From 557e2a0b09b978969a4a800ea57e5f0edb22e9e9 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Tue, 24 Oct 2017 23:52:38 +0000 Subject: [PATCH] stm32: uart: add USART_FLAG_ defines Similar to how we have abstract defines for the stop bits, parity and flow control common mode namees, provide abstract flag names for the "standard" flags. This allows us to start using common API code for v1 and v2 uarts For stm32f3, drop the "compatibility" defines that simply pollute the namespace, making it confusingly appear as if f3 has both SR and ISR registers. --- .../stm32/common/usart_common_f124.h | 17 ++++++++ .../libopencm3/stm32/common/usart_common_v2.h | 18 ++++++++ include/libopencm3/stm32/f3/usart.h | 41 ------------------- 3 files changed, 35 insertions(+), 41 deletions(-) diff --git a/include/libopencm3/stm32/common/usart_common_f124.h b/include/libopencm3/stm32/common/usart_common_f124.h index 283503d2..bfe50cd0 100644 --- a/include/libopencm3/stm32/common/usart_common_f124.h +++ b/include/libopencm3/stm32/common/usart_common_f124.h @@ -95,6 +95,23 @@ specific memorymap.h header before including this header file.*/ #define UART4_GTPR USART_GTPR(UART4_BASE) #define UART5_GTPR USART_GTPR(UART5_BASE) +/** @defgroup usart_convenience_flags U(S)ART convenience Flags + * @ingroup STM32F_usart_defines + * We define the "common" lower flag bits using a standard name, + * allowing them to be used regardless of which usart peripheral + * version you have. + * @{ + */ +#define USART_FLAG_PE USART_SR_PE +#define USART_FLAG_FE USART_SR_FE +#define USART_FLAG_NF USART_SR_NF +#define USART_FLAG_ORE USART_SR_ORE +#define USART_FLAG_IDLE USART_SR_IDLE +#define USART_FLAG_RXNE USART_SR_RXNE +#define USART_FLAG_TC USART_SR_TC +#define USART_FLAG_TXE USART_SR_TXE +/**@}*/ + /* --- USART_SR values ----------------------------------------------------- */ /****************************************************************************/ /** @defgroup usart_sr_flags USART Status register Flags diff --git a/include/libopencm3/stm32/common/usart_common_v2.h b/include/libopencm3/stm32/common/usart_common_v2.h index 2ae3ee35..4b5bee60 100644 --- a/include/libopencm3/stm32/common/usart_common_v2.h +++ b/include/libopencm3/stm32/common/usart_common_v2.h @@ -196,6 +196,24 @@ /**@}*/ +/** @defgroup usart_convenience_flags U(S)ART convenience Flags + * @ingroup STM32F_usart_defines + * We define the "common" lower flag bits using a standard name, + * allowing them to be used regardless of which usart peripheral + * version you have. + * @{ + */ +#define USART_FLAG_PE USART_ISR_PE +#define USART_FLAG_FE USART_ISR_FE +#define USART_FLAG_NF USART_ISR_NF +#define USART_FLAG_ORE USART_ISR_ORE +#define USART_FLAG_IDLE USART_ISR_IDLE +#define USART_FLAG_RXNE USART_ISR_RXNE +#define USART_FLAG_TC USART_ISR_TC +#define USART_FLAG_TXE USART_ISR_TXE +/**@}*/ + + /*****************************************************************************/ /* Register values */ /*****************************************************************************/ diff --git a/include/libopencm3/stm32/f3/usart.h b/include/libopencm3/stm32/f3/usart.h index 4d3766f7..ce4af10f 100644 --- a/include/libopencm3/stm32/f3/usart.h +++ b/include/libopencm3/stm32/f3/usart.h @@ -80,47 +80,6 @@ - -/* --- USART_SR values ----------------------------------------------------- */ -/****************************************************************************/ -/** @defgroup usart_sr_flags USART Status register Flags -@ingroup STM32F_usart_defines - -@{*/ - -/** CTS: CTS flag */ -/** @note: undefined on UART4 and UART5 */ -#define USART_SR_CTS USART_ISR_CTS - -/** LBD: LIN break detection flag */ -#define USART_SR_LBD USART_ISR_LBDF - -/** TXE: Transmit data buffer empty */ -#define USART_SR_TXE USART_ISR_TXE - -/** TC: Transmission complete */ -#define USART_SR_TC USART_ISR_TC - -/** RXNE: Read data register not empty */ -#define USART_SR_RXNE USART_ISR_RXNE - -/** IDLE: Idle line detected */ -#define USART_SR_IDLE USART_ISR_IDLE - -/** ORE: Overrun error */ -#define USART_SR_ORE USART_ISR_ORE - -/** NE: Noise error flag */ -#define USART_SR_NE USART_ISR_NF - -/** FE: Framing error */ -#define USART_SR_FE USART_ISR_FE - -/** PE: Parity error */ -#define USART_SR_PE USART_ISR_PE -/**@}*/ - - /* --- USART_RDR values --------------------------------------------------- */ /* RDR[8:0]: Receive data value */