annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Inc/stm32f4xx_hal_usart.h @ 81:da9444f53f46 kittz

Created new branch kittz
author Dmitry Romanov <kitt@bk.ru>
date Tue, 20 Nov 2018 09:25:17 +0000
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file stm32f4xx_hal_usart.h
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author MCD Application Team
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 26-December-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief Header file of USART HAL module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 /* Define to prevent recursive inclusion -------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #ifndef __STM32F4xx_HAL_USART_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 #define __STM32F4xx_HAL_USART_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 #ifdef __cplusplus
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 extern "C" {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 #include "stm32f4xx_hal_def.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 /** @addtogroup USART
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 /* Exported types ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 /** @defgroup USART_Exported_Types USART Exported Types
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 * @brief USART Init Structure definition
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 typedef struct
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 uint32_t BaudRate; /*!< This member configures the Usart communication baud rate.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 The baud rate is computed using the following formula:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 - IntegerDivider = ((PCLKx) / (8 * (husart->Init.BaudRate)))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 This parameter can be a value of @ref USART_Word_Length */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 This parameter can be a value of @ref USART_Stop_Bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 uint32_t Parity; /*!< Specifies the parity mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 This parameter can be a value of @ref USART_Parity
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 @note When parity is enabled, the computed parity is inserted
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 at the MSB position of the transmitted data (9th bit when
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 the word length is set to 9 data bits; 8th bit when the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 word length is set to 8 data bits). */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 This parameter can be a value of @ref USART_Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 This parameter can be a value of @ref USART_Clock_Polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 This parameter can be a value of @ref USART_Clock_Phase */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 This parameter can be a value of @ref USART_Last_Bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 }USART_InitTypeDef;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 * @brief HAL State structures definition
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 typedef enum
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 HAL_USART_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 HAL_USART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 HAL_USART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 HAL_USART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 HAL_USART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 HAL_USART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission Reception process is ongoing */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 HAL_USART_STATE_TIMEOUT = 0x03, /*!< Timeout state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 HAL_USART_STATE_ERROR = 0x04 /*!< Error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 }HAL_USART_StateTypeDef;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 * @brief USART handle Structure definition
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 typedef struct
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 USART_TypeDef *Instance; /* USART registers base address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 USART_InitTypeDef Init; /* Usart communication parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 uint8_t *pTxBuffPtr; /* Pointer to Usart Tx transfer Buffer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 uint16_t TxXferSize; /* Usart Tx Transfer size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 __IO uint16_t TxXferCount; /* Usart Tx Transfer Counter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 uint8_t *pRxBuffPtr; /* Pointer to Usart Rx transfer Buffer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 uint16_t RxXferSize; /* Usart Rx Transfer size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 __IO uint16_t RxXferCount; /* Usart Rx Transfer Counter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 DMA_HandleTypeDef *hdmatx; /* Usart Tx DMA Handle parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 DMA_HandleTypeDef *hdmarx; /* Usart Rx DMA Handle parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 HAL_LockTypeDef Lock; /* Locking object */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 __IO HAL_USART_StateTypeDef State; /* Usart communication state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 __IO uint32_t ErrorCode; /* USART Error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 }USART_HandleTypeDef;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 /* Exported constants --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 /** @defgroup USART_Exported_Constants USART Exported Constants
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 /** @defgroup USART_Error_Code USART Error Code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 * @brief USART Error Code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 #define HAL_USART_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 #define HAL_USART_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 #define HAL_USART_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 #define HAL_USART_ERROR_FE ((uint32_t)0x00000004) /*!< Frame error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 #define HAL_USART_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 #define HAL_USART_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 /** @defgroup USART_Word_Length USART Word Length
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 #define USART_WORDLENGTH_8B ((uint32_t)0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 /** @defgroup USART_Stop_Bits USART Number of Stop Bits
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 #define USART_STOPBITS_1 ((uint32_t)0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 #define USART_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 /** @defgroup USART_Parity USART Parity
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 #define USART_PARITY_NONE ((uint32_t)0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 #define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 #define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 /** @defgroup USART_Mode USART Mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 #define USART_MODE_RX ((uint32_t)USART_CR1_RE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 #define USART_MODE_TX ((uint32_t)USART_CR1_TE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 #define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 /** @defgroup USART_Clock USART Clock
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 #define USART_CLOCK_DISABLE ((uint32_t)0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 #define USART_CLOCK_ENABLE ((uint32_t)USART_CR2_CLKEN)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 /** @defgroup USART_Clock_Polarity USART Clock Polarity
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 #define USART_POLARITY_LOW ((uint32_t)0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 /** @defgroup USART_Clock_Phase USART Clock Phase
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 #define USART_PHASE_1EDGE ((uint32_t)0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 #define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 /** @defgroup USART_Last_Bit USART Last Bit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 #define USART_LASTBIT_DISABLE ((uint32_t)0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 #define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 /** @defgroup USART_NACK_State USART NACK State
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 #define USART_NACK_ENABLE ((uint32_t)USART_CR3_NACK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 #define USART_NACK_DISABLE ((uint32_t)0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 /** @defgroup USART_Flags USART Flags
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 * Elements values convention: 0xXXXX
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 * - 0xXXXX : Flag mask in the SR register
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 #define USART_FLAG_TXE ((uint32_t)0x00000080)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 #define USART_FLAG_TC ((uint32_t)0x00000040)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 #define USART_FLAG_RXNE ((uint32_t)0x00000020)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 #define USART_FLAG_IDLE ((uint32_t)0x00000010)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 #define USART_FLAG_ORE ((uint32_t)0x00000008)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 #define USART_FLAG_NE ((uint32_t)0x00000004)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 #define USART_FLAG_FE ((uint32_t)0x00000002)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 #define USART_FLAG_PE ((uint32_t)0x00000001)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 /** @defgroup USART_Interrupt_definition USART Interrupts Definition
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 * Elements values convention: 0xY000XXXX
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 * - XXXX : Interrupt mask in the XX register
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 * - Y : Interrupt source register (2bits)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 * - 01: CR1 register
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 * - 10: CR2 register
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 * - 11: CR3 register
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 #define USART_IT_PE ((uint32_t)(USART_CR1_REG_INDEX << 28 | USART_CR1_PEIE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 #define USART_IT_TXE ((uint32_t)(USART_CR1_REG_INDEX << 28 | USART_CR1_TXEIE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 #define USART_IT_TC ((uint32_t)(USART_CR1_REG_INDEX << 28 | USART_CR1_TCIE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 #define USART_IT_RXNE ((uint32_t)(USART_CR1_REG_INDEX << 28 | USART_CR1_RXNEIE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 #define USART_IT_IDLE ((uint32_t)(USART_CR1_REG_INDEX << 28 | USART_CR1_IDLEIE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 #define USART_IT_LBD ((uint32_t)(USART_CR2_REG_INDEX << 28 | USART_CR2_LBDIE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 #define USART_IT_CTS ((uint32_t)(USART_CR3_REG_INDEX << 28 | USART_CR3_CTSIE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 #define USART_IT_ERR ((uint32_t)(USART_CR3_REG_INDEX << 28 | USART_CR3_EIE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 /* Exported macro ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 /** @defgroup USART_Exported_Macros USART Exported Macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 /** @brief Reset USART handle state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 /** @brief Checks whether the specified Smartcard flag is set or not.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 * @param __FLAG__: specifies the flag to check.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 * @arg USART_FLAG_TXE: Transmit data register empty flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 * @arg USART_FLAG_TC: Transmission Complete flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 * @arg USART_FLAG_RXNE: Receive data register not empty flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 * @arg USART_FLAG_IDLE: Idle Line detection flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 * @arg USART_FLAG_ORE: Overrun Error flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 * @arg USART_FLAG_NE: Noise Error flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 * @arg USART_FLAG_FE: Framing Error flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 * @arg USART_FLAG_PE: Parity Error flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 * @retval The new state of __FLAG__ (TRUE or FALSE).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 /** @brief Clears the specified Smartcard pending flags.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 * @param __FLAG__: specifies the flag to check.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 * This parameter can be any combination of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 * @arg USART_FLAG_TC: Transmission Complete flag.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 * @arg USART_FLAG_RXNE: Receive data register not empty flag.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (Overrun
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 * error) and IDLE (Idle line detected) flags are cleared by software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 * sequence: a read operation to USART_SR register followed by a read
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 * operation to USART_DR register.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 * @note RXNE flag can be also cleared by a read to the USART_DR register.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 * @note TC flag can be also cleared by software sequence: a read operation to
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 * USART_SR register followed by a write operation to USART_DR register.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 * @note TXE flag is cleared only by a write to the USART_DR register.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 /** @brief Clear the USART PE pending flag.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 do{ \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 __IO uint32_t tmpreg; \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 tmpreg = (__HANDLE__)->Instance->SR; \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 tmpreg = (__HANDLE__)->Instance->DR; \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 UNUSED(tmpreg); \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 } while(0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 /** @brief Clear the USART FE pending flag.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 /** @brief Clear the USART NE pending flag.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 /** @brief Clear the UART ORE pending flag.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 /** @brief Clear the USART IDLE pending flag.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 /** @brief Enables or disables the specified USART interrupts.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 * @param __INTERRUPT__: specifies the USART interrupt source to check.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 * @arg USART_IT_TC: Transmission complete interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 * @arg USART_IT_IDLE: Idle line detection interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 * @arg USART_IT_PE: Parity Error interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 * This parameter can be: ENABLE or DISABLE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & USART_IT_MASK)): \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & USART_IT_MASK)): \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & USART_IT_MASK)))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & USART_IT_MASK)): \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & USART_IT_MASK)): \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & USART_IT_MASK)))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 /** @brief Checks whether the specified USART interrupt has occurred or not.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 * @param __IT__: specifies the USART interrupt source to check.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 * @arg USART_IT_TC: Transmission complete interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 * @arg USART_IT_IDLE: Idle line detection interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 * @arg USART_IT_ERR: Error interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 * @arg USART_IT_PE: Parity Error interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 * @retval The new state of __IT__ (TRUE or FALSE).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28) == 2)? \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & USART_IT_MASK))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 /** @brief Macro to enable the USART's one bit sample method
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 #define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 /** @brief Macro to disable the USART's one bit sample method
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 #define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 /** @brief Enable USART
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 * USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 #define __HAL_USART_ENABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 /** @brief Disable USART
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 * @param __HANDLE__: specifies the USART Handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 * USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 #define __HAL_USART_DISABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 /** @addtogroup USART_Exported_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 /** @addtogroup USART_Exported_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 /* Initialization/de-initialization functions **********************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 void HAL_USART_MspInit(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 void HAL_USART_MspDeInit(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 /** @addtogroup USART_Exported_Functions_Group2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 /* IO operation functions *******************************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 /** @addtogroup USART_Exported_Functions_Group3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 /* Peripheral State functions ************************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 /* Private constants ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 /** @defgroup USART_Private_Constants USART Private Constants
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 /** @brief USART interruptions flag mask
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 #define USART_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 #define USART_CR1_REG_INDEX 1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 #define USART_CR2_REG_INDEX 2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 #define USART_CR3_REG_INDEX 3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 /* Private macros ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 /** @defgroup USART_Private_Macros USART Private Macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 #define IS_USART_NACK_STATE(NACK) (((NACK) == USART_NACK_ENABLE) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 ((NACK) == USART_NACK_DISABLE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LASTBIT_DISABLE) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 ((LASTBIT) == USART_LASTBIT_ENABLE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 #define IS_USART_PHASE(CPHA) (((CPHA) == USART_PHASE_1EDGE) || ((CPHA) == USART_PHASE_2EDGE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 #define IS_USART_POLARITY(CPOL) (((CPOL) == USART_POLARITY_LOW) || ((CPOL) == USART_POLARITY_HIGH))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_CLOCK_DISABLE) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 ((CLOCK) == USART_CLOCK_ENABLE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_8B) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 ((LENGTH) == USART_WORDLENGTH_9B))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_STOPBITS_1) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 ((STOPBITS) == USART_STOPBITS_0_5) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 ((STOPBITS) == USART_STOPBITS_1_5) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 ((STOPBITS) == USART_STOPBITS_2))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 #define IS_USART_PARITY(PARITY) (((PARITY) == USART_PARITY_NONE) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 ((PARITY) == USART_PARITY_EVEN) || \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 ((PARITY) == USART_PARITY_ODD))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 #define IS_USART_MODE(MODE) ((((MODE) & (uint32_t)0xFFF3) == 0x00) && ((MODE) != (uint32_t)0x00))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 #define IS_USART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 #define USART_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_)))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 #define USART_DIVMANT(_PCLK_, _BAUD_) (USART_DIV((_PCLK_), (_BAUD_))/100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 #define USART_DIVFRAQ(_PCLK_, _BAUD_) (((USART_DIV((_PCLK_), (_BAUD_)) - (USART_DIVMANT((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 #define USART_BRR(_PCLK_, _BAUD_) ((USART_DIVMANT((_PCLK_), (_BAUD_)) << 4)|(USART_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 /** @defgroup USART_Private_Functions USART Private Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 #ifdef __cplusplus
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 #endif /* __STM32F4xx_HAL_USART_H */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/