stm32f4xx_hal_irda.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_irda.h
  4. * @author MCD Application Team
  5. * @version V1.4.3
  6. * @date 11-December-2015
  7. * @brief Header file of IRDA HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_HAL_IRDA_H
  39. #define __STM32F4xx_HAL_IRDA_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f4xx_hal_def.h"
  45. /** @addtogroup STM32F4xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup IRDA
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup IRDA_Exported_Types IRDA Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief IRDA Init Structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate.
  61. The baud rate is computed using the following formula:
  62. - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate)))
  63. - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */
  64. uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
  65. This parameter can be a value of @ref IRDA_Word_Length */
  66. uint32_t Parity; /*!< Specifies the parity mode.
  67. This parameter can be a value of @ref IRDA_Parity
  68. @note When parity is enabled, the computed parity is inserted
  69. at the MSB position of the transmitted data (9th bit when
  70. the word length is set to 9 data bits; 8th bit when the
  71. word length is set to 8 data bits). */
  72. uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
  73. This parameter can be a value of @ref IRDA_Mode */
  74. uint8_t Prescaler; /*!< Specifies the Prescaler */
  75. uint32_t IrDAMode; /*!< Specifies the IrDA mode
  76. This parameter can be a value of @ref IRDA_Low_Power */
  77. }IRDA_InitTypeDef;
  78. /**
  79. * @brief HAL State structures definition
  80. */
  81. typedef enum
  82. {
  83. HAL_IRDA_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */
  84. HAL_IRDA_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
  85. HAL_IRDA_STATE_BUSY = 0x02, /*!< An internal process is ongoing */
  86. HAL_IRDA_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
  87. HAL_IRDA_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
  88. HAL_IRDA_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
  89. HAL_IRDA_STATE_TIMEOUT = 0x03, /*!< Timeout state */
  90. HAL_IRDA_STATE_ERROR = 0x04 /*!< Error */
  91. }HAL_IRDA_StateTypeDef;
  92. /**
  93. * @brief IRDA handle Structure definition
  94. */
  95. typedef struct
  96. {
  97. USART_TypeDef *Instance; /* USART registers base address */
  98. IRDA_InitTypeDef Init; /* IRDA communication parameters */
  99. uint8_t *pTxBuffPtr; /* Pointer to IRDA Tx transfer Buffer */
  100. uint16_t TxXferSize; /* IRDA Tx Transfer size */
  101. uint16_t TxXferCount; /* IRDA Tx Transfer Counter */
  102. uint8_t *pRxBuffPtr; /* Pointer to IRDA Rx transfer Buffer */
  103. uint16_t RxXferSize; /* IRDA Rx Transfer size */
  104. uint16_t RxXferCount; /* IRDA Rx Transfer Counter */
  105. DMA_HandleTypeDef *hdmatx; /* IRDA Tx DMA Handle parameters */
  106. DMA_HandleTypeDef *hdmarx; /* IRDA Rx DMA Handle parameters */
  107. HAL_LockTypeDef Lock; /* Locking object */
  108. __IO HAL_IRDA_StateTypeDef State; /* IRDA communication state */
  109. __IO uint32_t ErrorCode; /* IRDA Error code */
  110. }IRDA_HandleTypeDef;
  111. /**
  112. * @}
  113. */
  114. /* Exported constants --------------------------------------------------------*/
  115. /** @defgroup IRDA_Exported_Constants IRDA Exported constants
  116. * @{
  117. */
  118. /** @defgroup IRDA_Error_Code IRDA Error Code
  119. * @brief IRDA Error Code
  120. * @{
  121. */
  122. #define HAL_IRDA_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
  123. #define HAL_IRDA_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */
  124. #define HAL_IRDA_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */
  125. #define HAL_IRDA_ERROR_FE ((uint32_t)0x00000004) /*!< Frame error */
  126. #define HAL_IRDA_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */
  127. #define HAL_IRDA_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
  128. /**
  129. * @}
  130. */
  131. /** @defgroup IRDA_Word_Length IRDA Word Length
  132. * @{
  133. */
  134. #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000)
  135. #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
  136. /**
  137. * @}
  138. */
  139. /** @defgroup IRDA_Parity IRDA Parity
  140. * @{
  141. */
  142. #define IRDA_PARITY_NONE ((uint32_t)0x00000000)
  143. #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
  144. #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
  145. /**
  146. * @}
  147. */
  148. /** @defgroup IRDA_Mode IRDA Transfer Mode
  149. * @{
  150. */
  151. #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE)
  152. #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE)
  153. #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
  154. /**
  155. * @}
  156. */
  157. /** @defgroup IRDA_Low_Power IRDA Low Power
  158. * @{
  159. */
  160. #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP)
  161. #define IRDA_POWERMODE_NORMAL ((uint32_t)0x00000000)
  162. /**
  163. * @}
  164. */
  165. /** @defgroup IRDA_Flags IRDA Flags
  166. * Elements values convention: 0xXXXX
  167. * - 0xXXXX : Flag mask in the SR register
  168. * @{
  169. */
  170. #define IRDA_FLAG_TXE ((uint32_t)0x00000080)
  171. #define IRDA_FLAG_TC ((uint32_t)0x00000040)
  172. #define IRDA_FLAG_RXNE ((uint32_t)0x00000020)
  173. #define IRDA_FLAG_IDLE ((uint32_t)0x00000010)
  174. #define IRDA_FLAG_ORE ((uint32_t)0x00000008)
  175. #define IRDA_FLAG_NE ((uint32_t)0x00000004)
  176. #define IRDA_FLAG_FE ((uint32_t)0x00000002)
  177. #define IRDA_FLAG_PE ((uint32_t)0x00000001)
  178. /**
  179. * @}
  180. */
  181. /** @defgroup IRDA_Interrupt_definition IRDA Interrupt Definitions
  182. * Elements values convention: 0xY000XXXX
  183. * - XXXX : Interrupt mask in the XX register
  184. * - Y : Interrupt source register (2bits)
  185. * - 01: CR1 register
  186. * - 10: CR2 register
  187. * - 11: CR3 register
  188. * @{
  189. */
  190. #define IRDA_IT_PE ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_PEIE))
  191. #define IRDA_IT_TXE ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_TXEIE))
  192. #define IRDA_IT_TC ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_TCIE))
  193. #define IRDA_IT_RXNE ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_RXNEIE))
  194. #define IRDA_IT_IDLE ((uint32_t)(IRDA_CR1_REG_INDEX << 28 | USART_CR1_IDLEIE))
  195. #define IRDA_IT_LBD ((uint32_t)(IRDA_CR2_REG_INDEX << 28 | USART_CR2_LBDIE))
  196. #define IRDA_IT_CTS ((uint32_t)(IRDA_CR3_REG_INDEX << 28 | USART_CR3_CTSIE))
  197. #define IRDA_IT_ERR ((uint32_t)(IRDA_CR3_REG_INDEX << 28 | USART_CR3_EIE))
  198. /**
  199. * @}
  200. */
  201. /**
  202. * @}
  203. */
  204. /* Exported macro ------------------------------------------------------------*/
  205. /** @defgroup IRDA_Exported_Macros IRDA Exported Macros
  206. * @{
  207. */
  208. /** @brief Reset IRDA handle state
  209. * @param __HANDLE__: specifies the USART Handle.
  210. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  211. * UART peripheral.
  212. * @retval None
  213. */
  214. #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET)
  215. /** @brief Flushs the IRDA DR register
  216. * @param __HANDLE__: specifies the USART Handle.
  217. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  218. * UART peripheral.
  219. */
  220. #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
  221. /** @brief Checks whether the specified IRDA flag is set or not.
  222. * @param __HANDLE__: specifies the USART Handle.
  223. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  224. * UART peripheral.
  225. * @param __FLAG__: specifies the flag to check.
  226. * This parameter can be one of the following values:
  227. * @arg IRDA_FLAG_TXE: Transmit data register empty flag
  228. * @arg IRDA_FLAG_TC: Transmission Complete flag
  229. * @arg IRDA_FLAG_RXNE: Receive data register not empty flag
  230. * @arg IRDA_FLAG_IDLE: Idle Line detection flag
  231. * @arg IRDA_FLAG_ORE: OverRun Error flag
  232. * @arg IRDA_FLAG_NE: Noise Error flag
  233. * @arg IRDA_FLAG_FE: Framing Error flag
  234. * @arg IRDA_FLAG_PE: Parity Error flag
  235. * @retval The new state of __FLAG__ (TRUE or FALSE).
  236. */
  237. #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
  238. /** @brief Clears the specified IRDA pending flag.
  239. * @param __HANDLE__: specifies the USART Handle.
  240. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  241. * UART peripheral.
  242. * @param __FLAG__: specifies the flag to check.
  243. * This parameter can be any combination of the following values:
  244. * @arg IRDA_FLAG_TC: Transmission Complete flag.
  245. * @arg IRDA_FLAG_RXNE: Receive data register not empty flag.
  246. *
  247. * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun
  248. * error) and IDLE (Idle line detected) flags are cleared by software
  249. * sequence: a read operation to USART_SR register followed by a read
  250. * operation to USART_DR register.
  251. * @note RXNE flag can be also cleared by a read to the USART_DR register.
  252. * @note TC flag can be also cleared by software sequence: a read operation to
  253. * USART_SR register followed by a write operation to USART_DR register.
  254. * @note TXE flag is cleared only by a write to the USART_DR register.
  255. *
  256. * @retval None
  257. */
  258. #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
  259. /** @brief Clear the IRDA PE pending flag.
  260. * @param __HANDLE__: specifies the USART Handle.
  261. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  262. * UART peripheral.
  263. * @retval None
  264. */
  265. #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) \
  266. do{ \
  267. __IO uint32_t tmpreg = 0x00; \
  268. tmpreg = (__HANDLE__)->Instance->SR; \
  269. UNUSED(tmpreg); \
  270. } while(0)
  271. /** @brief Clear the IRDA FE pending flag.
  272. * @param __HANDLE__: specifies the USART Handle.
  273. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  274. * UART peripheral.
  275. * @retval None
  276. */
  277. #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
  278. /** @brief Clear the IRDA NE pending flag.
  279. * @param __HANDLE__: specifies the USART Handle.
  280. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  281. * UART peripheral.
  282. * @retval None
  283. */
  284. #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
  285. /** @brief Clear the IRDA ORE pending flag.
  286. * @param __HANDLE__: specifies the USART Handle.
  287. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  288. * UART peripheral.
  289. * @retval None
  290. */
  291. #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
  292. /** @brief Clear the IRDA IDLE pending flag.
  293. * @param __HANDLE__: specifies the USART Handle.
  294. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  295. * UART peripheral.
  296. * @retval None
  297. */
  298. #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
  299. /** @brief Enables or disables the specified IRDA interrupt.
  300. * @param __HANDLE__: specifies the USART Handle.
  301. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  302. * UART peripheral.
  303. * @param __INTERRUPT__: specifies the IRDA interrupt source to check.
  304. * This parameter can be one of the following values:
  305. * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
  306. * @arg IRDA_IT_TC: Transmission complete interrupt
  307. * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
  308. * @arg IRDA_IT_IDLE: Idle line detection interrupt
  309. * @arg IRDA_IT_PE: Parity Error interrupt
  310. * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
  311. * @retval None
  312. */
  313. #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \
  314. (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \
  315. ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK)))
  316. #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
  317. (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
  318. ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK)))
  319. /** @brief Checks whether the specified IRDA interrupt has occurred or not.
  320. * @param __HANDLE__: specifies the USART Handle.
  321. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
  322. * UART peripheral.
  323. * @param __IT__: specifies the IRDA interrupt source to check.
  324. * This parameter can be one of the following values:
  325. * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
  326. * @arg IRDA_IT_TC: Transmission complete interrupt
  327. * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
  328. * @arg IRDA_IT_IDLE: Idle line detection interrupt
  329. * @arg USART_IT_ERR: Error interrupt
  330. * @arg IRDA_IT_PE: Parity Error interrupt
  331. * @retval The new state of __IT__ (TRUE or FALSE).
  332. */
  333. #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28) == 2)? \
  334. (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK))
  335. /** @brief Macro to enable the IRDA's one bit sample method
  336. * @param __HANDLE__: specifies the IRDA Handle.
  337. * @retval None
  338. */
  339. #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
  340. /** @brief Macro to disable the IRDA's one bit sample method
  341. * @param __HANDLE__: specifies the IRDA Handle.
  342. * @retval None
  343. */
  344. #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
  345. /** @brief Enable UART/USART associated to IRDA Handle
  346. * @param __HANDLE__: specifies the IRDA Handle.
  347. * IRDA Handle selects the USARTx or UARTy peripheral
  348. * (USART,UART availability and x,y values depending on device).
  349. * @retval None
  350. */
  351. #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
  352. /** @brief Disable UART/USART associated to IRDA Handle
  353. * @param __HANDLE__: specifies the IRDA Handle.
  354. * IRDA Handle selects the USARTx or UARTy peripheral
  355. * (USART,UART availability and x,y values depending on device).
  356. * @retval None
  357. */
  358. #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
  359. /**
  360. * @}
  361. */
  362. /* Exported functions --------------------------------------------------------*/
  363. /** @addtogroup IRDA_Exported_Functions
  364. * @{
  365. */
  366. /** @addtogroup IRDA_Exported_Functions_Group1
  367. * @{
  368. */
  369. /* Initialization/de-initialization functions **********************************/
  370. HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda);
  371. HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda);
  372. void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda);
  373. void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda);
  374. /**
  375. * @}
  376. */
  377. /** @addtogroup IRDA_Exported_Functions_Group2
  378. * @{
  379. */
  380. /* IO operation functions *******************************************************/
  381. HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  382. HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  383. HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
  384. HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
  385. HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
  386. HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
  387. HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda);
  388. HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda);
  389. HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda);
  390. void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda);
  391. void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda);
  392. void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda);
  393. void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
  394. void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
  395. void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda);
  396. /**
  397. * @}
  398. */
  399. /** @addtogroup IRDA_Exported_Functions_Group3
  400. * @{
  401. */
  402. /* Peripheral State functions **************************************************/
  403. HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda);
  404. uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda);
  405. /**
  406. * @}
  407. */
  408. /**
  409. * @}
  410. */
  411. /* Private types -------------------------------------------------------------*/
  412. /* Private variables ---------------------------------------------------------*/
  413. /* Private constants ---------------------------------------------------------*/
  414. /** @defgroup IRDA_Private_Constants IRDA Private Constants
  415. * @{
  416. */
  417. /** @brief IRDA interruptions flag mask
  418. *
  419. */
  420. #define IRDA_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
  421. USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE )
  422. #define IRDA_CR1_REG_INDEX 1
  423. #define IRDA_CR2_REG_INDEX 2
  424. #define IRDA_CR3_REG_INDEX 3
  425. /**
  426. * @}
  427. */
  428. /* Private macros --------------------------------------------------------*/
  429. /** @defgroup IRDA_Private_Macros IRDA Private Macros
  430. * @{
  431. */
  432. #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \
  433. ((LENGTH) == IRDA_WORDLENGTH_9B))
  434. #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \
  435. ((PARITY) == IRDA_PARITY_EVEN) || \
  436. ((PARITY) == IRDA_PARITY_ODD))
  437. #define IS_IRDA_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3) == 0x00) && ((MODE) != (uint32_t)0x000000))
  438. #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \
  439. ((MODE) == IRDA_POWERMODE_NORMAL))
  440. #define IS_IRDA_BAUDRATE(BAUDRATE) ((BAUDRATE) < 115201)
  441. #define IRDA_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_)))
  442. #define IRDA_DIVMANT(_PCLK_, _BAUD_) (IRDA_DIV((_PCLK_), (_BAUD_))/100)
  443. #define IRDA_DIVFRAQ(_PCLK_, _BAUD_) (((IRDA_DIV((_PCLK_), (_BAUD_)) - (IRDA_DIVMANT((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100)
  444. #define IRDA_BRR(_PCLK_, _BAUD_) ((IRDA_DIVMANT((_PCLK_), (_BAUD_)) << 4)|(IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F))
  445. /**
  446. * @}
  447. */
  448. /* Private functions ---------------------------------------------------------*/
  449. /** @defgroup IRDA_Private_Functions IRDA Private Functions
  450. * @{
  451. */
  452. /**
  453. * @}
  454. */
  455. /**
  456. * @}
  457. */
  458. /**
  459. * @}
  460. */
  461. #ifdef __cplusplus
  462. }
  463. #endif
  464. #endif /* __STM32F4xx_HAL_IRDA_H */
  465. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/