FastPwm for all oneshot42/125 and multishot // Cleanup
This commit is contained in:
parent
702ef4e798
commit
e0c1f84206
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
void pwmBrushedMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint16_t motorPwmRate, uint16_t idlePulse);
|
void pwmBrushedMotorConfig(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 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, uint8_t useMultiShot);
|
||||||
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 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,7 +806,7 @@ if (init->useBuzzerP6) {
|
||||||
#endif
|
#endif
|
||||||
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, init->useMultiShot);
|
||||||
} else if (init->useMultiShot) {
|
} else if (init->useMultiShot) {
|
||||||
pwmMultiShotMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount);
|
pwmMultiShotMotorConfig(timerHardwarePtr, pwmOutputConfiguration.motorCount);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define MAX_INPUTS 8
|
#define MAX_INPUTS 8
|
||||||
|
|
||||||
#define PWM_TIMER_MHZ 1
|
#define PWM_TIMER_MHZ 1
|
||||||
#define ONESHOT125_TIMER_MHZ 24
|
#define ONESHOT_TIMER_MHZ 24
|
||||||
#define PWM_BRUSHED_TIMER_MHZ 8
|
#define PWM_BRUSHED_TIMER_MHZ 8
|
||||||
#define MULTISHOT_TIMER_MHZ 12
|
#define MULTISHOT_TIMER_MHZ 12
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ static void pwmWriteStandard(uint8_t index, uint16_t value)
|
||||||
*motors[index]->ccr = value;
|
*motors[index]->ccr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pwmWriteOneshot(uint8_t index, uint16_t value)
|
static void pwmWriteOneshot125(uint8_t index, uint16_t value)
|
||||||
{
|
{
|
||||||
*motors[index]->ccr = value * 3; // 24Mhz -> 8Mhz
|
*motors[index]->ccr = value * 3; // 24Mhz -> 8Mhz
|
||||||
}
|
}
|
||||||
|
@ -205,24 +205,33 @@ void pwmBrushlessMotorConfig(const timerHardware_t *timerHardware, uint8_t motor
|
||||||
motors[motorIndex]->pwmWritePtr = pwmWriteStandard;
|
motors[motorIndex]->pwmWritePtr = pwmWriteStandard;
|
||||||
}
|
}
|
||||||
|
|
||||||
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, uint8_t useMultiShot)
|
||||||
{
|
{
|
||||||
uint32_t hz = PWM_BRUSHED_TIMER_MHZ * 1000000;
|
uint32_t hz;
|
||||||
motors[motorIndex] = pwmOutConfig(timerHardware, ONESHOT125_TIMER_MHZ, hz / motorPwmRate, idlePulse);
|
if (useMultiShot) {
|
||||||
|
hz = MULTISHOT_TIMER_MHZ * 1000000;
|
||||||
|
motors[motorIndex] = pwmOutConfig(timerHardware, MULTISHOT_TIMER_MHZ, hz / motorPwmRate, idlePulse);
|
||||||
|
} else {
|
||||||
|
hz = ONESHOT_TIMER_MHZ * 1000000;
|
||||||
|
motors[motorIndex] = pwmOutConfig(timerHardware, ONESHOT_TIMER_MHZ, hz / motorPwmRate, idlePulse);
|
||||||
|
}
|
||||||
|
|
||||||
if (useOneshot42) {
|
if (useOneshot42) {
|
||||||
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot42;
|
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot42;
|
||||||
|
} else if (useMultiShot) {
|
||||||
|
motors[motorIndex]->pwmWritePtr = pwmWriteMultiShot;
|
||||||
} else {
|
} else {
|
||||||
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot;
|
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot125;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwmOneshotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint8_t useOneshot42)
|
void pwmOneshotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint8_t useOneshot42)
|
||||||
{
|
{
|
||||||
motors[motorIndex] = pwmOutConfig(timerHardware, ONESHOT125_TIMER_MHZ, 0xFFFF, 0);
|
motors[motorIndex] = pwmOutConfig(timerHardware, ONESHOT_TIMER_MHZ, 0xFFFF, 0);
|
||||||
if (useOneshot42) {
|
if (useOneshot42) {
|
||||||
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot42;
|
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot42;
|
||||||
} else {
|
} else {
|
||||||
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot;
|
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot125;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,8 +308,8 @@ 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;
|
||||||
|
if (masterConfig.use_oneshot42) {
|
||||||
pwm_params.useOneshot42 = masterConfig.use_oneshot42 ? true : false;
|
pwm_params.useOneshot42 = masterConfig.use_oneshot42 ? true : false;
|
||||||
masterConfig.use_multiShot = false;
|
masterConfig.use_multiShot = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue