1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 21:35:44 +03:00

Oneshot42 Implementation

This commit is contained in:
borisbstyle 2016-02-22 15:13:36 +01:00
parent e561ec3cb7
commit 6b8f4f1111
7 changed files with 33 additions and 11 deletions

View file

@ -135,6 +135,16 @@ static void pwmWriteStandard(uint8_t index, uint16_t value)
*motors[index]->ccr = value;
}
static void pwmWriteOneshot(uint8_t index, uint16_t value)
{
*motors[index]->ccr = value * 3; // 24Mhz -> 8Mhz
}
static void pwmWriteOneshot42(uint8_t index, uint16_t value)
{
*motors[index]->ccr = value;
}
void pwmWriteMotor(uint8_t index, uint16_t value)
{
if (motors[index] && index < MAX_MOTORS)
@ -190,17 +200,25 @@ void pwmBrushlessMotorConfig(const timerHardware_t *timerHardware, uint8_t motor
motors[motorIndex]->pwmWritePtr = pwmWriteStandard;
}
void fastPWMMotorConfig(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)
{
uint32_t hz = PWM_BRUSHED_TIMER_MHZ * 1000000;
motors[motorIndex] = pwmOutConfig(timerHardware, ONESHOT125_TIMER_MHZ, hz / motorPwmRate, idlePulse);
motors[motorIndex]->pwmWritePtr = pwmWriteStandard;
if (useOneshot42) {
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot42;
} else {
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot;
}
}
void pwmOneshotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex)
void pwmOneshotMotorConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, uint8_t useOneshot42)
{
motors[motorIndex] = pwmOutConfig(timerHardware, ONESHOT125_TIMER_MHZ, 0xFFFF, 0);
motors[motorIndex]->pwmWritePtr = pwmWriteStandard;
if (useOneshot42) {
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot42;
} else {
motors[motorIndex]->pwmWritePtr = pwmWriteOneshot;
}
}
#ifdef USE_SERVOS