Modified version of the mbed library for use with the Nucleo boards.
Dependents: EEPROMWrite Full-Project
Fork of mbed-src by
Diff: targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_usart_ex.h
- Revision:
- 630:825f75ca301e
- Parent:
- 441:d2c15dda23c1
--- a/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_usart_ex.h Mon Sep 28 10:30:09 2015 +0100 +++ b/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_usart_ex.h Mon Sep 28 10:45:10 2015 +0100 @@ -2,13 +2,13 @@ ****************************************************************************** * @file stm32f0xx_hal_usart_ex.h * @author MCD Application Team - * @version V1.2.0 - * @date 11-December-2014 + * @version V1.3.0 + * @date 26-June-2015 * @brief Header file of USART HAL Extension module. ****************************************************************************** * @attention - * - * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> + * + * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -32,7 +32,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - ****************************************************************************** + ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ @@ -50,7 +50,7 @@ * @{ */ -/** @defgroup USARTEx USARTEx Extended HAL module driver +/** @defgroup USARTEx USARTEx * @{ */ @@ -59,38 +59,94 @@ /** @defgroup USARTEx_Exported_Constants USARTEx Exported Constants * @{ */ - + /** @defgroup USARTEx_Word_Length USARTEx Word Length * @{ */ #if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \ defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \ defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) -#define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) -#define USART_WORDLENGTH_8B ((uint32_t)0x00000000) -#define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) -#define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_7B) || \ - ((LENGTH) == USART_WORDLENGTH_8B) || \ - ((LENGTH) == USART_WORDLENGTH_9B)) +#define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) /*!< 7-bit long USART frame */ +#define USART_WORDLENGTH_8B ((uint32_t)0x00000000) /*!< 8-bit long USART frame */ +#define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) /*!< 9-bit long USART frame */ #else -#define USART_WORDLENGTH_8B ((uint32_t)0x00000000) -#define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) -#define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_8B) || \ - ((LENGTH) == USART_WORDLENGTH_9B)) +#define USART_WORDLENGTH_8B ((uint32_t)0x00000000) /*!< 8-bit long USART frame */ +#define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) /*!< 9-bit long USART frame */ #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || defined (STM32F070xB) || \ defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */ /** * @} */ - + +/** @defgroup USART_Request_Parameters USARTEx Request Parameters + * @{ + */ +#define USART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */ +#if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) +#define USART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */ +#else +#endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ +/** + * @} + */ + +/** @defgroup USART_Flags USART Flags + * Elements values convention: 0xXXXX + * - 0xXXXX : Flag mask in the ISR register + * @{ + */ +#if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) +#define USART_FLAG_REACK ((uint32_t)0x00400000) /*!< USART receive enable acknowledge flag */ +#endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ +#define USART_FLAG_TEACK ((uint32_t)0x00200000) /*!< USART transmit enable acknowledge flag */ +#define USART_FLAG_BUSY ((uint32_t)0x00010000) /*!< USART busy flag */ +#define USART_FLAG_CTS ((uint32_t)0x00000400) /*!< USART clear to send flag */ +#define USART_FLAG_CTSIF ((uint32_t)0x00000200) /*!< USART clear to send interrupt flag */ +#define USART_FLAG_TXE ((uint32_t)0x00000080) /*!< USART transmit data register empty */ +#define USART_FLAG_TC ((uint32_t)0x00000040) /*!< USART transmission complete */ +#define USART_FLAG_RXNE ((uint32_t)0x00000020) /*!< USART read data register not empty */ +#define USART_FLAG_IDLE ((uint32_t)0x00000010) /*!< USART idle flag */ +#define USART_FLAG_ORE ((uint32_t)0x00000008) /*!< USART overrun error */ +#define USART_FLAG_NE ((uint32_t)0x00000004) /*!< USART noise error */ +#define USART_FLAG_FE ((uint32_t)0x00000002) /*!< USART frame error */ +#define USART_FLAG_PE ((uint32_t)0x00000001) /*!< USART parity error */ /** * @} - */ - -/* Exported macro ------------------------------------------------------------*/ + */ + +/** + * @} + */ + +/* Exported macros ------------------------------------------------------------*/ +/** @defgroup USARTEx_Exported_Macros USARTEx Exported Macros + * @{ + */ -/** @defgroup USARTEx_Exported_Macros USARTEx Exported Macros +/** @brief Flush the USART Data registers. + * @param __HANDLE__: specifies the USART Handle. + * @retval None + */ +#if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) +#define __HAL_USART_FLUSH_DRREGISTER(__HANDLE__) \ + do{ \ + SET_BIT((__HANDLE__)->Instance->RQR, USART_RXDATA_FLUSH_REQUEST); \ + SET_BIT((__HANDLE__)->Instance->RQR, USART_TXDATA_FLUSH_REQUEST); \ + } while(0) +#else +#define __HAL_USART_FLUSH_DRREGISTER(__HANDLE__) \ + do{ \ + SET_BIT((__HANDLE__)->Instance->RQR, USART_RXDATA_FLUSH_REQUEST); \ + } while(0) +#endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ + +/** + * @} + */ + +/* Private macros ------------------------------------------------------------*/ +/** @defgroup USARTEx_Private_Macros USARTEx Private Macros * @{ */ @@ -100,7 +156,7 @@ * @retval the USART clocking source, written in __CLOCKSOURCE__. */ #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) -#define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ +#define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ do { \ switch(__HAL_RCC_GET_USART1_SOURCE()) \ { \ @@ -124,7 +180,7 @@ #elif defined (STM32F030x8) || defined (STM32F070x6) || \ defined (STM32F042x6) || defined (STM32F048xx) || \ defined (STM32F051x8) || defined (STM32F058xx) -#define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ +#define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ do { \ if((__HANDLE__)->Instance == USART1) \ { \ @@ -155,9 +211,9 @@ { \ (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ } \ - } while(0) + } while(0) #elif defined (STM32F070xB) -#define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ +#define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ do { \ if((__HANDLE__)->Instance == USART1) \ { \ @@ -196,9 +252,9 @@ { \ (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ } \ - } while(0) + } while(0) #elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) -#define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ +#define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ do { \ if((__HANDLE__)->Instance == USART1) \ { \ @@ -254,9 +310,9 @@ { \ (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ } \ - } while(0) + } while(0) #elif defined(STM32F091xC) || defined (STM32F098xx) -#define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ +#define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ do { \ if((__HANDLE__)->Instance == USART1) \ { \ @@ -347,7 +403,7 @@ } \ } while(0) #elif defined(STM32F030xC) -#define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ +#define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ do { \ if((__HANDLE__)->Instance == USART1) \ { \ @@ -394,23 +450,23 @@ { \ (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ } \ - } while(0) + } while(0) #endif /* defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) */ - -/** @brief Reports the USART mask to apply to retrieve the received data + +/** @brief Compute the USART mask to apply to retrieve the received data * according to the word length and to the parity bits activation. - * If PCE = 1, the parity bit is not included in the data extracted + * @note If PCE = 1, the parity bit is not included in the data extracted * by the reception API(). * This masking operation is not carried out in the case of - * DMA transfers. - * @param __HANDLE__: specifies the USART Handle - * @retval none - */ + * DMA transfers. + * @param __HANDLE__: specifies the USART Handle. + * @retval None, the mask to apply to USART RDR register is stored in (__HANDLE__)->Mask field. + */ #if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \ defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \ defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) -#define __HAL_USART_MASK_COMPUTATION(__HANDLE__) \ +#define USART_MASK_COMPUTATION(__HANDLE__) \ do { \ if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \ { \ @@ -445,9 +501,9 @@ (__HANDLE__)->Mask = 0x003F ; \ } \ } \ -} while(0) +} while(0) #else -#define __HAL_USART_MASK_COMPUTATION(__HANDLE__) \ +#define USART_MASK_COMPUTATION(__HANDLE__) \ do { \ if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \ { \ @@ -471,28 +527,56 @@ (__HANDLE__)->Mask = 0x007F ; \ } \ } \ -} while(0) +} while(0) #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \ defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \ defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */ + + +/** + * @brief Ensure that USART frame length is valid. + * @param __LENGTH__: USART frame length. + * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid) + */ +#if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \ + defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \ + defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) +#define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_7B) || \ + ((__LENGTH__) == USART_WORDLENGTH_8B) || \ + ((__LENGTH__) == USART_WORDLENGTH_9B)) +#else +#define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_8B) || \ + ((__LENGTH__) == USART_WORDLENGTH_9B)) +#endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || defined (STM32F070xB) || \ + defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ + defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */ + +/** + * @brief Ensure that USART request parameter is valid. + * @param __PARAM__: USART request parameter. + * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid) + */ +#if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) +#define IS_USART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) || \ + ((__PARAM__) == USART_TXDATA_FLUSH_REQUEST)) +#else +#define IS_USART_REQUEST_PARAMETER(__PARAM__) ((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) +#endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ + /** * @} */ /* Exported functions --------------------------------------------------------*/ -/* Initialization and de-initialization functions ****************************/ -/* I/O operation functions ***************************************************/ -/* Peripheral Control functions **********************************************/ -/* Peripheral State functions ************************************************/ /** * @} - */ + */ /** * @} - */ - + */ + #ifdef __cplusplus } #endif