stm32f7xx_hal_smartcard.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_smartcard.h
  4. * @author MCD Application Team
  5. * @brief Header file of SMARTCARD HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F7xx_HAL_SMARTCARD_H
  37. #define __STM32F7xx_HAL_SMARTCARD_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f7xx_hal_def.h"
  43. /** @addtogroup STM32F7xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup SMARTCARD
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types
  51. * @{
  52. */
  53. /**
  54. * @brief SMARTCARD Init Structure definition
  55. */
  56. typedef struct
  57. {
  58. uint32_t BaudRate; /*!< Configures the SmartCard communication baud rate.
  59. The baud rate register is computed using the following formula:
  60. Baud Rate Register = ((PCLKx) / ((hsmartcard->Init.BaudRate))) */
  61. uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
  62. This parameter @ref SMARTCARD_Word_Length can only be set to 9 (8 data + 1 parity bits). */
  63. uint32_t StopBits; /*!< Specifies the number of stop bits.
  64. This parameter can be a value of @ref SMARTCARD_Stop_Bits. */
  65. uint32_t Parity; /*!< Specifies the parity mode.
  66. This parameter can be a value of @ref SMARTCARD_Parity
  67. @note The parity is enabled by default (PCE is forced to 1).
  68. Since the WordLength is forced to 8 bits + parity, M is
  69. forced to 1 and the parity bit is the 9th bit. */
  70. uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
  71. This parameter can be a value of @ref SMARTCARD_Mode */
  72. uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock.
  73. This parameter can be a value of @ref SMARTCARD_Clock_Polarity */
  74. uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made.
  75. This parameter can be a value of @ref SMARTCARD_Clock_Phase */
  76. uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
  77. data bit (MSB) has to be output on the SCLK pin in synchronous mode.
  78. This parameter can be a value of @ref SMARTCARD_Last_Bit */
  79. uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
  80. Selecting the single sample method increases the receiver tolerance to clock
  81. deviations. This parameter can be a value of @ref SMARTCARD_OneBit_Sampling */
  82. uint32_t Prescaler; /*!< Specifies the SmartCard Prescaler */
  83. uint32_t GuardTime; /*!< Specifies the SmartCard Guard Time */
  84. uint16_t NACKEnable; /*!< Specifies whether the SmartCard NACK transmission is enabled
  85. in case of parity error.
  86. This parameter can be a value of @ref SMARTCARD_NACK_State */
  87. uint32_t TimeOutEnable; /*!< Specifies whether the receiver timeout is enabled.
  88. This parameter can be a value of @ref SMARTCARD_Timeout_Enable*/
  89. uint32_t TimeOutValue; /*!< Specifies the receiver time out value in number of baud blocks:
  90. it is used to implement the Character Wait Time (CWT) and
  91. Block Wait Time (BWT). It is coded over 24 bits. */
  92. uint32_t BlockLength; /*!< Specifies the SmartCard Block Length in T=1 Reception mode.
  93. This parameter can be any value from 0x0 to 0xFF */
  94. uint32_t AutoRetryCount; /*!< Specifies the SmartCard auto-retry count (number of retries in
  95. receive and transmit mode). When set to 0, retransmission is
  96. disabled. Otherwise, its maximum value is 7 (before signalling
  97. an error) */
  98. }SMARTCARD_InitTypeDef;
  99. /**
  100. * @brief SMARTCARD advanced features initalization structure definition
  101. */
  102. typedef struct
  103. {
  104. uint32_t AdvFeatureInit; /*!< Specifies which advanced SMARTCARD features is initialized. Several
  105. advanced features may be initialized at the same time. This parameter
  106. can be a value of @ref SMARTCARDEx_Advanced_Features_Initialization_Type */
  107. uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
  108. This parameter can be a value of @ref SMARTCARD_Tx_Inv */
  109. uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
  110. This parameter can be a value of @ref SMARTCARD_Rx_Inv */
  111. uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
  112. vs negative/inverted logic).
  113. This parameter can be a value of @ref SMARTCARD_Data_Inv */
  114. uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
  115. This parameter can be a value of @ref SMARTCARD_Rx_Tx_Swap */
  116. uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
  117. This parameter can be a value of @ref SMARTCARD_Overrun_Disable */
  118. uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
  119. This parameter can be a value of @ref SMARTCARD_DMA_Disable_on_Rx_Error */
  120. uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
  121. This parameter can be a value of @ref SMARTCARD_MSB_First */
  122. uint16_t TxCompletionIndication; /*!< Specifies which transmission completion indication is used: before (when
  123. relevant flag is available) or once guard time period has elapsed.
  124. This parameter can be a value of @ref SMARTCARDEx_Transmission_Completion_Indication. */
  125. }SMARTCARD_AdvFeatureInitTypeDef;
  126. /**
  127. * @brief HAL SMARTCARD State structures definition
  128. * @note HAL SMARTCARD State value is a combination of 2 different substates: gState and RxState.
  129. * - gState contains SMARTCARD state information related to global Handle management
  130. * and also information related to Tx operations.
  131. * gState value coding follow below described bitmap :
  132. * b7-b6 Error information
  133. * 00 : No Error
  134. * 01 : (Not Used)
  135. * 10 : Timeout
  136. * 11 : Error
  137. * b5 IP initilisation status
  138. * 0 : Reset (IP not initialized)
  139. * 1 : Init done (IP not initialized. HAL SMARTCARD Init function already called)
  140. * b4-b3 (not used)
  141. * xx : Should be set to 00
  142. * b2 Intrinsic process state
  143. * 0 : Ready
  144. * 1 : Busy (IP busy with some configuration or internal operations)
  145. * b1 (not used)
  146. * x : Should be set to 0
  147. * b0 Tx state
  148. * 0 : Ready (no Tx operation ongoing)
  149. * 1 : Busy (Tx operation ongoing)
  150. * - RxState contains information related to Rx operations.
  151. * RxState value coding follow below described bitmap :
  152. * b7-b6 (not used)
  153. * xx : Should be set to 00
  154. * b5 IP initilisation status
  155. * 0 : Reset (IP not initialized)
  156. * 1 : Init done (IP not initialized)
  157. * b4-b2 (not used)
  158. * xxx : Should be set to 000
  159. * b1 Rx state
  160. * 0 : Ready (no Rx operation ongoing)
  161. * 1 : Busy (Rx operation ongoing)
  162. * b0 (not used)
  163. * x : Should be set to 0.
  164. */
  165. typedef enum
  166. {
  167. HAL_SMARTCARD_STATE_RESET = 0x00U, /*!< Peripheral is not initialized
  168. Value is allowed for gState and RxState */
  169. HAL_SMARTCARD_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
  170. Value is allowed for gState and RxState */
  171. HAL_SMARTCARD_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
  172. Value is allowed for gState only */
  173. HAL_SMARTCARD_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
  174. Value is allowed for gState only */
  175. HAL_SMARTCARD_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
  176. Value is allowed for RxState only */
  177. HAL_SMARTCARD_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
  178. Not to be used for neither gState nor RxState.
  179. Value is result of combination (Or) between gState and RxState values */
  180. HAL_SMARTCARD_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
  181. Value is allowed for gState only */
  182. HAL_SMARTCARD_STATE_ERROR = 0xE0U /*!< Error
  183. Value is allowed for gState only */
  184. }HAL_SMARTCARD_StateTypeDef;
  185. /**
  186. * @brief SMARTCARD clock sources definition
  187. */
  188. typedef enum
  189. {
  190. SMARTCARD_CLOCKSOURCE_PCLK1 = 0x00U, /*!< PCLK1 clock source */
  191. SMARTCARD_CLOCKSOURCE_PCLK2 = 0x01U, /*!< PCLK2 clock source */
  192. SMARTCARD_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */
  193. SMARTCARD_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */
  194. SMARTCARD_CLOCKSOURCE_LSE = 0x08U, /*!< LSE clock source */
  195. SMARTCARD_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */
  196. }SMARTCARD_ClockSourceTypeDef;
  197. /**
  198. * @brief SMARTCARD handle Structure definition
  199. */
  200. typedef struct
  201. {
  202. USART_TypeDef *Instance; /*!< USART registers base address */
  203. SMARTCARD_InitTypeDef Init; /*!< SmartCard communication parameters */
  204. SMARTCARD_AdvFeatureInitTypeDef AdvancedInit; /*!< SmartCard advanced features initialization parameters */
  205. uint8_t *pTxBuffPtr; /*!< Pointer to SmartCard Tx transfer Buffer */
  206. uint16_t TxXferSize; /*!< SmartCard Tx Transfer size */
  207. __IO uint16_t TxXferCount; /*!< SmartCard Tx Transfer Counter */
  208. uint8_t *pRxBuffPtr; /*!< Pointer to SmartCard Rx transfer Buffer */
  209. uint16_t RxXferSize; /*!< SmartCard Rx Transfer size */
  210. __IO uint16_t RxXferCount; /*!< SmartCard Rx Transfer Counter */
  211. DMA_HandleTypeDef *hdmatx; /*!< SmartCard Tx DMA Handle parameters */
  212. DMA_HandleTypeDef *hdmarx; /*!< SmartCard Rx DMA Handle parameters */
  213. HAL_LockTypeDef Lock; /*!< Locking object */
  214. __IO HAL_SMARTCARD_StateTypeDef gState; /*!< SmartCard state information related to global Handle management
  215. and also related to Tx operations.
  216. This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
  217. __IO HAL_SMARTCARD_StateTypeDef RxState; /*!< SmartCard state information related to Rx operations.
  218. This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
  219. __IO uint32_t ErrorCode; /* SmartCard Error code */
  220. }SMARTCARD_HandleTypeDef;
  221. /**
  222. * @}
  223. */
  224. /* Exported constants --------------------------------------------------------*/
  225. /** @defgroup SMARTCARD_Exported_Constants SMARTCARD Exported constants
  226. * @{
  227. */
  228. /** @defgroup SMARTCARD_Error_Code SMARTCARD Error Code
  229. * @brief SMARTCARD Error Code
  230. * @{
  231. */
  232. #define HAL_SMARTCARD_ERROR_NONE ((uint32_t)0x00U) /*!< No error */
  233. #define HAL_SMARTCARD_ERROR_PE ((uint32_t)0x01U) /*!< Parity error */
  234. #define HAL_SMARTCARD_ERROR_NE ((uint32_t)0x02U) /*!< Noise error */
  235. #define HAL_SMARTCARD_ERROR_FE ((uint32_t)0x04U) /*!< frame error */
  236. #define HAL_SMARTCARD_ERROR_ORE ((uint32_t)0x08U) /*!< Overrun error */
  237. #define HAL_SMARTCARD_ERROR_DMA ((uint32_t)0x10U) /*!< DMA transfer error */
  238. #define HAL_SMARTCARD_ERROR_RTO ((uint32_t)0x20U) /*!< Receiver TimeOut error */
  239. /**
  240. * @}
  241. */
  242. /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
  243. * @{
  244. */
  245. #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M_0)
  246. /**
  247. * @}
  248. */
  249. /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits
  250. * @{
  251. */
  252. #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP))
  253. /**
  254. * @}
  255. */
  256. /** @defgroup SMARTCARD_Parity SMARTCARD Parity
  257. * @{
  258. */
  259. #define SMARTCARD_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
  260. #define SMARTCARD_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
  261. /**
  262. * @}
  263. */
  264. /** @defgroup SMARTCARD_Mode SMARTCARD Mode
  265. * @{
  266. */
  267. #define SMARTCARD_MODE_RX ((uint32_t)USART_CR1_RE)
  268. #define SMARTCARD_MODE_TX ((uint32_t)USART_CR1_TE)
  269. #define SMARTCARD_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
  270. /**
  271. * @}
  272. */
  273. /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
  274. * @{
  275. */
  276. #define SMARTCARD_POLARITY_LOW ((uint32_t)0x0000U)
  277. #define SMARTCARD_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL)
  278. /**
  279. * @}
  280. */
  281. /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase
  282. * @{
  283. */
  284. #define SMARTCARD_PHASE_1EDGE ((uint32_t)0x0000U)
  285. #define SMARTCARD_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA)
  286. /**
  287. * @}
  288. */
  289. /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit
  290. * @{
  291. */
  292. #define SMARTCARD_LASTBIT_DISABLE ((uint32_t)0x0000U)
  293. #define SMARTCARD_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL)
  294. /**
  295. * @}
  296. */
  297. /** @defgroup SMARTCARD_OneBit_Sampling SMARTCARD OneBit Sampling
  298. * @{
  299. */
  300. #define SMARTCARD_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x0000U)
  301. #define SMARTCARD_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT)
  302. /**
  303. * @}
  304. */
  305. /** @defgroup SMARTCARD_NACK_State SMARTCARD NACK State
  306. * @{
  307. */
  308. #define SMARTCARD_NACK_ENABLE ((uint32_t)USART_CR3_NACK)
  309. #define SMARTCARD_NACK_DISABLE ((uint32_t)0x0000U)
  310. /**
  311. * @}
  312. */
  313. /** @defgroup SMARTCARD_Timeout_Enable SMARTCARD Timeout Enable
  314. * @{
  315. */
  316. #define SMARTCARD_TIMEOUT_DISABLE ((uint32_t)0x00000000U)
  317. #define SMARTCARD_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN)
  318. /**
  319. * @}
  320. */
  321. /** @defgroup SMARTCARD_DMA_Requests SMARTCARD DMA requests
  322. * @{
  323. */
  324. #define SMARTCARD_DMAREQ_TX ((uint32_t)USART_CR3_DMAT)
  325. #define SMARTCARD_DMAREQ_RX ((uint32_t)USART_CR3_DMAR)
  326. /**
  327. * @}
  328. */
  329. /** @defgroup SMARTCARD_Advanced_Features_Initialization_Type SMARTCARD Advanced Features Initialization Type
  330. * @{
  331. */
  332. #define SMARTCARD_ADVFEATURE_NO_INIT ((uint32_t)0x00000000U)
  333. #define SMARTCARD_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001U)
  334. #define SMARTCARD_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002U)
  335. #define SMARTCARD_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004U)
  336. #define SMARTCARD_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008U)
  337. #define SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010U)
  338. #define SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020U)
  339. #define SMARTCARD_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080U)
  340. /**
  341. * @}
  342. */
  343. /** @defgroup SMARTCARD_Tx_Inv SMARTCARD Tx Inv
  344. * @{
  345. */
  346. #define SMARTCARD_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000U)
  347. #define SMARTCARD_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV)
  348. /**
  349. * @}
  350. */
  351. /** @defgroup SMARTCARD_Rx_Inv SMARTCARD Rx Inv
  352. * @{
  353. */
  354. #define SMARTCARD_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000U)
  355. #define SMARTCARD_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV)
  356. /**
  357. * @}
  358. */
  359. /** @defgroup SMARTCARD_Data_Inv SMARTCARD Data Inv
  360. * @{
  361. */
  362. #define SMARTCARD_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000U)
  363. #define SMARTCARD_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV)
  364. /**
  365. * @}
  366. */
  367. /** @defgroup SMARTCARD_Rx_Tx_Swap SMARTCARD Rx Tx Swap
  368. * @{
  369. */
  370. #define SMARTCARD_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000U)
  371. #define SMARTCARD_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP)
  372. /**
  373. * @}
  374. */
  375. /** @defgroup SMARTCARD_Overrun_Disable SMARTCARD Overrun Disable
  376. * @{
  377. */
  378. #define SMARTCARD_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000U)
  379. #define SMARTCARD_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS)
  380. /**
  381. * @}
  382. */
  383. /** @defgroup SMARTCARD_DMA_Disable_on_Rx_Error SMARTCARD DMA Disable on Rx Error
  384. * @{
  385. */
  386. #define SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000U)
  387. #define SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE)
  388. /**
  389. * @}
  390. */
  391. /** @defgroup SMARTCARD_MSB_First SMARTCARD MSB First
  392. * @{
  393. */
  394. #define SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000U)
  395. #define SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST)
  396. /**
  397. * @}
  398. */
  399. /** @defgroup SmartCard_Flags SMARTCARD Flags
  400. * Elements values convention: 0xXXXX
  401. * - 0xXXXX : Flag mask in the ISR register
  402. * @{
  403. */
  404. #define SMARTCARD_FLAG_REACK ((uint32_t)0x00400000U)
  405. #define SMARTCARD_FLAG_TEACK ((uint32_t)0x00200000U)
  406. #define SMARTCARD_FLAG_BUSY ((uint32_t)0x00010000U)
  407. #define SMARTCARD_FLAG_EOBF ((uint32_t)0x00001000U)
  408. #define SMARTCARD_FLAG_RTOF ((uint32_t)0x00000800U)
  409. #define SMARTCARD_FLAG_TXE ((uint32_t)0x00000080U)
  410. #define SMARTCARD_FLAG_TC ((uint32_t)0x00000040U)
  411. #define SMARTCARD_FLAG_RXNE ((uint32_t)0x00000020U)
  412. #define SMARTCARD_FLAG_IDLE ((uint32_t)0x00000010U)
  413. #define SMARTCARD_FLAG_ORE ((uint32_t)0x00000008U)
  414. #define SMARTCARD_FLAG_NE ((uint32_t)0x00000004U)
  415. #define SMARTCARD_FLAG_FE ((uint32_t)0x00000002U)
  416. #define SMARTCARD_FLAG_PE ((uint32_t)0x00000001U)
  417. /**
  418. * @}
  419. */
  420. /** @defgroup SMARTCARD_Interrupt_definition SMARTCARD Interrupt definition
  421. * Elements values convention: 0000ZZZZ0XXYYYYYb
  422. * - YYYYY : Interrupt source position in the XX register (5bits)
  423. * - XX : Interrupt source register (2bits)
  424. * - 01: CR1 register
  425. * - 10: CR2 register
  426. * - 11: CR3 register
  427. * - ZZZZ : Flag position in the ISR register(4bits)
  428. * @{
  429. */
  430. #define SMARTCARD_IT_PE ((uint16_t)0x0028U)
  431. #define SMARTCARD_IT_TXE ((uint16_t)0x0727U)
  432. #define SMARTCARD_IT_TC ((uint16_t)0x0626U)
  433. #define SMARTCARD_IT_RXNE ((uint16_t)0x0525U)
  434. #define SMARTCARD_IT_IDLE ((uint16_t)0x0424U)
  435. #define SMARTCARD_IT_ERR ((uint16_t)0x0060U)
  436. #define SMARTCARD_IT_ORE ((uint16_t)0x0300U)
  437. #define SMARTCARD_IT_NE ((uint16_t)0x0200U)
  438. #define SMARTCARD_IT_FE ((uint16_t)0x0100U)
  439. #define SMARTCARD_IT_EOB ((uint16_t)0x0C3BU)
  440. #define SMARTCARD_IT_RTO ((uint16_t)0x0B3AU)
  441. /**
  442. * @}
  443. */
  444. /** @defgroup SMARTCARD_IT_CLEAR_Flags SMARTCARD IT CLEAR Flags
  445. * @{
  446. */
  447. #define SMARTCARD_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
  448. #define SMARTCARD_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
  449. #define SMARTCARD_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
  450. #define SMARTCARD_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
  451. #define SMARTCARD_CLEAR_IDLEF USART_ICR_IDLECF /*!< Idle line detected clear Flag */
  452. #define SMARTCARD_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
  453. #define SMARTCARD_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
  454. #define SMARTCARD_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */
  455. /**
  456. * @}
  457. */
  458. /** @defgroup SMARTCARD_Request_Parameters SMARTCARD Request Parameters
  459. * @{
  460. */
  461. #define SMARTCARD_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
  462. #define SMARTCARD_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
  463. /**
  464. * @}
  465. */
  466. /** @defgroup SMARTCARD_CR3_SCAR_CNT_LSB_POS SMARTCARD CR3 SCAR CNT LSB POS
  467. * @{
  468. */
  469. #define SMARTCARD_CR3_SCARCNT_LSB_POS ((uint32_t) 17U)
  470. /**
  471. * @}
  472. */
  473. /** @defgroup SMARTCARD_GTPR_GT_LSBPOS SMARTCARD GTPR GT LSBPOS
  474. * @{
  475. */
  476. #define SMARTCARD_GTPR_GT_LSB_POS ((uint32_t) 8U)
  477. /**
  478. * @}
  479. */
  480. /** @defgroup SMARTCARD_RTOR_BLEN_LSBPOS SMARTCARD RTOR BLEN LSBPOS
  481. * @{
  482. */
  483. #define SMARTCARD_RTOR_BLEN_LSB_POS ((uint32_t) 24U)
  484. /**
  485. * @}
  486. */
  487. /** @defgroup SMARTCARD_Interruption_Mask SMARTCARD Interruption Mask
  488. * @{
  489. */
  490. #define SMARTCARD_IT_MASK ((uint16_t)0x001FU)
  491. /**
  492. * @}
  493. */
  494. /**
  495. * @}
  496. */
  497. /* Exported macro ------------------------------------------------------------*/
  498. /** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros
  499. * @{
  500. */
  501. /** @brief Reset SMARTCARD handle state
  502. * @param __HANDLE__ specifies the SMARTCARD Handle.
  503. * The Handle Instance which can be USART1 or USART2
  504. * @retval None
  505. */
  506. #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMARTCARD_STATE_RESET)
  507. /** @brief Flush the Smartcard DR register
  508. * @param __HANDLE__ specifies the SMARTCARD Handle.
  509. * The Handle Instance which can be USART1 or USART2.
  510. * @retval None
  511. */
  512. #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) (__HAL_SMARTCARD_SEND_REQ((__HANDLE__), SMARTCARD_RXDATA_FLUSH_REQUEST))
  513. /** @brief Checks whether the specified Smartcard flag is set or not.
  514. * @param __HANDLE__ specifies the SMARTCARD Handle.
  515. * The Handle Instance which can be USART1 or USART2.
  516. * @param __FLAG__ specifies the flag to check.
  517. * This parameter can be one of the following values:
  518. * @arg SMARTCARD_FLAG_REACK: Receive enable acknowledge flag
  519. * @arg SMARTCARD_FLAG_TEACK: Transmit enable acknowledge flag
  520. * @arg SMARTCARD_FLAG_BUSY: Busy flag
  521. * @arg SMARTCARD_FLAG_EOBF: End of block flag
  522. * @arg SMARTCARD_FLAG_RTOF: Receiver timeout flag
  523. * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag
  524. * @arg SMARTCARD_FLAG_TC: Transmission Complete flag
  525. * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag
  526. * @arg SMARTCARD_FLAG_ORE: OverRun Error flag
  527. * @arg SMARTCARD_FLAG_NE: Noise Error flag
  528. * @arg SMARTCARD_FLAG_FE: Framing Error flag
  529. * @arg SMARTCARD_FLAG_PE: Parity Error flag
  530. * @retval The new state of __FLAG__ (TRUE or FALSE).
  531. */
  532. #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
  533. /** @brief Clear the specified SMARTCARD pending flag.
  534. * @param __HANDLE__ specifies the SMARTCARD Handle.
  535. * @param __FLAG__ specifies the flag to check.
  536. * This parameter can be any combination of the following values:
  537. * @arg @ref SMARTCARD_CLEAR_PEF Parity error clear flag
  538. * @arg @ref SMARTCARD_CLEAR_FEF Framing error clear flag
  539. * @arg @ref SMARTCARD_CLEAR_NEF Noise detected clear flag
  540. * @arg @ref SMARTCARD_CLEAR_OREF OverRun error clear flag
  541. * @arg @ref SMARTCARD_CLEAR_IDLEF Idle line detected clear flag
  542. * @arg @ref SMARTCARD_CLEAR_TCF Transmission complete clear flag
  543. @if STM32L443xx
  544. * @arg @ref SMARTCARD_CLEAR_TCBGTF Transmission complete before guard time clear flag (when flag available)
  545. @endif
  546. * @arg @ref SMARTCARD_CLEAR_RTOF Receiver timeout clear flag
  547. * @arg @ref SMARTCARD_CLEAR_EOBF End of block clear flag
  548. * @retval None
  549. */
  550. #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
  551. /** @brief Clear the SMARTCARD PE pending flag.
  552. * @param __HANDLE__ specifies the SMARTCARD Handle.
  553. * @retval None
  554. */
  555. #define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_PEF)
  556. /** @brief Clear the SMARTCARD FE pending flag.
  557. * @param __HANDLE__ specifies the SMARTCARD Handle.
  558. * @retval None
  559. */
  560. #define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_FEF)
  561. /** @brief Clear the SMARTCARD NE pending flag.
  562. * @param __HANDLE__ specifies the SMARTCARD Handle.
  563. * @retval None
  564. */
  565. #define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_NEF)
  566. /** @brief Clear the SMARTCARD ORE pending flag.
  567. * @param __HANDLE__ specifies the SMARTCARD Handle.
  568. * @retval None
  569. */
  570. #define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_OREF)
  571. /** @brief Clear the SMARTCARD IDLE pending flag.
  572. * @param __HANDLE__ specifies the SMARTCARD Handle.
  573. * @retval None
  574. */
  575. #define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_IDLEF)
  576. /** @brief Enables the specified SmartCard interrupt.
  577. * @param __HANDLE__ specifies the SMARTCARD Handle.
  578. * The Handle Instance which can be USART1 or USART2.
  579. * @param __INTERRUPT__ specifies the SMARTCARD interrupt to enable.
  580. * This parameter can be one of the following values:
  581. * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
  582. * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
  583. * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
  584. * @arg SMARTCARD_IT_TC: Transmission complete interrupt
  585. * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
  586. * @arg SMARTCARD_IT_PE: Parity Error interrupt
  587. * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
  588. * @retval None
  589. */
  590. #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
  591. ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
  592. ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
  593. /** @brief Disables the specified SmartCard interrupt.
  594. * @param __HANDLE__ specifies the SMARTCARD Handle.
  595. * The Handle Instance which can be USART1 or USART2.
  596. * @param __INTERRUPT__ specifies the SMARTCARD interrupt to enable.
  597. * This parameter can be one of the following values:
  598. * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
  599. * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
  600. * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
  601. * @arg SMARTCARD_IT_TC: Transmission complete interrupt
  602. * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
  603. * @arg SMARTCARD_IT_PE: Parity Error interrupt
  604. * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
  605. * @retval None
  606. */
  607. #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
  608. ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
  609. ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
  610. /** @brief Checks whether the specified SmartCard interrupt has occurred or not.
  611. * @param __HANDLE__ specifies the SMARTCARD Handle.
  612. * The Handle Instance which can be USART1 or USART2.
  613. * @param __IT__ specifies the SMARTCARD interrupt to check.
  614. * This parameter can be one of the following values:
  615. * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
  616. * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
  617. * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
  618. * @arg SMARTCARD_IT_TC: Transmission complete interrupt
  619. * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
  620. * @arg SMARTCARD_IT_ORE: OverRun Error interrupt
  621. * @arg SMARTCARD_IT_NE: Noise Error interrupt
  622. * @arg SMARTCARD_IT_FE: Framing Error interrupt
  623. * @arg SMARTCARD_IT_PE: Parity Error interrupt
  624. * @retval The new state of __IT__ (TRUE or FALSE).
  625. */
  626. #define __HAL_SMARTCARD_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1U << ((__IT__)>> 0x08U)))
  627. /** @brief Checks whether the specified SmartCard interrupt interrupt source is enabled.
  628. * @param __HANDLE__ specifies the SMARTCARD Handle.
  629. * The Handle Instance which can be USART1 or USART2.
  630. * @param __IT__ specifies the SMARTCARD interrupt source to check.
  631. * This parameter can be one of the following values:
  632. * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
  633. * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
  634. * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
  635. * @arg SMARTCARD_IT_TC: Transmission complete interrupt
  636. * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
  637. * @arg SMARTCARD_IT_ORE: OverRun Error interrupt
  638. * @arg SMARTCARD_IT_NE: Noise Error interrupt
  639. * @arg SMARTCARD_IT_FE: Framing Error interrupt
  640. * @arg SMARTCARD_IT_PE: Parity Error interrupt
  641. * @retval The new state of __IT__ (TRUE or FALSE).
  642. */
  643. #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2U)? \
  644. (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \
  645. (((uint16_t)(__IT__)) & SMARTCARD_IT_MASK)))
  646. /** @brief Clears the specified SMARTCARD ISR flag, in setting the proper ICR register flag.
  647. * @param __HANDLE__ specifies the SMARTCARD Handle.
  648. * The Handle Instance which can be USART1 or USART2.
  649. * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set
  650. * to clear the corresponding interrupt
  651. * This parameter can be one of the following values:
  652. * @arg USART_CLEAR_PEF: Parity Error Clear Flag
  653. * @arg USART_CLEAR_FEF: Framing Error Clear Flag
  654. * @arg USART_CLEAR_NEF: Noise detected Clear Flag
  655. * @arg USART_CLEAR_OREF: OverRun Error Clear Flag
  656. * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag
  657. * @arg USART_CLEAR_RTOF: Receiver Time Out Clear Flag
  658. * @arg USART_CLEAR_EOBF: End Of Block Clear Flag
  659. * @retval None
  660. */
  661. #define __HAL_SMARTCARD_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
  662. /** @brief Set a specific SMARTCARD request flag.
  663. * @param __HANDLE__ specifies the SMARTCARD Handle.
  664. * The Handle Instance which can be USART1 or USART2.
  665. * @param __REQ__ specifies the request flag to set
  666. * This parameter can be one of the following values:
  667. * @arg SMARTCARD_RXDATA_FLUSH_REQUEST: Receive Data flush Request
  668. * @arg SMARTCARD_TXDATA_FLUSH_REQUEST: Transmit data flush Request
  669. *
  670. * @retval None
  671. */
  672. #define __HAL_SMARTCARD_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
  673. /** @brief Enable the USART associated to the SMARTCARD Handle
  674. * @param __HANDLE__ specifies the SMARTCARD Handle.
  675. * The Handle Instance which can be USART1 or USART2.
  676. * @retval None
  677. */
  678. #define __HAL_SMARTCARD_ENABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
  679. /** @brief Disable the USART associated to the SMARTCARD Handle
  680. * @param __HANDLE__ specifies the SMARTCARD Handle.
  681. * The Handle Instance which can be USART1 or USART2.
  682. * @retval None
  683. */
  684. #define __HAL_SMARTCARD_DISABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
  685. /** @brief Macros to enable or disable the SmartCard DMA request.
  686. * @param __HANDLE__ specifies the SMARTCARD Handle.
  687. * The Handle Instance which can be USART1 or USART2.
  688. * @param __REQUEST__ specifies the SmartCard DMA request.
  689. * This parameter can be one of the following values:
  690. * @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
  691. * @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
  692. */
  693. #define __HAL_SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 |= (__REQUEST__))
  694. #define __HAL_SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 &= ~(__REQUEST__))
  695. /**
  696. * @}
  697. */
  698. /* Include SMARTCARD HAL Extension module */
  699. #include "stm32f7xx_hal_smartcard_ex.h"
  700. /* Exported functions --------------------------------------------------------*/
  701. /** @addtogroup SMARTCARD_Exported_Functions
  702. * @{
  703. */
  704. /** @addtogroup SMARTCARD_Exported_Functions_Group1
  705. * @{
  706. */
  707. /* Initialization/de-initialization functions **********************************/
  708. HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsmartcard);
  709. HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsmartcard);
  710. void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsmartcard);
  711. void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsmartcard);
  712. /**
  713. * @}
  714. */
  715. /** @addtogroup SMARTCARD_Exported_Functions_Group2
  716. * @{
  717. */
  718. /* IO operation functions *******************************************************/
  719. HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  720. HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  721. HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
  722. HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
  723. HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
  724. HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
  725. /* Transfer Abort functions */
  726. HAL_StatusTypeDef HAL_SMARTCARD_Abort(SMARTCARD_HandleTypeDef *hsmartcard);
  727. HAL_StatusTypeDef HAL_SMARTCARD_AbortTransmit(SMARTCARD_HandleTypeDef *hsmartcard);
  728. HAL_StatusTypeDef HAL_SMARTCARD_AbortReceive(SMARTCARD_HandleTypeDef *hsmartcard);
  729. HAL_StatusTypeDef HAL_SMARTCARD_Abort_IT(SMARTCARD_HandleTypeDef *hsmartcard);
  730. HAL_StatusTypeDef HAL_SMARTCARD_AbortTransmit_IT(SMARTCARD_HandleTypeDef *hsmartcard);
  731. HAL_StatusTypeDef HAL_SMARTCARD_AbortReceive_IT(SMARTCARD_HandleTypeDef *hsmartcard);
  732. void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsmartcard);
  733. void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard);
  734. void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard);
  735. void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsmartcard);
  736. void HAL_SMARTCARD_AbortCpltCallback (SMARTCARD_HandleTypeDef *hsmartcard);
  737. void HAL_SMARTCARD_AbortTransmitCpltCallback (SMARTCARD_HandleTypeDef *hsmartcard);
  738. void HAL_SMARTCARD_AbortReceiveCpltCallback (SMARTCARD_HandleTypeDef *hsmartcard);
  739. /**
  740. * @}
  741. */
  742. /** @addtogroup SMARTCARD_Exported_Functions_Group3
  743. * @{
  744. */
  745. /* Peripheral State functions **************************************************/
  746. HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsmartcard);
  747. uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsmartcard);
  748. /**
  749. * @}
  750. */
  751. /**
  752. * @}
  753. */
  754. /* Private types -------------------------------------------------------------*/
  755. /* Private variables ---------------------------------------------------------*/
  756. /* Private constants ---------------------------------------------------------*/
  757. /** @defgroup SMARTCARD_Private_Constants SMARTCARD Private Constants
  758. * @{
  759. */
  760. #define IS_SMARTCARD_WORD_LENGTH(__LENGTH__) ((__LENGTH__) == SMARTCARD_WORDLENGTH_9B)
  761. #define IS_SMARTCARD_STOPBITS(__STOPBITS__) ((__STOPBITS__) == SMARTCARD_STOPBITS_1_5)
  762. #define IS_SMARTCARD_PARITY(__PARITY__) (((__PARITY__) == SMARTCARD_PARITY_EVEN) || \
  763. ((__PARITY__) == SMARTCARD_PARITY_ODD))
  764. #define IS_SMARTCARD_MODE(__MODE__) ((((__MODE__) & (uint32_t)0xFFF3) == 0x00) && ((__MODE__) != (uint32_t)0x00))
  765. #define IS_SMARTCARD_POLARITY(__CPOL__) (((__CPOL__) == SMARTCARD_POLARITY_LOW) || ((__CPOL__) == SMARTCARD_POLARITY_HIGH))
  766. #define IS_SMARTCARD_PHASE(__CPHA__) (((__CPHA__) == SMARTCARD_PHASE_1EDGE) || ((__CPHA__) == SMARTCARD_PHASE_2EDGE))
  767. #define IS_SMARTCARD_LASTBIT(__LASTBIT__) (((__LASTBIT__) == SMARTCARD_LASTBIT_DISABLE) || \
  768. ((__LASTBIT__) == SMARTCARD_LASTBIT_ENABLE))
  769. #define IS_SMARTCARD_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == SMARTCARD_ONE_BIT_SAMPLE_DISABLE) || \
  770. ((__ONEBIT__) == SMARTCARD_ONE_BIT_SAMPLE_ENABLE))
  771. #define IS_SMARTCARD_NACK(__NACK__) (((__NACK__) == SMARTCARD_NACK_ENABLE) || \
  772. ((__NACK__) == SMARTCARD_NACK_DISABLE))
  773. #define IS_SMARTCARD_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == SMARTCARD_TIMEOUT_DISABLE) || \
  774. ((__TIMEOUT__) == SMARTCARD_TIMEOUT_ENABLE))
  775. #define IS_SMARTCARD_ADVFEATURE_INIT(INIT) ((INIT) <= (SMARTCARD_ADVFEATURE_NO_INIT | \
  776. SMARTCARD_ADVFEATURE_TXINVERT_INIT | \
  777. SMARTCARD_ADVFEATURE_RXINVERT_INIT | \
  778. SMARTCARD_ADVFEATURE_DATAINVERT_INIT | \
  779. SMARTCARD_ADVFEATURE_SWAP_INIT | \
  780. SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
  781. SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT | \
  782. SMARTCARD_ADVFEATURE_MSBFIRST_INIT))
  783. #define IS_SMARTCARD_ADVFEATURE_TXINV(TXINV) (((TXINV) == SMARTCARD_ADVFEATURE_TXINV_DISABLE) || \
  784. ((TXINV) == SMARTCARD_ADVFEATURE_TXINV_ENABLE))
  785. #define IS_SMARTCARD_ADVFEATURE_RXINV(RXINV) (((RXINV) == SMARTCARD_ADVFEATURE_RXINV_DISABLE) || \
  786. ((RXINV) == SMARTCARD_ADVFEATURE_RXINV_ENABLE))
  787. #define IS_SMARTCARD_ADVFEATURE_DATAINV(DATAINV) (((DATAINV) == SMARTCARD_ADVFEATURE_DATAINV_DISABLE) || \
  788. ((DATAINV) == SMARTCARD_ADVFEATURE_DATAINV_ENABLE))
  789. #define IS_SMARTCARD_ADVFEATURE_SWAP(SWAP) (((SWAP) == SMARTCARD_ADVFEATURE_SWAP_DISABLE) || \
  790. ((SWAP) == SMARTCARD_ADVFEATURE_SWAP_ENABLE))
  791. #define IS_SMARTCARD_OVERRUN(OVERRUN) (((OVERRUN) == SMARTCARD_ADVFEATURE_OVERRUN_ENABLE) || \
  792. ((OVERRUN) == SMARTCARD_ADVFEATURE_OVERRUN_DISABLE))
  793. #define IS_SMARTCARD_ADVFEATURE_DMAONRXERROR(DMA) (((DMA) == SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR) || \
  794. ((DMA) == SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR))
  795. #define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 4500001)
  796. #define IS_SMARTCARD_BLOCKLENGTH(__LENGTH__) ((__LENGTH__) <= 0xFF)
  797. #define IS_SMARTCARD_TIMEOUT_VALUE(__TIMEOUTVALUE__) ((__TIMEOUTVALUE__) <= 0xFFFFFF)
  798. #define IS_SMARTCARD_AUTORETRY_COUNT(__COUNT__) ((__COUNT__) <= 0x7)
  799. #define IS_SMARTCARD_ADVFEATURE_MSBFIRST(MSBFIRST) (((MSBFIRST) == SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE) || \
  800. ((MSBFIRST) == SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE))
  801. #define IS_SMARTCARD_REQUEST_PARAMETER(PARAM) (((PARAM) == SMARTCARD_RXDATA_FLUSH_REQUEST) || \
  802. ((PARAM) == SMARTCARD_TXDATA_FLUSH_REQUEST))
  803. /**
  804. * @}
  805. */
  806. /* Private functions ---------------------------------------------------------*/
  807. /** @defgroup SMARTCARD_Private_Functions SMARTCARD Private Functions
  808. * @{
  809. */
  810. /**
  811. * @}
  812. */
  813. /**
  814. * @}
  815. */
  816. /**
  817. * @}
  818. */
  819. #ifdef __cplusplus
  820. }
  821. #endif
  822. #endif /* __STM32F7xx_HAL_SMARTCARD_H */
  823. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/