1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +03:00

Split PWM code into appropriate separate files - mapping, rx and output.

By decoupling everything the structures now only contain members they need.  The mapping code is simplified.  The calculation of timer periods is now where it belongs (with the output code, not with the mapping code).  Also, since each motor output has it's own callback method it is technically possible to mix brushed and brushless motors if the brushed motors and brushless motors use different timers.  Additional code would be required to fully support that.
This commit is contained in:
Dominic Clifton 2014-05-06 07:48:11 +01:00
parent adfbb8ac43
commit 6721587566
13 changed files with 601 additions and 473 deletions

60
src/drivers/pwm_mapping.h Executable file
View file

@ -0,0 +1,60 @@
#pragma once
#define MAX_PWM_MOTORS 12
#define MAX_PWM_SERVOS 8
#define MAX_PWM_INPUT_PORTS 8
#define MAX_MOTORS 12
#define MAX_SERVOS 8
#define MAX_PWM_OUTPUT_PORTS MAX_PWM_MOTORS // must be set to the largest of either MAX_MOTORS or MAX_SERVOS
#if MAX_PWM_OUTPUT_PORTS < MAX_MOTORS || MAX_PWM_OUTPUT_PORTS < MAX_SERVOS
#error Invalid motor/servo/port configuration
#endif
#define PULSE_1MS (1000) // 1ms pulse width
#define PULSE_MIN (750) // minimum PWM pulse width which is considered valid
#define PULSE_MAX (2250) // maximum PWM pulse width which is considered valid
#define MAX_INPUTS 8
#define PWM_TIMER_MHZ 1
typedef struct drv_pwm_config_t {
bool enableInput;
bool usePPM;
bool useUART;
bool useSoftSerial;
bool useServos;
bool extraServos; // configure additional 4 channels in PPM mode as servos, not motors
bool airplane; // fixed wing hardware config, lots of servos etc
uint8_t adcChannel; // steal one RC input for current sensor
uint16_t motorPwmRate;
uint16_t servoPwmRate;
uint16_t idlePulse; // PWM value to use when initializing the driver. set this to either PULSE_1MS (regular pwm),
// some higher value (used by 3d mode), or 0, for brushed pwm drivers.
uint16_t servoCenterPulse;
} drv_pwm_config_t;
// This indexes into the read-only hardware definition structure, timerHardware_t, as well as into pwmPorts structure with dynamic data.
enum {
PWM1 = 0,
PWM2,
PWM3,
PWM4,
PWM5,
PWM6,
PWM7,
PWM8,
PWM9,
PWM10,
PWM11,
PWM12,
PWM13,
PWM14
};