altos/stmf0: Add 'ao_serial_shutdown'
authorKeith Packard <keithp@keithp.com>
Tue, 16 Jul 2019 18:04:16 +0000 (11:04 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 16 Jul 2019 18:04:16 +0000 (11:04 -0700)
This powers down the UART logic on request.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_serial.h
src/stmf0/ao_serial_stm.c

index 440b562b0b26e5c00ad3bf2ca8b22093b51e5d54..3500a0933d80b268898656fb123b212d5c6ff65c 100644 (file)
@@ -117,6 +117,9 @@ void
 ao_serial3_set_speed(uint8_t speed);
 #endif
 
 ao_serial3_set_speed(uint8_t speed);
 #endif
 
+void
+ao_serial_shutdown(void);
+
 void
 ao_serial_init(void);
 
 void
 ao_serial_init(void);
 
index 5097041a7e10693cb55a25598acb06490087745b..ef35394aab53dec6bbf9f64d816d11ab2c5b5186 100644 (file)
@@ -375,6 +375,17 @@ ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart,
 }
 #endif
 
 }
 #endif
 
+void
+ao_serial_shutdown(void)
+{
+#if HAS_SERIAL_1
+       stm_rcc.apb2enr &= ~(1 << STM_RCC_APB2ENR_USART1EN);
+#endif
+#if HAS_SERIAL_2
+       stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USART2EN);
+#endif
+}
+
 void
 ao_serial_init(void)
 {
 void
 ao_serial_init(void)
 {