my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Parent:
92:4fc01daae5a5
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 84:0b3ab51c8877 1 /**
bogdanm 84:0b3ab51c8877 2 ******************************************************************************
bogdanm 84:0b3ab51c8877 3 * @file stm32l0xx_hal_usart_ex.h
bogdanm 84:0b3ab51c8877 4 * @author MCD Application Team
Kojto 96:487b796308b0 5 * @version V1.2.0
Kojto 96:487b796308b0 6 * @date 06-February-2015
bogdanm 84:0b3ab51c8877 7 * @brief Header file of USART HAL Extension module.
bogdanm 84:0b3ab51c8877 8 ******************************************************************************
bogdanm 84:0b3ab51c8877 9 * @attention
bogdanm 84:0b3ab51c8877 10 *
Kojto 96:487b796308b0 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
bogdanm 84:0b3ab51c8877 12 *
bogdanm 84:0b3ab51c8877 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 84:0b3ab51c8877 14 * are permitted provided that the following conditions are met:
bogdanm 84:0b3ab51c8877 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 84:0b3ab51c8877 16 * this list of conditions and the following disclaimer.
bogdanm 84:0b3ab51c8877 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 84:0b3ab51c8877 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 84:0b3ab51c8877 19 * and/or other materials provided with the distribution.
bogdanm 84:0b3ab51c8877 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 84:0b3ab51c8877 21 * may be used to endorse or promote products derived from this software
bogdanm 84:0b3ab51c8877 22 * without specific prior written permission.
bogdanm 84:0b3ab51c8877 23 *
bogdanm 84:0b3ab51c8877 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 84:0b3ab51c8877 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 84:0b3ab51c8877 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 84:0b3ab51c8877 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 84:0b3ab51c8877 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 84:0b3ab51c8877 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 84:0b3ab51c8877 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 84:0b3ab51c8877 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 84:0b3ab51c8877 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 84:0b3ab51c8877 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 84:0b3ab51c8877 34 *
bogdanm 84:0b3ab51c8877 35 ******************************************************************************
bogdanm 84:0b3ab51c8877 36 */
bogdanm 84:0b3ab51c8877 37
bogdanm 84:0b3ab51c8877 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 84:0b3ab51c8877 39 #ifndef __STM32L0xx_HAL_USART_EX_H
bogdanm 84:0b3ab51c8877 40 #define __STM32L0xx_HAL_USART_EX_H
bogdanm 84:0b3ab51c8877 41
bogdanm 84:0b3ab51c8877 42 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 43 extern "C" {
bogdanm 84:0b3ab51c8877 44 #endif
bogdanm 84:0b3ab51c8877 45
bogdanm 84:0b3ab51c8877 46 /* Includes ------------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 47 #include "stm32l0xx_hal_def.h"
bogdanm 84:0b3ab51c8877 48
bogdanm 84:0b3ab51c8877 49 /** @addtogroup STM32L0xx_HAL_Driver
bogdanm 84:0b3ab51c8877 50 * @{
bogdanm 84:0b3ab51c8877 51 */
Kojto 96:487b796308b0 52 /** @defgroup USARTEx USARTEx Extended USART
bogdanm 84:0b3ab51c8877 53 * @{
Kojto 96:487b796308b0 54 */
bogdanm 84:0b3ab51c8877 55
bogdanm 84:0b3ab51c8877 56 /* Exported types ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 57 /* Exported constants --------------------------------------------------------*/
Kojto 96:487b796308b0 58 /** @defgroup USARTEx_Exported_Constants USARTEx Exported Constants
bogdanm 84:0b3ab51c8877 59 * @{
bogdanm 84:0b3ab51c8877 60 */
bogdanm 84:0b3ab51c8877 61
Kojto 96:487b796308b0 62 /** @defgroup USARTEx_Word_Length Word length definition
bogdanm 84:0b3ab51c8877 63 * @{
bogdanm 84:0b3ab51c8877 64 */
bogdanm 84:0b3ab51c8877 65 #define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M_1)
bogdanm 84:0b3ab51c8877 66 #define USART_WORDLENGTH_8B ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 67 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M_0)
bogdanm 84:0b3ab51c8877 68 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_7B) || \
bogdanm 84:0b3ab51c8877 69 ((LENGTH) == USART_WORDLENGTH_8B) || \
bogdanm 84:0b3ab51c8877 70 ((LENGTH) == USART_WORDLENGTH_9B))
bogdanm 84:0b3ab51c8877 71 /**
bogdanm 84:0b3ab51c8877 72 * @}
bogdanm 84:0b3ab51c8877 73 */
bogdanm 84:0b3ab51c8877 74
bogdanm 84:0b3ab51c8877 75 /**
bogdanm 84:0b3ab51c8877 76 * @}
bogdanm 84:0b3ab51c8877 77 */
bogdanm 84:0b3ab51c8877 78 /* Exported macro ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 79
Kojto 96:487b796308b0 80 /** @defgroup USARTEx_Extended_Exported_Macros USARTEx Exported Macros
bogdanm 84:0b3ab51c8877 81 * @{
bogdanm 84:0b3ab51c8877 82 */
bogdanm 84:0b3ab51c8877 83
bogdanm 84:0b3ab51c8877 84 /** @brief Reports the USART clock source.
bogdanm 84:0b3ab51c8877 85 * @param __HANDLE__: specifies the USART Handle
bogdanm 84:0b3ab51c8877 86 * @param __CLOCKSOURCE__ : output variable
bogdanm 84:0b3ab51c8877 87 * @retval the USART clocking source, written in __CLOCKSOURCE__.
bogdanm 84:0b3ab51c8877 88 */
Kojto 96:487b796308b0 89 #if defined (STM32L031xx) || defined (STM32L041xx)
Kojto 96:487b796308b0 90 #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 96:487b796308b0 91 do { \
Kojto 96:487b796308b0 92 if((__HANDLE__)->Instance == USART2) \
Kojto 96:487b796308b0 93 { \
Kojto 96:487b796308b0 94 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 96:487b796308b0 95 { \
Kojto 96:487b796308b0 96 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 96:487b796308b0 97 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 96:487b796308b0 98 break; \
Kojto 96:487b796308b0 99 case RCC_USART2CLKSOURCE_HSI: \
Kojto 96:487b796308b0 100 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 96:487b796308b0 101 break; \
Kojto 96:487b796308b0 102 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 96:487b796308b0 103 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 96:487b796308b0 104 break; \
Kojto 96:487b796308b0 105 case RCC_USART2CLKSOURCE_LSE: \
Kojto 96:487b796308b0 106 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 96:487b796308b0 107 break; \
Kojto 96:487b796308b0 108 default: \
Kojto 96:487b796308b0 109 break; \
Kojto 96:487b796308b0 110 } \
Kojto 96:487b796308b0 111 } \
Kojto 96:487b796308b0 112 } while(0)
Kojto 96:487b796308b0 113
Kojto 96:487b796308b0 114 #else /* (STM32L031xx) || defined (STM32L041xx) */
Kojto 96:487b796308b0 115
Kojto 96:487b796308b0 116 #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
bogdanm 84:0b3ab51c8877 117 do { \
bogdanm 84:0b3ab51c8877 118 if((__HANDLE__)->Instance == USART1) \
bogdanm 84:0b3ab51c8877 119 { \
Kojto 96:487b796308b0 120 switch(__HAL_RCC_GET_USART1_SOURCE()) \
bogdanm 84:0b3ab51c8877 121 { \
bogdanm 84:0b3ab51c8877 122 case RCC_USART1CLKSOURCE_PCLK2: \
bogdanm 84:0b3ab51c8877 123 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK2; \
bogdanm 84:0b3ab51c8877 124 break; \
bogdanm 84:0b3ab51c8877 125 case RCC_USART1CLKSOURCE_HSI: \
bogdanm 84:0b3ab51c8877 126 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
bogdanm 84:0b3ab51c8877 127 break; \
bogdanm 84:0b3ab51c8877 128 case RCC_USART1CLKSOURCE_SYSCLK: \
bogdanm 84:0b3ab51c8877 129 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
bogdanm 84:0b3ab51c8877 130 break; \
bogdanm 84:0b3ab51c8877 131 case RCC_USART1CLKSOURCE_LSE: \
bogdanm 84:0b3ab51c8877 132 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
bogdanm 84:0b3ab51c8877 133 break; \
bogdanm 84:0b3ab51c8877 134 default: \
bogdanm 84:0b3ab51c8877 135 break; \
bogdanm 84:0b3ab51c8877 136 } \
bogdanm 84:0b3ab51c8877 137 } \
bogdanm 84:0b3ab51c8877 138 else if((__HANDLE__)->Instance == USART2) \
bogdanm 84:0b3ab51c8877 139 { \
bogdanm 84:0b3ab51c8877 140 switch(__HAL_RCC_GET_USART2_SOURCE()) \
bogdanm 84:0b3ab51c8877 141 { \
bogdanm 84:0b3ab51c8877 142 case RCC_USART2CLKSOURCE_PCLK1: \
bogdanm 84:0b3ab51c8877 143 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
bogdanm 84:0b3ab51c8877 144 break; \
bogdanm 84:0b3ab51c8877 145 case RCC_USART2CLKSOURCE_HSI: \
bogdanm 84:0b3ab51c8877 146 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
bogdanm 84:0b3ab51c8877 147 break; \
bogdanm 84:0b3ab51c8877 148 case RCC_USART2CLKSOURCE_SYSCLK: \
bogdanm 84:0b3ab51c8877 149 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
bogdanm 84:0b3ab51c8877 150 break; \
bogdanm 84:0b3ab51c8877 151 case RCC_USART2CLKSOURCE_LSE: \
bogdanm 84:0b3ab51c8877 152 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
bogdanm 84:0b3ab51c8877 153 break; \
bogdanm 84:0b3ab51c8877 154 default: \
bogdanm 84:0b3ab51c8877 155 break; \
bogdanm 84:0b3ab51c8877 156 } \
bogdanm 84:0b3ab51c8877 157 } \
bogdanm 84:0b3ab51c8877 158 } while(0)
Kojto 96:487b796308b0 159 #endif /* (STM32L031xx) || (STM32L041xx) */
bogdanm 84:0b3ab51c8877 160
bogdanm 84:0b3ab51c8877 161 /** @brief Reports the USART mask to apply to retrieve the received data
bogdanm 84:0b3ab51c8877 162 * according to the word length and to the parity bits activation.
bogdanm 84:0b3ab51c8877 163 * If PCE = 1, the parity bit is not included in the data extracted
bogdanm 84:0b3ab51c8877 164 * by the reception API().
bogdanm 84:0b3ab51c8877 165 * This masking operation is not carried out in the case of
bogdanm 84:0b3ab51c8877 166 * DMA transfers.
bogdanm 84:0b3ab51c8877 167 * @param __HANDLE__: specifies the USART Handle
bogdanm 84:0b3ab51c8877 168 * @retval mask to apply to USART RDR register value.
bogdanm 84:0b3ab51c8877 169 */
Kojto 96:487b796308b0 170 #define USART_MASK_COMPUTATION(__HANDLE__) \
bogdanm 84:0b3ab51c8877 171 do { \
bogdanm 84:0b3ab51c8877 172 if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \
bogdanm 84:0b3ab51c8877 173 { \
bogdanm 84:0b3ab51c8877 174 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
bogdanm 84:0b3ab51c8877 175 { \
bogdanm 84:0b3ab51c8877 176 (__HANDLE__)->Mask = 0x01FF ; \
bogdanm 84:0b3ab51c8877 177 } \
bogdanm 84:0b3ab51c8877 178 else \
bogdanm 84:0b3ab51c8877 179 { \
bogdanm 84:0b3ab51c8877 180 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 84:0b3ab51c8877 181 } \
bogdanm 84:0b3ab51c8877 182 } \
bogdanm 84:0b3ab51c8877 183 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \
bogdanm 84:0b3ab51c8877 184 { \
bogdanm 84:0b3ab51c8877 185 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
bogdanm 84:0b3ab51c8877 186 { \
bogdanm 84:0b3ab51c8877 187 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 84:0b3ab51c8877 188 } \
bogdanm 84:0b3ab51c8877 189 else \
bogdanm 84:0b3ab51c8877 190 { \
bogdanm 84:0b3ab51c8877 191 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 84:0b3ab51c8877 192 } \
bogdanm 84:0b3ab51c8877 193 } \
bogdanm 84:0b3ab51c8877 194 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_7B) \
bogdanm 84:0b3ab51c8877 195 { \
bogdanm 84:0b3ab51c8877 196 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
bogdanm 84:0b3ab51c8877 197 { \
bogdanm 84:0b3ab51c8877 198 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 84:0b3ab51c8877 199 } \
bogdanm 84:0b3ab51c8877 200 else \
bogdanm 84:0b3ab51c8877 201 { \
bogdanm 84:0b3ab51c8877 202 (__HANDLE__)->Mask = 0x003F ; \
bogdanm 84:0b3ab51c8877 203 } \
bogdanm 84:0b3ab51c8877 204 } \
bogdanm 84:0b3ab51c8877 205 } while(0)
bogdanm 84:0b3ab51c8877 206
bogdanm 84:0b3ab51c8877 207 /**
bogdanm 84:0b3ab51c8877 208 * @}
bogdanm 84:0b3ab51c8877 209 */
bogdanm 84:0b3ab51c8877 210
bogdanm 84:0b3ab51c8877 211 /* Exported functions --------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 212 /* Initialization/de-initialization methods **********************************/
bogdanm 84:0b3ab51c8877 213 /* IO operation methods *******************************************************/
bogdanm 84:0b3ab51c8877 214 /* Peripheral Control methods ************************************************/
bogdanm 84:0b3ab51c8877 215 /* Peripheral State methods **************************************************/
bogdanm 84:0b3ab51c8877 216
bogdanm 84:0b3ab51c8877 217
bogdanm 84:0b3ab51c8877 218 /**
bogdanm 84:0b3ab51c8877 219 * @}
bogdanm 84:0b3ab51c8877 220 */
bogdanm 84:0b3ab51c8877 221
bogdanm 84:0b3ab51c8877 222 /**
bogdanm 84:0b3ab51c8877 223 * @}
bogdanm 84:0b3ab51c8877 224 */
bogdanm 84:0b3ab51c8877 225
bogdanm 84:0b3ab51c8877 226 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 227 }
bogdanm 84:0b3ab51c8877 228 #endif
bogdanm 84:0b3ab51c8877 229
bogdanm 84:0b3ab51c8877 230 #endif /* __STM32L0xx_HAL_USART_EX_H */
bogdanm 84:0b3ab51c8877 231
bogdanm 84:0b3ab51c8877 232 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 96:487b796308b0 233