diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index 7d7ed4fc06..2def243011 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -42,7 +42,7 @@ static pwmOutputPort_t servos[MAX_SUPPORTED_SERVOS]; #ifdef BEEPER static pwmOutputPort_t beeperPwm; -static uint16_t freqBeep=0; +static uint16_t freqBeep = 0; #endif bool pwmMotorsEnabled = false; @@ -456,7 +456,7 @@ void servoDevInit(const servoDevConfig_t *servoConfig) /* flag failure and disable ability to arm */ break; } - pwmOutConfig(&servos[servoIndex], timer, PWM_TIMER_HZ, PWM_TIMER_HZ / servoConfig->servoPwmRate, servoConfig->servoCenterPulse, 0); + pwmOutConfig(&servos[servoIndex], timer, PWM_TIMER_1MHZ, PWM_TIMER_1MHZ / servoConfig->servoPwmRate, servoConfig->servoCenterPulse, 0); servos[servoIndex].enabled = true; } } @@ -469,7 +469,7 @@ void pwmWriteBeeper(bool onoffBeep) if(!beeperPwm.io) return; if(onoffBeep == true) { - *beeperPwm.ccr = (PWM_TIMER_HZ / freqBeep) / 2; + *beeperPwm.ccr = (PWM_TIMER_1MHZ / freqBeep) / 2; beeperPwm.enabled = true; } else { *beeperPwm.ccr = 0; @@ -495,7 +495,7 @@ void beeperPwmInit(IO_t io, uint16_t frequency) IOConfigGPIO(beeperPwm.io, IOCFG_AF_PP); #endif freqBeep = frequency; - pwmOutConfig(&beeperPwm, timer, PWM_TIMER_HZ, PWM_TIMER_HZ / freqBeep, (PWM_TIMER_HZ / freqBeep) / 2, 0); + pwmOutConfig(&beeperPwm, timer, PWM_TIMER_1MHZ, PWM_TIMER_1MHZ / freqBeep, (PWM_TIMER_1MHZ / freqBeep) / 2, 0); } *beeperPwm.ccr = 0; beeperPwm.enabled = false; diff --git a/src/main/drivers/pwm_output.h b/src/main/drivers/pwm_output.h index 34c56c69d9..f0ef307c2a 100644 --- a/src/main/drivers/pwm_output.h +++ b/src/main/drivers/pwm_output.h @@ -77,7 +77,7 @@ typedef enum { PWM_TYPE_MAX } motorPwmProtocolTypes_e; -#define PWM_TIMER_HZ MHZ_TO_HZ(1) +#define PWM_TIMER_1MHZ MHZ_TO_HZ(1) #ifdef USE_DSHOT #define MAX_DMA_TIMERS 8 diff --git a/src/main/drivers/rx_pwm.c b/src/main/drivers/rx_pwm.c index 863e21e8e1..f922c83501 100644 --- a/src/main/drivers/rx_pwm.c +++ b/src/main/drivers/rx_pwm.c @@ -391,7 +391,7 @@ void pwmRxInit(const pwmConfig_t *pwmConfig) IOConfigGPIO(io, IOCFG_AF_PP); #endif - timerConfigure(timer, (uint16_t)PWM_TIMER_PERIOD, PWM_TIMER_HZ); + timerConfigure(timer, (uint16_t)PWM_TIMER_PERIOD, PWM_TIMER_1MHZ); timerChCCHandlerInit(&port->edgeCb, pwmEdgeCallback); timerChOvrHandlerInit(&port->overflowCb, pwmOverflowCallback); timerChConfigCallbacks(timer, &port->edgeCb, &port->overflowCb); @@ -448,7 +448,7 @@ void ppmRxInit(const ppmConfig_t *ppmConfig) IOConfigGPIO(io, IOCFG_AF_PP); #endif - timerConfigure(timer, (uint16_t)PPM_TIMER_PERIOD, PWM_TIMER_HZ); + timerConfigure(timer, (uint16_t)PPM_TIMER_PERIOD, PWM_TIMER_1MHZ); timerChCCHandlerInit(&port->edgeCb, ppmEdgeCallback); timerChOvrHandlerInit(&port->overflowCb, ppmOverflowCallback); timerChConfigCallbacks(timer, &port->edgeCb, &port->overflowCb); diff --git a/src/main/drivers/timer.h b/src/main/drivers/timer.h index 00cf4d8bc1..1127a1c45e 100644 --- a/src/main/drivers/timer.h +++ b/src/main/drivers/timer.h @@ -134,7 +134,7 @@ typedef enum { #define HARDWARE_TIMER_DEFINITION_COUNT 14 #endif -#define MHZ_TO_HZ(x) (x * 1000000) +#define MHZ_TO_HZ(x) ((x) * 1000000) extern const timerHardware_t timerHardware[]; extern const timerDef_t timerDefinitions[];