From bdcb3653bd9fb97f98773ac3bc1f87a6f52b1121 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 16 Jul 2019 11:04:16 -0700 Subject: [PATCH] altos/stmf0: Add 'ao_serial_shutdown' This powers down the UART logic on request. Signed-off-by: Keith Packard --- src/kernel/ao_serial.h | 3 +++ src/stmf0/ao_serial_stm.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/kernel/ao_serial.h b/src/kernel/ao_serial.h index 440b562b..3500a093 100644 --- a/src/kernel/ao_serial.h +++ b/src/kernel/ao_serial.h @@ -117,6 +117,9 @@ void ao_serial3_set_speed(uint8_t speed); #endif +void +ao_serial_shutdown(void); + void ao_serial_init(void); diff --git a/src/stmf0/ao_serial_stm.c b/src/stmf0/ao_serial_stm.c index 5097041a..ef35394a 100644 --- a/src/stmf0/ao_serial_stm.c +++ b/src/stmf0/ao_serial_stm.c @@ -375,6 +375,17 @@ ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart, } #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) { -- 2.30.2