]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3/stm32f3xx_hal_usart.h
Add a qwerty layer
[max/tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3 / stm32f3xx_hal_usart.h
1 /**
2   ******************************************************************************
3   * @file    stm32f3xx_hal_usart.h
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    12-Sept-2014
7   * @brief   Header file of USART HAL module.
8   ******************************************************************************
9   * @attention
10   *
11   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
12   *
13   * Redistribution and use in source and binary forms, with or without modification,
14   * are permitted provided that the following conditions are met:
15   *   1. Redistributions of source code must retain the above copyright notice,
16   *      this list of conditions and the following disclaimer.
17   *   2. Redistributions in binary form must reproduce the above copyright notice,
18   *      this list of conditions and the following disclaimer in the documentation
19   *      and/or other materials provided with the distribution.
20   *   3. Neither the name of STMicroelectronics nor the names of its contributors
21   *      may be used to endorse or promote products derived from this software
22   *      without specific prior written permission.
23   *
24   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34   *
35   ******************************************************************************  
36   */
37
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F3xx_HAL_USART_H
40 #define __STM32F3xx_HAL_USART_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f3xx_hal_def.h"
48
49 /** @addtogroup STM32F3xx_HAL_Driver
50   * @{
51   */
52
53 /** @addtogroup USART
54   * @{
55   */ 
56
57 /* Exported types ------------------------------------------------------------*/ 
58 /** @defgroup USART_Exported_Types USART Exported Types
59   * @{
60   */
61
62 /** 
63   * @brief USART Init Structure definition  
64   */ 
65 typedef struct
66 {
67   uint32_t BaudRate;                  /*!< This member configures the Usart communication baud rate.
68                                            The baud rate is computed using the following formula:
69                                               Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))) */
70
71   uint32_t WordLength;                /*!< Specifies the number of data bits transmitted or received in a frame.
72                                            This parameter can be a value of @ref USARTEx_Word_Length */
73
74   uint32_t StopBits;                  /*!< Specifies the number of stop bits transmitted.
75                                            This parameter can be a value of @ref USART_Stop_Bits */
76
77   uint32_t Parity;                   /*!< Specifies the parity mode.
78                                            This parameter can be a value of @ref USART_Parity
79                                            @note When parity is enabled, the computed parity is inserted
80                                                  at the MSB position of the transmitted data (9th bit when
81                                                  the word length is set to 9 data bits; 8th bit when the
82                                                  word length is set to 8 data bits). */
83  
84   uint32_t Mode;                      /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
85                                            This parameter can be a value of @ref USART_Mode */
86                                            
87   uint32_t CLKPolarity;               /*!< Specifies the steady state of the serial clock.
88                                            This parameter can be a value of @ref USART_Clock_Polarity */
89
90   uint32_t CLKPhase;                  /*!< Specifies the clock transition on which the bit capture is made.
91                                            This parameter can be a value of @ref USART_Clock_Phase */
92
93   uint32_t CLKLastBit;                /*!< Specifies whether the clock pulse corresponding to the last transmitted
94                                            data bit (MSB) has to be output on the SCLK pin in synchronous mode.
95                                            This parameter can be a value of @ref USART_Last_Bit */
96 }USART_InitTypeDef;
97
98 /** 
99   * @brief HAL State structures definition  
100   */ 
101 typedef enum
102 {
103   HAL_USART_STATE_RESET             = 0x00,    /*!< Peripheral is not initialized   */
104   HAL_USART_STATE_READY             = 0x01,    /*!< Peripheral Initialized and ready for use */
105   HAL_USART_STATE_BUSY              = 0x02,    /*!< an internal process is ongoing */   
106   HAL_USART_STATE_BUSY_TX           = 0x12,    /*!< Data Transmission process is ongoing */ 
107   HAL_USART_STATE_BUSY_RX           = 0x22,    /*!< Data Reception process is ongoing */
108   HAL_USART_STATE_BUSY_TX_RX        = 0x32,    /*!< Data Transmission Reception process is ongoing */
109   HAL_USART_STATE_TIMEOUT           = 0x03,    /*!< Timeout state */
110   HAL_USART_STATE_ERROR             = 0x04     /*!< Error */      
111 }HAL_USART_StateTypeDef;
112
113 /** 
114   * @brief  HAL USART Error Code structure definition  
115   */ 
116 typedef enum
117 {
118   HAL_USART_ERROR_NONE      = 0x00,    /*!< No error            */
119   HAL_USART_ERROR_PE        = 0x01,    /*!< Parity error        */
120   HAL_USART_ERROR_NE        = 0x02,    /*!< Noise error         */
121   HAL_USART_ERROR_FE        = 0x04,    /*!< frame error         */
122   HAL_USART_ERROR_ORE       = 0x08,    /*!< Overrun error       */
123   HAL_USART_ERROR_DMA       = 0x10     /*!< DMA transfer error  */
124 }HAL_USART_ErrorTypeDef;
125
126 /** 
127   * @brief  USART clock sources definitions
128   */
129 typedef enum
130 {
131   USART_CLOCKSOURCE_PCLK1      = 0x00,    /*!< PCLK1 clock source     */
132   USART_CLOCKSOURCE_PCLK2      = 0x01,    /*!< PCLK2 clock source     */
133   USART_CLOCKSOURCE_HSI        = 0x02,    /*!< HSI clock source       */
134   USART_CLOCKSOURCE_SYSCLK     = 0x04,    /*!< SYSCLK clock source    */
135   USART_CLOCKSOURCE_LSE        = 0x08,    /*!< LSE clock source       */
136   USART_CLOCKSOURCE_UNDEFINED  = 0x10     /*!< Undefined clock source */
137 }USART_ClockSourceTypeDef;
138
139
140 /** 
141   * @brief  USART handle Structure definition  
142   */  
143 typedef struct
144 {
145   USART_TypeDef                 *Instance;        /*!< USART registers base address        */
146   
147   USART_InitTypeDef             Init;             /*!< USART communication parameters      */
148   
149   uint8_t                       *pTxBuffPtr;      /*!< Pointer to USART Tx transfer Buffer */
150   
151   uint16_t                      TxXferSize;       /*!< USART Tx Transfer size              */
152   
153   uint16_t                      TxXferCount;      /*!< USART Tx Transfer Counter           */
154   
155   uint8_t                       *pRxBuffPtr;      /*!< Pointer to USART Rx transfer Buffer */
156   
157   uint16_t                      RxXferSize;       /*!< USART Rx Transfer size              */
158   
159   uint16_t                      RxXferCount;      /*!< USART Rx Transfer Counter           */
160   
161   uint16_t                      Mask;             /*!< USART Rx RDR register mask          */
162   
163   DMA_HandleTypeDef             *hdmatx;          /*!< USART Tx DMA Handle parameters      */
164     
165   DMA_HandleTypeDef             *hdmarx;          /*!< USART Rx DMA Handle parameters      */
166   
167   HAL_LockTypeDef                Lock;            /*!< Locking object                      */
168   
169   HAL_USART_StateTypeDef         State;           /*!< USART communication state           */
170   
171   HAL_USART_ErrorTypeDef         ErrorCode;       /*!< USART Error code                    */
172   
173 }USART_HandleTypeDef;
174
175 /**
176   * @}
177   */
178
179 /* Exported constants --------------------------------------------------------*/
180
181 /** @defgroup USART_Exported_Constants USART Exported Constants
182   * @{
183   */
184
185 /** @defgroup USART_Stop_Bits  USART Number of Stop Bits
186   * @{
187   */
188 #define USART_STOPBITS_1                     ((uint32_t)0x0000)
189 #define USART_STOPBITS_0_5                   ((uint32_t)USART_CR2_STOP_0)
190 #define USART_STOPBITS_2                     ((uint32_t)USART_CR2_STOP_1)
191 #define USART_STOPBITS_1_5                   ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
192 #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_STOPBITS_1) || \
193                                          ((STOPBITS) == USART_STOPBITS_0_5) || \
194                                          ((STOPBITS) == USART_STOPBITS_1_5) || \
195                                          ((STOPBITS) == USART_STOPBITS_2))
196 /**
197   * @}
198   */ 
199
200 /** @defgroup USART_Parity    USART Parity
201   * @{
202   */ 
203 #define USART_PARITY_NONE                    ((uint32_t)0x0000)
204 #define USART_PARITY_EVEN                    ((uint32_t)USART_CR1_PCE)
205 #define USART_PARITY_ODD                     ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) 
206 #define IS_USART_PARITY(PARITY) (((PARITY) == USART_PARITY_NONE) || \
207                                      ((PARITY) == USART_PARITY_EVEN) || \
208                                      ((PARITY) == USART_PARITY_ODD))
209 /**
210   * @}
211   */ 
212
213 /** @defgroup USART_Mode   USART Mode
214   * @{
215   */ 
216 #define USART_MODE_RX                        ((uint32_t)USART_CR1_RE)
217 #define USART_MODE_TX                        ((uint32_t)USART_CR1_TE)
218 #define USART_MODE_TX_RX                     ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
219 #define IS_USART_MODE(MODE) ((((MODE) & (uint32_t)0xFFFFFFF3) == 0x00) && ((MODE) != (uint32_t)0x00))
220 /**
221   * @}
222   */
223     
224 /** @defgroup USART_Clock  USART Clock
225   * @{
226   */ 
227 #define USART_CLOCK_DISABLED                 ((uint32_t)0x0000)
228 #define USART_CLOCK_ENABLED                  ((uint32_t)USART_CR2_CLKEN)
229 #define IS_USART_CLOCK(CLOCK)      (((CLOCK) == USART_CLOCK_DISABLED) || \
230                                    ((CLOCK) == USART_CLOCK_ENABLED))
231 /**
232   * @}
233   */ 
234
235 /** @defgroup USART_Clock_Polarity  USART Clock Polarity
236   * @{
237   */
238 #define USART_POLARITY_LOW                   ((uint32_t)0x0000)
239 #define USART_POLARITY_HIGH                  ((uint32_t)USART_CR2_CPOL)
240 #define IS_USART_POLARITY(CPOL) (((CPOL) == USART_POLARITY_LOW) || ((CPOL) == USART_POLARITY_HIGH))
241 /**
242   * @}
243   */ 
244
245 /** @defgroup USART_Clock_Phase   USART Clock Phase
246   * @{
247   */
248 #define USART_PHASE_1EDGE                    ((uint32_t)0x0000)
249 #define USART_PHASE_2EDGE                    ((uint32_t)USART_CR2_CPHA)
250 #define IS_USART_PHASE(CPHA) (((CPHA) == USART_PHASE_1EDGE) || ((CPHA) == USART_PHASE_2EDGE))
251 /**
252   * @}
253   */
254
255 /** @defgroup USART_Last_Bit  USART Last Bit
256   * @{
257   */
258 #define USART_LASTBIT_DISABLE                ((uint32_t)0x0000)
259 #define USART_LASTBIT_ENABLE                 ((uint32_t)USART_CR2_LBCL)
260 #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LASTBIT_DISABLE) || \
261                                        ((LASTBIT) == USART_LASTBIT_ENABLE))
262 /**
263   * @}
264   */
265
266
267 /** @defgroup USART_Flags      USART Flags
268   *        Elements values convention: 0xXXXX
269   *           - 0xXXXX  : Flag mask in the ISR register
270   * @{
271   */
272 #define USART_FLAG_REACK                     ((uint32_t)0x00400000)
273 #define USART_FLAG_TEACK                     ((uint32_t)0x00200000)  
274 #define USART_FLAG_BUSY                      ((uint32_t)0x00010000)
275 #define USART_FLAG_CTS                       ((uint32_t)0x00000400)
276 #define USART_FLAG_CTSIF                     ((uint32_t)0x00000200)
277 #define USART_FLAG_LBDF                      ((uint32_t)0x00000100)
278 #define USART_FLAG_TXE                       ((uint32_t)0x00000080)
279 #define USART_FLAG_TC                        ((uint32_t)0x00000040)
280 #define USART_FLAG_RXNE                      ((uint32_t)0x00000020)
281 #define USART_FLAG_IDLE                      ((uint32_t)0x00000010)
282 #define USART_FLAG_ORE                       ((uint32_t)0x00000008)
283 #define USART_FLAG_NE                        ((uint32_t)0x00000004)
284 #define USART_FLAG_FE                        ((uint32_t)0x00000002)
285 #define USART_FLAG_PE                        ((uint32_t)0x00000001)
286 /**
287   * @}
288   */
289
290 /** @defgroup USART_Interrupt_definition USART Interrupts Definition
291   *        Elements values convention: 0000ZZZZ0XXYYYYYb
292   *           - YYYYY  : Interrupt source position in the XX register (5bits)
293   *           - XX  : Interrupt source register (2bits)
294   *                 - 01: CR1 register
295   *                 - 10: CR2 register
296   *                 - 11: CR3 register
297   *           - ZZZZ  : Flag position in the ISR register(4bits)
298   * @{
299   */
300   
301 #define USART_IT_PE                          ((uint16_t)0x0028)
302 #define USART_IT_TXE                         ((uint16_t)0x0727)
303 #define USART_IT_TC                          ((uint16_t)0x0626)
304 #define USART_IT_RXNE                        ((uint16_t)0x0525)
305 #define USART_IT_IDLE                        ((uint16_t)0x0424)
306 #define USART_IT_ERR                         ((uint16_t)0x0060)
307
308 #define USART_IT_ORE                         ((uint16_t)0x0300)
309 #define USART_IT_NE                          ((uint16_t)0x0200)
310 #define USART_IT_FE                          ((uint16_t)0x0100)
311 /**
312   * @}
313   */
314
315 /** @defgroup USART_IT_CLEAR_Flags    USART Interruption Clear Flags
316   * @{
317   */
318 #define USART_CLEAR_PEF                       USART_ICR_PECF            /*!< Parity Error Clear Flag */          
319 #define USART_CLEAR_FEF                       USART_ICR_FECF            /*!< Framing Error Clear Flag */         
320 #define USART_CLEAR_NEF                       USART_ICR_NCF             /*!< Noise detected Clear Flag */        
321 #define USART_CLEAR_OREF                      USART_ICR_ORECF           /*!< OverRun Error Clear Flag */         
322 #define USART_CLEAR_IDLEF                     USART_ICR_IDLECF          /*!< IDLE line detected Clear Flag */    
323 #define USART_CLEAR_TCF                       USART_ICR_TCCF            /*!< Transmission Complete Clear Flag */ 
324 #define USART_CLEAR_CTSF                      USART_ICR_CTSCF           /*!< CTS Interrupt Clear Flag */         
325 /**
326   * @}
327   */ 
328
329 /** @defgroup USART_Request_Parameters  USART Request Parameters
330   * @{
331   */
332 #define USART_RXDATA_FLUSH_REQUEST        ((uint32_t)USART_RQR_RXFRQ)        /*!< Receive Data flush Request */ 
333 #define USART_TXDATA_FLUSH_REQUEST        ((uint32_t)USART_RQR_TXFRQ)        /*!< Transmit data flush Request */
334 #define IS_USART_REQUEST_PARAMETER(PARAM) (((PARAM) == USART_RXDATA_FLUSH_REQUEST) || \
335                                            ((PARAM) == USART_TXDATA_FLUSH_REQUEST))   
336 /**
337   * @}
338   */
339
340 /** @defgroup USART_Interruption_Mask    USART interruptions flag mask
341   * @{
342   */  
343 #define USART_IT_MASK                             ((uint16_t)0x001F)  
344 /**
345   * @}
346   */
347
348 /**
349   * @}
350   */
351   
352     
353 /* Exported macros ------------------------------------------------------------*/
354
355 /** @defgroup USART_Exported_Macros USART Exported Macros
356   * @{
357   */  
358   
359 /** @brief  Reset USART handle state
360   * @param  __HANDLE__: USART handle.
361   * @retval None
362   */
363 #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
364
365
366 /** @brief  Checks whether the specified USART flag is set or not.
367   * @param  __HANDLE__: specifies the USART Handle
368   * @param  __FLAG__: specifies the flag to check.
369   *        This parameter can be one of the following values:
370   *            @arg USART_FLAG_REACK: Receive enable ackowledge flag
371   *            @arg USART_FLAG_TEACK: Transmit enable ackowledge flag
372   *            @arg USART_FLAG_BUSY:  Busy flag                  
373   *            @arg USART_FLAG_CTS:   CTS Change flag         
374   *            @arg USART_FLAG_TXE:   Transmit data register empty flag
375   *            @arg USART_FLAG_TC:    Transmission Complete flag
376   *            @arg USART_FLAG_RXNE:  Receive data register not empty flag
377   *            @arg USART_FLAG_IDLE:  Idle Line detection flag
378   *            @arg USART_FLAG_ORE:   OverRun Error flag
379   *            @arg USART_FLAG_NE:    Noise Error flag
380   *            @arg USART_FLAG_FE:    Framing Error flag
381   *            @arg USART_FLAG_PE:    Parity Error flag
382   * @retval The new state of __FLAG__ (TRUE or FALSE).
383   */
384 #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
385
386
387 /** @brief  Enables the specified USART interrupt.
388   * @param  __HANDLE__: specifies the USART Handle
389   * @param  __INTERRUPT__: specifies the USART interrupt source to enable.
390   *          This parameter can be one of the following values:
391   *            @arg USART_IT_TXE:  Transmit Data Register empty interrupt
392   *            @arg USART_IT_TC:   Transmission complete interrupt
393   *            @arg USART_IT_RXNE: Receive Data register not empty interrupt
394   *            @arg USART_IT_IDLE: Idle line detection interrupt
395   *            @arg USART_IT_PE:   Parity Error interrupt
396   *            @arg USART_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
397   * @retval None
398   */
399 #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__)   (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
400                                                             ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
401                                                             ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))))
402
403 /** @brief  Disables the specified USART interrupt.
404   * @param  __HANDLE__: specifies the USART Handle.
405   * @param  __INTERRUPT__: specifies the USART interrupt source to disable.
406   *          This parameter can be one of the following values:
407   *            @arg USART_IT_TXE:  Transmit Data Register empty interrupt
408   *            @arg USART_IT_TC:   Transmission complete interrupt
409   *            @arg USART_IT_RXNE: Receive Data register not empty interrupt
410   *            @arg USART_IT_IDLE: Idle line detection interrupt
411   *            @arg USART_IT_PE:   Parity Error interrupt
412   *            @arg USART_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
413   * @retval None
414   */
415 #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__)  (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
416                                                             ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
417                                                             ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))))
418
419     
420 /** @brief  Checks whether the specified USART interrupt has occurred or not.
421   * @param  __HANDLE__: specifies the USART Handle
422   * @param  __IT__: specifies the USART interrupt source to check.
423   *          This parameter can be one of the following values:
424   *            @arg USART_IT_TXE: Transmit Data Register empty interrupt
425   *            @arg USART_IT_TC:  Transmission complete interrupt
426   *            @arg USART_IT_RXNE: Receive Data register not empty interrupt
427   *            @arg USART_IT_IDLE: Idle line detection interrupt
428   *            @arg USART_IT_ORE: OverRun Error interrupt
429   *            @arg USART_IT_NE: Noise Error interrupt
430   *            @arg USART_IT_FE: Framing Error interrupt
431   *            @arg USART_IT_PE: Parity Error interrupt
432   * @retval The new state of __IT__ (TRUE or FALSE).
433   */
434 #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08))) 
435
436 /** @brief  Checks whether the specified USART interrupt source is enabled.
437   * @param  __HANDLE__: specifies the USART Handle.
438   * @param  __IT__: specifies the USART interrupt source to check.
439   *          This parameter can be one of the following values:
440   *            @arg USART_IT_TXE: Transmit Data Register empty interrupt
441   *            @arg USART_IT_TC:  Transmission complete interrupt
442   *            @arg USART_IT_RXNE: Receive Data register not empty interrupt
443   *            @arg USART_IT_IDLE: Idle line detection interrupt
444   *            @arg USART_IT_ORE: OverRun Error interrupt
445   *            @arg USART_IT_NE: Noise Error interrupt
446   *            @arg USART_IT_FE: Framing Error interrupt
447   *            @arg USART_IT_PE: Parity Error interrupt
448   * @retval The new state of __IT__ (TRUE or FALSE).
449   */
450 #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \
451                                                    (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \
452                                                    (((uint16_t)(__IT__)) & USART_IT_MASK)))
453
454
455 /** @brief  Clears the specified USART ISR flag, in setting the proper ICR register flag.
456   * @param  __HANDLE__: specifies the USART Handle.
457   * @param  __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
458   *                       to clear the corresponding interrupt
459   *          This parameter can be one of the following values:
460   *            @arg USART_CLEAR_PEF: Parity Error Clear Flag          
461   *            @arg USART_CLEAR_FEF: Framing Error Clear Flag         
462   *            @arg USART_CLEAR_NEF: Noise detected Clear Flag        
463   *            @arg USART_CLEAR_OREF: OverRun Error Clear Flag         
464   *            @arg USART_CLEAR_IDLEF: IDLE line detected Clear Flag    
465   *            @arg USART_CLEAR_TCF: Transmission Complete Clear Flag 
466   *            @arg USART_CLEAR_CTSF: CTS Interrupt Clear Flag      
467   * @retval None
468   */
469 #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) 
470
471 /** @brief  Set a specific USART request flag.
472   * @param  __HANDLE__: specifies the USART Handle.
473   * @param  __REQ__: specifies the request flag to set
474   *          This parameter can be one of the following values:
475   *            @arg USART_RXDATA_FLUSH_REQUEST: Receive Data flush Request 
476   *            @arg USART_TXDATA_FLUSH_REQUEST: Transmit data flush Request 
477   *
478   * @retval None
479   */ 
480 #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__)) 
481
482 /** @brief  Enable USART
483   * @param  __HANDLE__: specifies the USART Handle.
484   * @retval None
485   */ 
486 #define __HAL_USART_ENABLE(__HANDLE__)               ((__HANDLE__)->Instance->CR1 |=  USART_CR1_UE)
487
488 /** @brief  Disable USART
489   * @param  __HANDLE__: specifies the USART Handle.
490   * @retval None
491   */ 
492 #define __HAL_USART_DISABLE(__HANDLE__)              ((__HANDLE__)->Instance->CR1 &=  ~USART_CR1_UE)
493   
494
495 /** @brief  Check USART Baud rate
496   * @param  BAUDRATE: Baudrate specified by the user
497   *         The maximum Baud Rate is derived from the maximum clock on F3 (i.e. 72 MHz) 
498   *         divided by the smallest oversampling used on the USART (i.e. 8)  
499   * @retval Test result (TRUE or FALSE) 
500   */ 
501 #define IS_USART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 9000001)
502
503 /**
504   * @}
505   */
506  
507 /* Include USART HAL Extended module */
508 #include "stm32f3xx_hal_usart_ex.h"        
509                                  
510 /* Exported functions --------------------------------------------------------*/
511 /** @addtogroup USART_Exported_Functions USART Exported Functions
512   * @{
513   */
514
515 /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions
516   *  @brief    Initialization and Configuration functions 
517   * @{
518   */
519 /* Initialization and de-initialization functions  ****************************/
520 HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart);
521 HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart);
522 void HAL_USART_MspInit(USART_HandleTypeDef *husart);
523 void HAL_USART_MspDeInit(USART_HandleTypeDef *husart);
524 HAL_StatusTypeDef HAL_USART_CheckIdleState(USART_HandleTypeDef *husart);
525 /**
526   * @}
527   */
528
529 /** @defgroup USART_Exported_Functions_Group2 Input and Output operation functions 
530   *  @brief   USART Transmit/Receive functions 
531   * @{
532   */
533 /* IO operation functions *****************************************************/
534 HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
535 HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
536 HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
537 HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
538 HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
539 HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData,  uint16_t Size);
540 HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
541 HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
542 HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
543 HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
544 HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
545 HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
546 void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
547 void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
548 void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
549 void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
550 void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
551 void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
552 void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
553 /**
554   * @}
555   */
556
557 /** @defgroup USART_Exported_Functions_Group3 Peripheral Control functions 
558   *  @brief   USART control functions 
559   * @{
560   */
561 /* Peripheral Control functions ***********************************************/
562
563 /* Peripheral State and Error functions ***************************************/
564 HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart);
565 uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart);
566 /**
567   * @}
568   */
569   
570 /**
571   * @}
572   */
573
574 /**
575   * @}
576   */ 
577
578 /**
579   * @}
580   */
581   
582 #ifdef __cplusplus
583 }
584 #endif
585
586 #endif /* __STM32F3xx_HAL_USART_H */
587
588 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/