This avoids having the pin float and pick up noise from any adjacent
signals, like TeleMini's radio.
Signed-off-by: Keith Packard <keithp@keithp.com>
timer.bdtr = 0;
#endif
stm_rcc_enr &= ~(1 << STM_RCC_TIMER);
timer.bdtr = 0;
#endif
stm_rcc_enr &= ~(1 << STM_RCC_TIMER);
+
+ /* Disconnect the timer from the pin */
+ stm_afr_set(BEEPER_PORT, BEEPER_PIN, STM_AFR_NONE);
/* Update the values */
timer.egr = (1 << STM_TIM23_EGR_UG);
/* Update the values */
timer.egr = (1 << STM_TIM23_EGR_UG);
+
+ /* Hook the timer up to the beeper pin */
+ stm_afr_set(BEEPER_PORT, BEEPER_PIN, STM_AFR_AF2);
void
ao_beep_init(void)
{
void
ao_beep_init(void)
{
- ao_enable_port(BEEPER_PORT);
- stm_afr_set(BEEPER_PORT, BEEPER_PIN, STM_AFR_AF2);
+ ao_enable_output(BEEPER_PORT, BEEPER_PIN, BEEPER, 0);
/* Leave the timer off until requested */
stm_rcc_enr &= ~(1 << STM_RCC_TIMER);
/* Leave the timer off until requested */
stm_rcc_enr &= ~(1 << STM_RCC_TIMER);