Multishot Implementation
This commit is contained in:
parent
6b8f4f1111
commit
ee76376005
|
@ -38,6 +38,7 @@ typedef struct master_t {
|
|||
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_oneshot42; // Oneshot42
|
||||
uint8_t use_multiShot; // multishot
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
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 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 pwmMultiShotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex);
|
||||
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->useFastPWM) {
|
||||
fastPWMMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse, init->useOneshot42);
|
||||
} else if (init->useMultiShot) {
|
||||
pwmMultiShotMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount);
|
||||
} else {
|
||||
pwmOneshotMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount, init->useOneshot42);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#define PWM_TIMER_MHZ 1
|
||||
#define ONESHOT125_TIMER_MHZ 24
|
||||
#define PWM_BRUSHED_TIMER_MHZ 8
|
||||
#define MULTISHOT_TIMER_MHZ 12
|
||||
|
||||
typedef struct sonarGPIOConfig_s {
|
||||
GPIO_TypeDef *gpio;
|
||||
|
@ -61,6 +62,7 @@ typedef struct drv_pwm_config_s {
|
|||
bool useOneshot;
|
||||
bool useFastPWM;
|
||||
bool useOneshot42;
|
||||
bool useMultiShot;
|
||||
bool useSoftSerial;
|
||||
bool useLEDStrip;
|
||||
#ifdef SONAR
|
||||
|
|
|
@ -145,6 +145,11 @@ static void pwmWriteOneshot42(uint8_t index, uint16_t 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)
|
||||
{
|
||||
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
|
||||
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_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
|
||||
{ "enable_buzzer_p6", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_buzzer_p6, .config.lookup = { TABLE_OFF_ON } },
|
||||
#endif
|
||||
|
|
|
@ -308,8 +308,13 @@ void init(void)
|
|||
#endif
|
||||
|
||||
pwm_params.useOneshot = feature(FEATURE_ONESHOT125);
|
||||
pwm_params.useFastPWM = masterConfig.use_fast_pwm ? true : false;
|
||||
pwm_params.useOneshot42 = masterConfig.use_oneshot42 ? true : false;
|
||||
if (masterConfig.use_fast_pwm || masterConfig.use_oneshot42) {
|
||||
pwm_params.useFastPWM = masterConfig.use_fast_pwm ? 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.idlePulse = masterConfig.escAndServoConfig.mincommand;
|
||||
if (feature(FEATURE_3D))
|
||||
|
|
Loading…
Reference in New Issue