diff options
author | Keith Packard <keithp@keithp.com> | 2017-04-21 23:02:57 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-04-21 23:02:57 -0700 |
commit | 4682323a4bf147b9a908f5f9104bf01ab2cf0533 (patch) | |
tree | ccaa9214d144f550b55c71f570e20dfed061f6ae | |
parent | eb1c2bf5244840049c0a58e0ceecfcd9f5c290dd (diff) |
altos/stmf0: Pull beeper pin low when beeper is off
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>
-rw-r--r-- | src/stmf0/ao_beep_stm.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/stmf0/ao_beep_stm.c b/src/stmf0/ao_beep_stm.c index 84ccd93e..610f4a31 100644 --- a/src/stmf0/ao_beep_stm.c +++ b/src/stmf0/ao_beep_stm.c @@ -55,6 +55,9 @@ disable(void) 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); } void @@ -361,6 +364,9 @@ ao_beep(uint8_t beep) /* 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); #endif } } @@ -376,8 +382,7 @@ ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant 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); |