mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Multishot Implementation
This commit is contained in:
parent
6b8f4f1111
commit
ee76376005
6 changed files with 25 additions and 2 deletions
|
@ -38,6 +38,7 @@ typedef struct master_t {
|
||||||
uint16_t servo_pwm_rate; // The update rate of servo outputs (50-498Hz)
|
uint16_t servo_pwm_rate; // The update rate of servo outputs (50-498Hz)
|
||||||
uint8_t use_fast_pwm; // Use fast PWM implementation when oneshot enabled
|
uint8_t use_fast_pwm; // Use fast PWM implementation when oneshot enabled
|
||||||
uint8_t use_oneshot42; // Oneshot42
|
uint8_t use_oneshot42; // Oneshot42
|
||||||
|
uint8_t use_multiShot; // multishot
|
||||||
|
|
||||||
#ifdef USE_SERVOS
|
#ifdef USE_SERVOS
|
||||||
servoMixer_t customServoMixer[MAX_SERVO_RULES];
|
servoMixer_t customServoMixer[MAX_SERVO_RULES];
|
||||||
|
|
|
@ -33,6 +33,7 @@ void pwmBrushedMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIn
|
||||||
void pwmBrushlessMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint16_t motorPwmRate, uint16_t idlePulse);
|
void pwmBrushlessMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint16_t motorPwmRate, uint16_t idlePulse);
|
||||||
void fastPWMMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint16_t motorPwmRate, uint16_t idlePulse, uint8_t useOneshot42);
|
void fastPWMMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint16_t motorPwmRate, uint16_t idlePulse, uint8_t useOneshot42);
|
||||||
void pwmOneshotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint8_t useOneshot42);
|
void pwmOneshotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint8_t useOneshot42);
|
||||||
|
void pwmMultiShotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex);
|
||||||
void pwmServoConfig(const timerHardware_t *timerHardware, uint8_t servoIndex, uint16_t servoPwmRate, uint16_t servoCenterPulse);
|
void pwmServoConfig(const timerHardware_t *timerHardware, uint8_t servoIndex, uint16_t servoPwmRate, uint16_t servoCenterPulse);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -806,6 +807,8 @@ if (init->useBuzzerP6) {
|
||||||
if (init->useOneshot) {
|
if (init->useOneshot) {
|
||||||
if (init->useFastPWM) {
|
if (init->useFastPWM) {
|
||||||
fastPWMMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse, init->useOneshot42);
|
fastPWMMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse, init->useOneshot42);
|
||||||
|
} else if (init->useMultiShot) {
|
||||||
|
pwmMultiShotMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount);
|
||||||
} else {
|
} else {
|
||||||
pwmOneshotMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount, init->useOneshot42);
|
pwmOneshotMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount, init->useOneshot42);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#define PWM_TIMER_MHZ 1
|
#define PWM_TIMER_MHZ 1
|
||||||
#define ONESHOT125_TIMER_MHZ 24
|
#define ONESHOT125_TIMER_MHZ 24
|
||||||
#define PWM_BRUSHED_TIMER_MHZ 8
|
#define PWM_BRUSHED_TIMER_MHZ 8
|
||||||
|
#define MULTISHOT_TIMER_MHZ 12
|
||||||
|
|
||||||
typedef struct sonarGPIOConfig_s {
|
typedef struct sonarGPIOConfig_s {
|
||||||
GPIO_TypeDef *gpio;
|
GPIO_TypeDef *gpio;
|
||||||
|
@ -61,6 +62,7 @@ typedef struct drv_pwm_config_s {
|
||||||
bool useOneshot;
|
bool useOneshot;
|
||||||
bool useFastPWM;
|
bool useFastPWM;
|
||||||
bool useOneshot42;
|
bool useOneshot42;
|
||||||
|
bool useMultiShot;
|
||||||
bool useSoftSerial;
|
bool useSoftSerial;
|
||||||
bool useLEDStrip;
|
bool useLEDStrip;
|
||||||
#ifdef SONAR
|
#ifdef SONAR
|
||||||
|
|
|
@ -145,6 +145,11 @@ static void pwmWriteOneshot42(uint8_t index, uint16_t value)
|
||||||
*motors[index]->ccr = value;
|
*motors[index]->ccr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pwmWriteMultiShot(uint8_t index, uint16_t value)
|
||||||
|
{
|
||||||
|
*motors[index]->ccr = (uint16_t)((float)(value-1000) / 4.1666f)+ 60;
|
||||||
|
}
|
||||||
|
|
||||||
void pwmWriteMotor(uint8_t index, uint16_t value)
|
void pwmWriteMotor(uint8_t index, uint16_t value)
|
||||||
{
|
{
|
||||||
if (motors[index] && index < MAX_MOTORS)
|
if (motors[index] && index < MAX_MOTORS)
|
||||||
|
@ -221,6 +226,12 @@ void pwmOneshotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pwmMultiShotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex)
|
||||||
|
{
|
||||||
|
motors[motorIndex] = pwmOutConfig(timerHardware, MULTISHOT_TIMER_MHZ, 0xFFFF, 0);
|
||||||
|
motors[motorIndex]->pwmWritePtr = pwmWriteMultiShot;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_SERVOS
|
#ifdef USE_SERVOS
|
||||||
void pwmServoConfig(const timerHardware_t *timerHardware, uint8_t servoIndex, uint16_t servoPwmRate, uint16_t servoCenterPulse)
|
void pwmServoConfig(const timerHardware_t *timerHardware, uint8_t servoIndex, uint16_t servoPwmRate, uint16_t servoCenterPulse)
|
||||||
{
|
{
|
||||||
|
|
|
@ -530,6 +530,7 @@ const clivalue_t valueTable[] = {
|
||||||
|
|
||||||
{ "use_fast_pwm", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_fast_pwm, .config.lookup = { TABLE_OFF_ON } },
|
{ "use_fast_pwm", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_fast_pwm, .config.lookup = { TABLE_OFF_ON } },
|
||||||
{ "use_oneshot42", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_oneshot42, .config.lookup = { TABLE_OFF_ON } },
|
{ "use_oneshot42", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_oneshot42, .config.lookup = { TABLE_OFF_ON } },
|
||||||
|
{ "use_multishot", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_multiShot, .config.lookup = { TABLE_OFF_ON } },
|
||||||
#ifdef CC3D
|
#ifdef CC3D
|
||||||
{ "enable_buzzer_p6", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_buzzer_p6, .config.lookup = { TABLE_OFF_ON } },
|
{ "enable_buzzer_p6", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_buzzer_p6, .config.lookup = { TABLE_OFF_ON } },
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -308,8 +308,13 @@ void init(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pwm_params.useOneshot = feature(FEATURE_ONESHOT125);
|
pwm_params.useOneshot = feature(FEATURE_ONESHOT125);
|
||||||
|
if (masterConfig.use_fast_pwm || masterConfig.use_oneshot42) {
|
||||||
pwm_params.useFastPWM = masterConfig.use_fast_pwm ? true : false;
|
pwm_params.useFastPWM = masterConfig.use_fast_pwm ? true : false;
|
||||||
pwm_params.useOneshot42 = masterConfig.use_oneshot42 ? true : false;
|
pwm_params.useOneshot42 = masterConfig.use_oneshot42 ? true : false;
|
||||||
|
masterConfig.use_multiShot = false;
|
||||||
|
} else {
|
||||||
|
pwm_params.useMultiShot = masterConfig.use_multiShot ? true : false;
|
||||||
|
}
|
||||||
pwm_params.motorPwmRate = masterConfig.motor_pwm_rate;
|
pwm_params.motorPwmRate = masterConfig.motor_pwm_rate;
|
||||||
pwm_params.idlePulse = masterConfig.escAndServoConfig.mincommand;
|
pwm_params.idlePulse = masterConfig.escAndServoConfig.mincommand;
|
||||||
if (feature(FEATURE_3D))
|
if (feature(FEATURE_3D))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue