mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Prevent channel.ccr to be deferenced if timer failed to initialize
This commit is contained in:
parent
a2c6264d55
commit
37cd0404e5
1 changed files with 7 additions and 4 deletions
|
@ -487,9 +487,11 @@ void pwmToggleBeeper(void)
|
|||
|
||||
void beeperPwmInit(const ioTag_t tag, uint16_t frequency)
|
||||
{
|
||||
beeperPwm.io = IOGetByTag(tag);
|
||||
const timerHardware_t *timer = timerGetByTag(tag, TIM_USE_BEEPER);
|
||||
if (beeperPwm.io && timer) {
|
||||
IO_t beeperIO = IOGetByTag(tag);
|
||||
|
||||
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);
|
||||
|
@ -498,8 +500,9 @@ void beeperPwmInit(const ioTag_t tag, uint16_t frequency)
|
|||
#endif
|
||||
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…
Add table
Add a link
Reference in a new issue