White space tidy & add braces
This commit is contained in:
parent
22a7788fa3
commit
e87d14fe46
|
@ -469,40 +469,42 @@ void servoDevInit(const servoDevConfig_t *servoConfig)
|
|||
#ifdef USE_BEEPER
|
||||
void pwmWriteBeeper(bool onoffBeep)
|
||||
{
|
||||
if (!beeperPwm.io)
|
||||
return;
|
||||
if (onoffBeep == true) {
|
||||
*beeperPwm.channel.ccr = (PWM_TIMER_1MHZ / freqBeep) / 2;
|
||||
beeperPwm.enabled = true;
|
||||
} else {
|
||||
*beeperPwm.channel.ccr = 0;
|
||||
beeperPwm.enabled = false;
|
||||
}
|
||||
if (!beeperPwm.io) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (onoffBeep == true) {
|
||||
*beeperPwm.channel.ccr = (PWM_TIMER_1MHZ / freqBeep) / 2;
|
||||
beeperPwm.enabled = true;
|
||||
} else {
|
||||
*beeperPwm.channel.ccr = 0;
|
||||
beeperPwm.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
void pwmToggleBeeper(void)
|
||||
{
|
||||
pwmWriteBeeper(!beeperPwm.enabled);
|
||||
pwmWriteBeeper(!beeperPwm.enabled);
|
||||
}
|
||||
|
||||
void beeperPwmInit(const ioTag_t tag, uint16_t frequency)
|
||||
{
|
||||
const timerHardware_t *timer = timerGetByTag(tag, TIM_USE_BEEPER);
|
||||
IO_t beeperIO = IOGetByTag(tag);
|
||||
const timerHardware_t *timer = timerGetByTag(tag, TIM_USE_BEEPER);
|
||||
IO_t beeperIO = IOGetByTag(tag);
|
||||
|
||||
if (beeperIO && timer) {
|
||||
beeperPwm.io = beeperIO;
|
||||
IOInit(beeperPwm.io, OWNER_BEEPER, RESOURCE_INDEX(0));
|
||||
if (beeperIO && timer) {
|
||||
beeperPwm.io = beeperIO;
|
||||
IOInit(beeperPwm.io, OWNER_BEEPER, RESOURCE_INDEX(0));
|
||||
#if defined(USE_HAL_DRIVER)
|
||||
IOConfigGPIOAF(beeperPwm.io, IOCFG_AF_PP, timer->alternateFunction);
|
||||
IOConfigGPIOAF(beeperPwm.io, IOCFG_AF_PP, timer->alternateFunction);
|
||||
#else
|
||||
IOConfigGPIO(beeperPwm.io, IOCFG_AF_PP);
|
||||
IOConfigGPIO(beeperPwm.io, IOCFG_AF_PP);
|
||||
#endif
|
||||
freqBeep = frequency;
|
||||
pwmOutConfig(&beeperPwm.channel, timer, PWM_TIMER_1MHZ, PWM_TIMER_1MHZ / freqBeep, (PWM_TIMER_1MHZ / freqBeep) / 2, 0);
|
||||
freqBeep = frequency;
|
||||
pwmOutConfig(&beeperPwm.channel, timer, PWM_TIMER_1MHZ, PWM_TIMER_1MHZ / freqBeep, (PWM_TIMER_1MHZ / freqBeep) / 2, 0);
|
||||
|
||||
*beeperPwm.channel.ccr = 0;
|
||||
beeperPwm.enabled = false;
|
||||
}
|
||||
*beeperPwm.channel.ccr = 0;
|
||||
beeperPwm.enabled = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue