Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /** |
2 | ****************************************************************************** |
||
3 | * @file stm32f1xx_hal_irda.h |
||
4 | * @author MCD Application Team |
||
5 | mjames | 5 | * @version V1.0.4 |
6 | * @date 29-April-2016 |
||
2 | mjames | 7 | * @brief Header file of IRDA HAL module. |
8 | ****************************************************************************** |
||
9 | * @attention |
||
10 | * |
||
5 | mjames | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
2 | mjames | 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 __STM32F1xx_HAL_IRDA_H |
||
40 | #define __STM32F1xx_HAL_IRDA_H |
||
41 | |||
42 | #ifdef __cplusplus |
||
43 | extern "C" { |
||
44 | #endif |
||
45 | |||
46 | /* Includes ------------------------------------------------------------------*/ |
||
47 | #include "stm32f1xx_hal_def.h" |
||
48 | |||
49 | /** @addtogroup STM32F1xx_HAL_Driver |
||
50 | * @{ |
||
51 | */ |
||
52 | |||
53 | /** @addtogroup IRDA |
||
54 | * @{ |
||
55 | */ |
||
56 | |||
57 | /* Exported types ------------------------------------------------------------*/ |
||
58 | /** @defgroup IRDA_Exported_Types IRDA Exported Types |
||
59 | * @{ |
||
60 | */ |
||
61 | |||
62 | /** |
||
63 | * @brief IRDA Init Structure definition |
||
64 | */ |
||
65 | typedef struct |
||
66 | { |
||
67 | uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate. |
||
68 | The baud rate is computed using the following formula: |
||
69 | - IntegerDivider = ((PCLKx) / (16 * (hirda->Init.BaudRate))) |
||
70 | - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */ |
||
71 | |||
72 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
||
73 | This parameter can be a value of @ref IRDA_Word_Length */ |
||
74 | |||
75 | |||
76 | uint32_t Parity; /*!< Specifies the parity mode. |
||
77 | This parameter can be a value of @ref IRDA_Parity |
||
78 | @note When parity is enabled, the computed parity is inserted |
||
79 | at the MSB position of the transmitted data (9th bit when |
||
80 | the word length is set to 9 data bits; 8th bit when the |
||
81 | word length is set to 8 data bits). */ |
||
82 | |||
83 | uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. |
||
84 | This parameter can be a value of @ref IRDA_Transfer_Mode */ |
||
85 | |||
86 | uint8_t Prescaler; /*!< Specifies the Prescaler value prescaler value to be programmed |
||
87 | in the IrDA low-power Baud Register, for defining pulse width on which |
||
88 | burst acceptance/rejection will be decided. This value is used as divisor |
||
89 | of system clock to achieve required pulse width. */ |
||
90 | |||
91 | uint32_t IrDAMode; /*!< Specifies the IrDA mode |
||
92 | This parameter can be a value of @ref IRDA_Low_Power */ |
||
93 | }IRDA_InitTypeDef; |
||
94 | |||
95 | /** |
||
96 | * @brief HAL IRDA State structures definition |
||
97 | */ |
||
98 | typedef enum |
||
99 | { |
||
100 | HAL_IRDA_STATE_RESET = 0x00, /*!< Peripheral is not initialized */ |
||
101 | HAL_IRDA_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
||
102 | HAL_IRDA_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
||
103 | HAL_IRDA_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
||
104 | HAL_IRDA_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
||
105 | HAL_IRDA_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ |
||
106 | HAL_IRDA_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
||
107 | HAL_IRDA_STATE_ERROR = 0x04 /*!< Error */ |
||
108 | }HAL_IRDA_StateTypeDef; |
||
109 | |||
110 | |||
111 | /** |
||
112 | * @brief IRDA handle Structure definition |
||
113 | */ |
||
114 | typedef struct |
||
115 | { |
||
116 | USART_TypeDef *Instance; /*!< USART registers base address */ |
||
117 | |||
118 | IRDA_InitTypeDef Init; /*!< IRDA communication parameters */ |
||
119 | |||
120 | uint8_t *pTxBuffPtr; /*!< Pointer to IRDA Tx transfer Buffer */ |
||
121 | |||
122 | uint16_t TxXferSize; /*!< IRDA Tx Transfer size */ |
||
123 | |||
124 | uint16_t TxXferCount; /*!< IRDA Tx Transfer Counter */ |
||
125 | |||
126 | uint8_t *pRxBuffPtr; /*!< Pointer to IRDA Rx transfer Buffer */ |
||
127 | |||
128 | uint16_t RxXferSize; /*!< IRDA Rx Transfer size */ |
||
129 | |||
130 | uint16_t RxXferCount; /*!< IRDA Rx Transfer Counter */ |
||
131 | |||
132 | DMA_HandleTypeDef *hdmatx; /*!< IRDA Tx DMA Handle parameters */ |
||
133 | |||
134 | DMA_HandleTypeDef *hdmarx; /*!< IRDA Rx DMA Handle parameters */ |
||
135 | |||
136 | HAL_LockTypeDef Lock; /*!< Locking object */ |
||
137 | |||
138 | __IO HAL_IRDA_StateTypeDef State; /*!< IRDA communication state */ |
||
139 | |||
140 | __IO uint32_t ErrorCode; /*!< IRDA Error code */ |
||
141 | |||
142 | }IRDA_HandleTypeDef; |
||
143 | |||
144 | /** |
||
145 | * @} |
||
146 | */ |
||
147 | |||
148 | /* Exported constants --------------------------------------------------------*/ |
||
149 | /** @defgroup IRDA_Exported_Constants IRDA Exported constants |
||
150 | * @{ |
||
151 | */ |
||
152 | |||
153 | /** @defgroup IRDA_Error_Codes IRDA Error Codes |
||
154 | * @{ |
||
155 | */ |
||
156 | #define HAL_IRDA_ERROR_NONE ((uint32_t)0x00) /*!< No error */ |
||
157 | #define HAL_IRDA_ERROR_PE ((uint32_t)0x01) /*!< Parity error */ |
||
158 | #define HAL_IRDA_ERROR_NE ((uint32_t)0x02) /*!< Noise error */ |
||
159 | #define HAL_IRDA_ERROR_FE ((uint32_t)0x04) /*!< frame error */ |
||
160 | #define HAL_IRDA_ERROR_ORE ((uint32_t)0x08) /*!< Overrun error */ |
||
161 | #define HAL_IRDA_ERROR_DMA ((uint32_t)0x10) /*!< DMA transfer error */ |
||
162 | |||
163 | /** |
||
164 | * @} |
||
165 | */ |
||
166 | |||
167 | |||
168 | /** @defgroup IRDA_Word_Length IRDA Word Length |
||
169 | * @{ |
||
170 | */ |
||
171 | #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000) |
||
172 | #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M) |
||
173 | /** |
||
174 | * @} |
||
175 | */ |
||
176 | |||
177 | |||
178 | /** @defgroup IRDA_Parity IRDA Parity |
||
179 | * @{ |
||
180 | */ |
||
181 | #define IRDA_PARITY_NONE ((uint32_t)0x00000000) |
||
182 | #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE) |
||
183 | #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) |
||
184 | /** |
||
185 | * @} |
||
186 | */ |
||
187 | |||
188 | |||
189 | /** @defgroup IRDA_Transfer_Mode IRDA Transfer Mode |
||
190 | * @{ |
||
191 | */ |
||
192 | #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE) |
||
193 | #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE) |
||
194 | #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) |
||
195 | /** |
||
196 | * @} |
||
197 | */ |
||
198 | |||
199 | /** @defgroup IRDA_Low_Power IRDA Low Power |
||
200 | * @{ |
||
201 | */ |
||
202 | #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP) |
||
203 | #define IRDA_POWERMODE_NORMAL ((uint32_t)0x00000000) |
||
204 | /** |
||
205 | * @} |
||
206 | */ |
||
207 | |||
208 | /** @defgroup IRDA_Flags IRDA Flags |
||
209 | * Elements values convention: 0xXXXX |
||
210 | * - 0xXXXX : Flag mask in the SR register |
||
211 | * @{ |
||
212 | */ |
||
213 | #define IRDA_FLAG_TXE ((uint32_t)USART_SR_TXE) |
||
214 | #define IRDA_FLAG_TC ((uint32_t)USART_SR_TC) |
||
215 | #define IRDA_FLAG_RXNE ((uint32_t)USART_SR_RXNE) |
||
216 | #define IRDA_FLAG_IDLE ((uint32_t)USART_SR_IDLE) |
||
217 | #define IRDA_FLAG_ORE ((uint32_t)USART_SR_ORE) |
||
218 | #define IRDA_FLAG_NE ((uint32_t)USART_SR_NE) |
||
219 | #define IRDA_FLAG_FE ((uint32_t)USART_SR_FE) |
||
220 | #define IRDA_FLAG_PE ((uint32_t)USART_SR_PE) |
||
221 | /** |
||
222 | * @} |
||
223 | */ |
||
224 | |||
225 | /** @defgroup IRDA_Interrupt_definition IRDA Interrupt Definitions |
||
226 | * Elements values convention: 0xY000XXXX |
||
227 | * - XXXX : Interrupt mask (16 bits) in the Y register |
||
228 | * - Y : Interrupt source register (4 bits) |
||
229 | * - 0001: CR1 register |
||
230 | * - 0010: CR2 register |
||
231 | * - 0011: CR3 register |
||
232 | * |
||
233 | * @{ |
||
234 | */ |
||
235 | |||
236 | #define IRDA_IT_PE ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_PEIE)) |
||
237 | #define IRDA_IT_TXE ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_TXEIE)) |
||
238 | #define IRDA_IT_TC ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_TCIE)) |
||
239 | #define IRDA_IT_RXNE ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_RXNEIE)) |
||
240 | #define IRDA_IT_IDLE ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_IDLEIE)) |
||
241 | |||
242 | #define IRDA_IT_LBD ((uint32_t)(IRDA_CR2_REG_INDEX << 28 | USART_CR2_LBDIE)) |
||
243 | |||
244 | #define IRDA_IT_CTS ((uint32_t)(IRDA_CR3_REG_INDEX << 28 | USART_CR3_CTSIE)) |
||
245 | #define IRDA_IT_ERR ((uint32_t)(IRDA_CR3_REG_INDEX << 28 | USART_CR3_EIE)) |
||
246 | |||
247 | /** |
||
248 | * @} |
||
249 | */ |
||
250 | |||
251 | /** |
||
252 | * @} |
||
253 | */ |
||
254 | |||
255 | |||
256 | /* Exported macro ------------------------------------------------------------*/ |
||
257 | /** @defgroup IRDA_Exported_Macros IRDA Exported Macros |
||
258 | * @{ |
||
259 | */ |
||
260 | |||
261 | /** @brief Reset IRDA handle state |
||
262 | * @param __HANDLE__: specifies the IRDA Handle. |
||
263 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
264 | * (USART,UART availability and x,y values depending on device). |
||
265 | * @retval None |
||
266 | */ |
||
267 | #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET) |
||
268 | |||
269 | /** @brief Flush the IRDA DR register |
||
270 | * @param __HANDLE__: specifies the USART Handle. |
||
271 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
272 | * (USART,UART availability and x,y values depending on device). |
||
273 | */ |
||
274 | #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) |
||
275 | |||
276 | /** @brief Check whether the specified IRDA flag is set or not. |
||
277 | * @param __HANDLE__: specifies the IRDA Handle. |
||
278 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
279 | * (USART,UART availability and x,y values depending on device). |
||
280 | * @param __FLAG__: specifies the flag to check. |
||
281 | * This parameter can be one of the following values: |
||
282 | * @arg IRDA_FLAG_TXE: Transmit data register empty flag |
||
283 | * @arg IRDA_FLAG_TC: Transmission Complete flag |
||
284 | * @arg IRDA_FLAG_RXNE: Receive data register not empty flag |
||
285 | * @arg IRDA_FLAG_IDLE: Idle Line detection flag |
||
286 | * @arg IRDA_FLAG_ORE: OverRun Error flag |
||
287 | * @arg IRDA_FLAG_NE: Noise Error flag |
||
288 | * @arg IRDA_FLAG_FE: Framing Error flag |
||
289 | * @arg IRDA_FLAG_PE: Parity Error flag |
||
290 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
||
291 | */ |
||
292 | #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
||
293 | |||
294 | /** @brief Clear the specified IRDA pending flag. |
||
295 | * @param __HANDLE__: specifies the IRDA Handle. |
||
296 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
297 | * (USART,UART availability and x,y values depending on device). |
||
298 | * @param __FLAG__: specifies the flag to check. |
||
299 | * This parameter can be any combination of the following values: |
||
300 | * @arg IRDA_FLAG_TC: Transmission Complete flag. |
||
301 | * @arg IRDA_FLAG_RXNE: Receive data register not empty flag. |
||
302 | * |
||
303 | * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun |
||
304 | * error) and IDLE (Idle line detected) flags are cleared by software |
||
305 | * sequence: a read operation to USART_SR register followed by a read |
||
306 | * operation to USART_DR register. |
||
307 | * @note RXNE flag can be also cleared by a read to the USART_DR register. |
||
308 | * @note TC flag can be also cleared by software sequence: a read operation to |
||
309 | * USART_SR register followed by a write operation to USART_DR register. |
||
310 | * @note TXE flag is cleared only by a write to the USART_DR register. |
||
311 | * |
||
312 | * @retval None |
||
313 | */ |
||
314 | #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) |
||
315 | |||
316 | /** @brief Clear the IRDA PE pending flag. |
||
317 | * @param __HANDLE__: specifies the IRDA Handle. |
||
318 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
319 | * (USART,UART availability and x,y values depending on device). |
||
320 | * @retval None |
||
321 | */ |
||
322 | #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) \ |
||
323 | do{ \ |
||
324 | __IO uint32_t tmpreg; \ |
||
325 | tmpreg = (__HANDLE__)->Instance->SR; \ |
||
326 | tmpreg = (__HANDLE__)->Instance->DR; \ |
||
327 | UNUSED(tmpreg); \ |
||
328 | }while(0) \ |
||
329 | |||
330 | /** @brief Clear the IRDA FE pending flag. |
||
331 | * @param __HANDLE__: specifies the IRDA Handle. |
||
332 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
333 | * (USART,UART availability and x,y values depending on device). |
||
334 | * @retval None |
||
335 | */ |
||
336 | #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) |
||
337 | |||
338 | /** @brief Clear the IRDA NE pending flag. |
||
339 | * @param __HANDLE__: specifies the IRDA Handle. |
||
340 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
341 | * (USART,UART availability and x,y values depending on device). |
||
342 | * @retval None |
||
343 | */ |
||
344 | #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) |
||
345 | |||
346 | /** @brief Clear the IRDA ORE pending flag. |
||
347 | * @param __HANDLE__: specifies the IRDA Handle. |
||
348 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
349 | * (USART,UART availability and x,y values depending on device). |
||
350 | * @retval None |
||
351 | */ |
||
352 | #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) |
||
353 | |||
354 | /** @brief Clear the IRDA IDLE pending flag. |
||
355 | * @param __HANDLE__: specifies the IRDA Handle. |
||
356 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
357 | * (USART,UART availability and x,y values depending on device). |
||
358 | * @retval None |
||
359 | */ |
||
360 | #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) |
||
361 | |||
362 | /** @brief Enable the specified IRDA interrupt. |
||
363 | * @param __HANDLE__: specifies the IRDA Handle. |
||
364 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
365 | * (USART,UART availability and x,y values depending on device). |
||
366 | * @param __INTERRUPT__: specifies the IRDA interrupt source to enable. |
||
367 | * This parameter can be one of the following values: |
||
368 | * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt |
||
369 | * @arg IRDA_IT_TC: Transmission complete interrupt |
||
370 | * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt |
||
371 | * @arg IRDA_IT_IDLE: Idle line detection interrupt |
||
372 | * @arg IRDA_IT_PE: Parity Error interrupt |
||
373 | * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
||
374 | * @retval None |
||
375 | */ |
||
376 | #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == IRDA_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ |
||
377 | (((__INTERRUPT__) >> 28) == IRDA_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ |
||
378 | ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK))) |
||
379 | |||
380 | /** @brief Disable the specified IRDA interrupt. |
||
381 | * @param __HANDLE__: specifies the IRDA Handle. |
||
382 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
383 | * (USART,UART availability and x,y values depending on device). |
||
384 | * @param __INTERRUPT__: specifies the IRDA interrupt source to disable. |
||
385 | * This parameter can be one of the following values: |
||
386 | * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt |
||
387 | * @arg IRDA_IT_TC: Transmission complete interrupt |
||
388 | * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt |
||
389 | * @arg IRDA_IT_IDLE: Idle line detection interrupt |
||
390 | * @arg IRDA_IT_PE: Parity Error interrupt |
||
391 | * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
||
392 | * @retval None |
||
393 | */ |
||
394 | #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == IRDA_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ |
||
395 | (((__INTERRUPT__) >> 28) == IRDA_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ |
||
396 | ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK))) |
||
397 | |||
398 | /** @brief Check whether the specified IRDA interrupt has occurred or not. |
||
399 | * @param __HANDLE__: specifies the IRDA Handle. |
||
400 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
401 | * (USART,UART availability and x,y values depending on device). |
||
402 | * @param __IT__: specifies the IRDA interrupt source to check. |
||
403 | * This parameter can be one of the following values: |
||
404 | * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt |
||
405 | * @arg IRDA_IT_TC: Transmission complete interrupt |
||
406 | * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt |
||
407 | * @arg IRDA_IT_IDLE: Idle line detection interrupt |
||
408 | * @arg IRDA_IT_ERR: Error interrupt |
||
409 | * @arg IRDA_IT_PE: Parity Error interrupt |
||
410 | * @retval The new state of __IT__ (TRUE or FALSE). |
||
411 | */ |
||
412 | #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == IRDA_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:((((__IT__) >> 28) == IRDA_CR2_REG_INDEX)? \ |
||
413 | (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK)) |
||
414 | |||
415 | /** @brief Enable UART/USART associated to IRDA Handle |
||
416 | * @param __HANDLE__: specifies the IRDA Handle. |
||
417 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
418 | * (USART,UART availability and x,y values depending on device). |
||
419 | * @retval None |
||
420 | */ |
||
421 | #define __HAL_IRDA_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE)) |
||
422 | |||
423 | /** @brief Disable UART/USART associated to IRDA Handle |
||
424 | * @param __HANDLE__: specifies the IRDA Handle. |
||
425 | * IRDA Handle selects the USARTx or UARTy peripheral |
||
426 | * (USART,UART availability and x,y values depending on device). |
||
427 | * @retval None |
||
428 | */ |
||
429 | #define __HAL_IRDA_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE)) |
||
430 | |||
431 | /** |
||
432 | * @} |
||
433 | */ |
||
434 | |||
435 | /* Private macros --------------------------------------------------------*/ |
||
436 | /** @defgroup IRDA_Private_Macros IRDA Private Macros |
||
437 | * @{ |
||
438 | */ |
||
439 | |||
440 | #define IRDA_CR1_REG_INDEX 1 |
||
441 | #define IRDA_CR2_REG_INDEX 2 |
||
442 | #define IRDA_CR3_REG_INDEX 3 |
||
443 | |||
444 | #define IRDA_DIV(__PCLK__, __BAUD__) (((__PCLK__)*25)/(4*(__BAUD__))) |
||
445 | #define IRDA_DIVMANT(__PCLK__, __BAUD__) (IRDA_DIV((__PCLK__), (__BAUD__))/100) |
||
446 | #define IRDA_DIVFRAQ(__PCLK__, __BAUD__) (((IRDA_DIV((__PCLK__), (__BAUD__)) - (IRDA_DIVMANT((__PCLK__), (__BAUD__)) * 100)) * 16 + 50) / 100) |
||
5 | mjames | 447 | /* UART BRR = mantissa + overflow + fraction |
448 | = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0F) */ |
||
449 | #define IRDA_BRR(_PCLK_, _BAUD_) (((IRDA_DIVMANT((_PCLK_), (_BAUD_)) << 4) + \ |
||
450 | (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0)) + \ |
||
451 | (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F)) |
||
2 | mjames | 452 | |
453 | /** Ensure that IRDA Baud rate is less or equal to maximum value |
||
454 | * __BAUDRATE__: specifies the IRDA Baudrate set by the user. |
||
455 | * The maximum Baud Rate is 115200bps |
||
456 | * Returns : True or False |
||
457 | */ |
||
458 | #define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201) |
||
459 | |||
460 | #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \ |
||
461 | ((LENGTH) == IRDA_WORDLENGTH_9B)) |
||
462 | |||
463 | #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \ |
||
464 | ((PARITY) == IRDA_PARITY_EVEN) || \ |
||
465 | ((PARITY) == IRDA_PARITY_ODD)) |
||
466 | |||
467 | #define IS_IRDA_MODE(MODE) ((((MODE) & (~((uint32_t)IRDA_MODE_TX_RX))) == 0x00) && \ |
||
468 | ((MODE) != (uint32_t)0x00000000)) |
||
469 | |||
470 | #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \ |
||
471 | ((MODE) == IRDA_POWERMODE_NORMAL)) |
||
472 | |||
473 | /** IRDA interruptions flag mask |
||
474 | * |
||
475 | */ |
||
476 | #define IRDA_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \ |
||
477 | USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE ) |
||
478 | |||
479 | /** |
||
480 | * @} |
||
481 | */ |
||
482 | |||
483 | |||
484 | /* Exported functions --------------------------------------------------------*/ |
||
485 | |||
486 | /** @addtogroup IRDA_Exported_Functions IRDA Exported Functions |
||
487 | * @{ |
||
488 | */ |
||
489 | |||
490 | /** @addtogroup IRDA_Exported_Functions_Group1 Initialization and de-initialization functions |
||
491 | * @{ |
||
492 | */ |
||
493 | |||
494 | /* Initialization and de-initialization functions ****************************/ |
||
495 | HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda); |
||
496 | HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda); |
||
497 | void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); |
||
498 | void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); |
||
499 | |||
500 | /** |
||
501 | * @} |
||
502 | */ |
||
503 | |||
504 | /** @addtogroup IRDA_Exported_Functions_Group2 IO operation functions |
||
505 | * @{ |
||
506 | */ |
||
507 | |||
508 | /* IO operation functions *****************************************************/ |
||
509 | HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
||
510 | HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
||
511 | HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); |
||
512 | HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); |
||
513 | HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); |
||
514 | HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); |
||
515 | HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda); |
||
516 | HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda); |
||
517 | HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda); |
||
518 | void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda); |
||
519 | void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); |
||
520 | void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); |
||
521 | void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda); |
||
522 | void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda); |
||
523 | void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); |
||
524 | |||
525 | /** |
||
526 | * @} |
||
527 | */ |
||
528 | |||
529 | /** @addtogroup IRDA_Exported_Functions_Group3 Peripheral State and Errors functions |
||
530 | * @{ |
||
531 | */ |
||
532 | |||
533 | /* Peripheral State and Error functions ***************************************/ |
||
534 | HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda); |
||
535 | uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda); |
||
536 | |||
537 | /** |
||
538 | * @} |
||
539 | */ |
||
540 | |||
541 | /** |
||
542 | * @} |
||
543 | */ |
||
544 | |||
545 | /** |
||
546 | * @} |
||
547 | */ |
||
548 | |||
549 | /** |
||
550 | * @} |
||
551 | */ |
||
552 | |||
553 | #ifdef __cplusplus |
||
554 | } |
||
555 | #endif |
||
556 | |||
557 | #endif /* __STM32F1xx_HAL_IRDA_H */ |
||
558 | |||
559 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |