mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32L1/device/stm32l1xx_hal_smartcard.h@189:f392fc9709a3, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 22:31:08 2019 +0000
- Revision:
- 189:f392fc9709a3
- Parent:
- 184:08ed48f1de7f
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 149:156823d33999 | 1 | /** |
<> | 149:156823d33999 | 2 | ****************************************************************************** |
<> | 149:156823d33999 | 3 | * @file stm32l1xx_hal_smartcard.h |
<> | 149:156823d33999 | 4 | * @author MCD Application Team |
<> | 149:156823d33999 | 5 | * @brief This file contains all the functions prototypes for the SMARTCARD |
<> | 149:156823d33999 | 6 | * firmware library. |
<> | 149:156823d33999 | 7 | ****************************************************************************** |
<> | 149:156823d33999 | 8 | * @attention |
<> | 149:156823d33999 | 9 | * |
AnnaBridge | 184:08ed48f1de7f | 10 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
<> | 149:156823d33999 | 11 | * |
<> | 149:156823d33999 | 12 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 149:156823d33999 | 13 | * are permitted provided that the following conditions are met: |
<> | 149:156823d33999 | 14 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 149:156823d33999 | 15 | * this list of conditions and the following disclaimer. |
<> | 149:156823d33999 | 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 149:156823d33999 | 17 | * this list of conditions and the following disclaimer in the documentation |
<> | 149:156823d33999 | 18 | * and/or other materials provided with the distribution. |
<> | 149:156823d33999 | 19 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 149:156823d33999 | 20 | * may be used to endorse or promote products derived from this software |
<> | 149:156823d33999 | 21 | * without specific prior written permission. |
<> | 149:156823d33999 | 22 | * |
<> | 149:156823d33999 | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 149:156823d33999 | 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 149:156823d33999 | 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 149:156823d33999 | 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 149:156823d33999 | 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 149:156823d33999 | 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 149:156823d33999 | 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 149:156823d33999 | 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 149:156823d33999 | 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 149:156823d33999 | 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 149:156823d33999 | 33 | * |
<> | 149:156823d33999 | 34 | ****************************************************************************** |
<> | 149:156823d33999 | 35 | */ |
<> | 149:156823d33999 | 36 | |
<> | 149:156823d33999 | 37 | /* Define to prevent recursive inclusion -------------------------------------*/ |
<> | 149:156823d33999 | 38 | #ifndef __STM32L1xx_HAL_SMARTCARD_H |
<> | 149:156823d33999 | 39 | #define __STM32L1xx_HAL_SMARTCARD_H |
<> | 149:156823d33999 | 40 | |
<> | 149:156823d33999 | 41 | #ifdef __cplusplus |
<> | 149:156823d33999 | 42 | extern "C" { |
<> | 149:156823d33999 | 43 | #endif |
<> | 149:156823d33999 | 44 | |
<> | 149:156823d33999 | 45 | /* Includes ------------------------------------------------------------------*/ |
<> | 149:156823d33999 | 46 | #include "stm32l1xx_hal_def.h" |
<> | 149:156823d33999 | 47 | |
<> | 149:156823d33999 | 48 | /** @addtogroup STM32L1xx_HAL_Driver |
<> | 149:156823d33999 | 49 | * @{ |
<> | 149:156823d33999 | 50 | */ |
<> | 149:156823d33999 | 51 | |
<> | 149:156823d33999 | 52 | /** @addtogroup SMARTCARD |
<> | 149:156823d33999 | 53 | * @{ |
<> | 149:156823d33999 | 54 | */ |
<> | 149:156823d33999 | 55 | |
<> | 149:156823d33999 | 56 | /* Exported types ------------------------------------------------------------*/ |
<> | 149:156823d33999 | 57 | /** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types |
<> | 149:156823d33999 | 58 | * @{ |
<> | 149:156823d33999 | 59 | */ |
<> | 149:156823d33999 | 60 | |
<> | 149:156823d33999 | 61 | |
<> | 149:156823d33999 | 62 | /** |
<> | 149:156823d33999 | 63 | * @brief SMARTCARD Init Structure definition |
<> | 149:156823d33999 | 64 | */ |
<> | 149:156823d33999 | 65 | typedef struct |
<> | 149:156823d33999 | 66 | { |
<> | 149:156823d33999 | 67 | uint32_t BaudRate; /*!< This member configures the SmartCard communication baud rate. |
<> | 149:156823d33999 | 68 | The baud rate is computed using the following formula: |
<> | 149:156823d33999 | 69 | - IntegerDivider = ((PCLKx) / (16 * (hsmartcard->Init.BaudRate))) |
<> | 149:156823d33999 | 70 | - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */ |
<> | 149:156823d33999 | 71 | |
<> | 149:156823d33999 | 72 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
<> | 149:156823d33999 | 73 | This parameter can be a value of @ref SMARTCARD_Word_Length */ |
<> | 149:156823d33999 | 74 | |
<> | 149:156823d33999 | 75 | uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. |
<> | 149:156823d33999 | 76 | This parameter can be a value of @ref SMARTCARD_Stop_Bits */ |
<> | 149:156823d33999 | 77 | |
<> | 149:156823d33999 | 78 | uint32_t Parity; /*!< Specifies the parity mode. |
<> | 149:156823d33999 | 79 | This parameter can be a value of @ref SMARTCARD_Parity |
<> | 149:156823d33999 | 80 | @note When parity is enabled, the computed parity is inserted |
<> | 149:156823d33999 | 81 | at the MSB position of the transmitted data (9th bit when |
<> | 149:156823d33999 | 82 | the word length is set to 9 data bits; 8th bit when the |
<> | 149:156823d33999 | 83 | word length is set to 8 data bits).*/ |
<> | 149:156823d33999 | 84 | |
<> | 149:156823d33999 | 85 | uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. |
<> | 149:156823d33999 | 86 | This parameter can be a value of @ref SMARTCARD_Mode */ |
<> | 149:156823d33999 | 87 | |
<> | 149:156823d33999 | 88 | uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. |
<> | 149:156823d33999 | 89 | This parameter can be a value of @ref SMARTCARD_Clock_Polarity */ |
<> | 149:156823d33999 | 90 | |
<> | 149:156823d33999 | 91 | uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. |
<> | 149:156823d33999 | 92 | This parameter can be a value of @ref SMARTCARD_Clock_Phase */ |
<> | 149:156823d33999 | 93 | |
<> | 149:156823d33999 | 94 | uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
<> | 149:156823d33999 | 95 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
<> | 149:156823d33999 | 96 | This parameter can be a value of @ref SMARTCARD_Last_Bit */ |
<> | 149:156823d33999 | 97 | |
<> | 149:156823d33999 | 98 | uint32_t Prescaler; /*!< Specifies the SmartCard Prescaler value used for dividing the system clock |
<> | 149:156823d33999 | 99 | to provide the smartcard clock. The value given in the register |
<> | 149:156823d33999 | 100 | (5 significant bits) is multiplied by 2 to give the division factor of |
<> | 149:156823d33999 | 101 | the source clock frequency; |
<> | 149:156823d33999 | 102 | This parameter can be a value of @ref SMARTCARD_Prescaler */ |
<> | 149:156823d33999 | 103 | |
<> | 149:156823d33999 | 104 | uint32_t GuardTime; /*!< Specifies the SmartCard Guard Time value in terms of number |
<> | 149:156823d33999 | 105 | of baud clocks */ |
<> | 149:156823d33999 | 106 | |
<> | 149:156823d33999 | 107 | uint32_t NACKState; /*!< Specifies the SmartCard NACK Transmission state |
<> | 149:156823d33999 | 108 | This parameter can be a value of @ref SMARTCARD_NACK_State */ |
<> | 149:156823d33999 | 109 | }SMARTCARD_InitTypeDef; |
<> | 149:156823d33999 | 110 | |
<> | 149:156823d33999 | 111 | /** |
<> | 149:156823d33999 | 112 | * @brief HAL State structures definition |
<> | 149:156823d33999 | 113 | */ |
<> | 149:156823d33999 | 114 | typedef enum |
<> | 149:156823d33999 | 115 | { |
<> | 149:156823d33999 | 116 | HAL_SMARTCARD_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ |
<> | 149:156823d33999 | 117 | HAL_SMARTCARD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
<> | 149:156823d33999 | 118 | HAL_SMARTCARD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
<> | 149:156823d33999 | 119 | HAL_SMARTCARD_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
<> | 149:156823d33999 | 120 | HAL_SMARTCARD_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
<> | 149:156823d33999 | 121 | HAL_SMARTCARD_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ |
<> | 149:156823d33999 | 122 | HAL_SMARTCARD_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
<> | 149:156823d33999 | 123 | HAL_SMARTCARD_STATE_ERROR = 0x04 /*!< Error */ |
<> | 149:156823d33999 | 124 | }HAL_SMARTCARD_StateTypeDef; |
<> | 149:156823d33999 | 125 | |
<> | 149:156823d33999 | 126 | |
<> | 149:156823d33999 | 127 | /** |
<> | 149:156823d33999 | 128 | * @brief SMARTCARD handle Structure definition |
<> | 149:156823d33999 | 129 | */ |
<> | 149:156823d33999 | 130 | typedef struct |
<> | 149:156823d33999 | 131 | { |
<> | 149:156823d33999 | 132 | USART_TypeDef *Instance; /*!< USART registers base address */ |
<> | 149:156823d33999 | 133 | |
<> | 149:156823d33999 | 134 | SMARTCARD_InitTypeDef Init; /*!< SmartCard communication parameters */ |
<> | 149:156823d33999 | 135 | |
<> | 149:156823d33999 | 136 | uint8_t *pTxBuffPtr; /*!< Pointer to SmartCard Tx transfer Buffer */ |
<> | 149:156823d33999 | 137 | |
<> | 149:156823d33999 | 138 | uint16_t TxXferSize; /*!< SmartCard Tx Transfer size */ |
<> | 149:156823d33999 | 139 | |
<> | 149:156823d33999 | 140 | uint16_t TxXferCount; /*!< SmartCard Tx Transfer Counter */ |
<> | 149:156823d33999 | 141 | |
<> | 149:156823d33999 | 142 | uint8_t *pRxBuffPtr; /*!< Pointer to SmartCard Rx transfer Buffer */ |
<> | 149:156823d33999 | 143 | |
<> | 149:156823d33999 | 144 | uint16_t RxXferSize; /*!< SmartCard Rx Transfer size */ |
<> | 149:156823d33999 | 145 | |
<> | 149:156823d33999 | 146 | uint16_t RxXferCount; /*!< SmartCard Rx Transfer Counter */ |
<> | 149:156823d33999 | 147 | |
<> | 149:156823d33999 | 148 | DMA_HandleTypeDef *hdmatx; /*!< SmartCard Tx DMA Handle parameters */ |
<> | 149:156823d33999 | 149 | |
<> | 149:156823d33999 | 150 | DMA_HandleTypeDef *hdmarx; /*!< SmartCard Rx DMA Handle parameters */ |
<> | 149:156823d33999 | 151 | |
<> | 149:156823d33999 | 152 | HAL_LockTypeDef Lock; /*!< Locking object */ |
<> | 149:156823d33999 | 153 | |
<> | 149:156823d33999 | 154 | __IO HAL_SMARTCARD_StateTypeDef State; /*!< SmartCard communication state */ |
<> | 149:156823d33999 | 155 | |
<> | 149:156823d33999 | 156 | __IO uint32_t ErrorCode; /*!< SmartCard Error code */ |
<> | 149:156823d33999 | 157 | }SMARTCARD_HandleTypeDef; |
<> | 149:156823d33999 | 158 | |
<> | 149:156823d33999 | 159 | /** |
<> | 149:156823d33999 | 160 | * @} |
<> | 149:156823d33999 | 161 | */ |
<> | 149:156823d33999 | 162 | |
<> | 149:156823d33999 | 163 | /* Exported constants --------------------------------------------------------*/ |
<> | 149:156823d33999 | 164 | /** @defgroup SMARTCARD_Exported_Constants SMARTCARD Exported constants |
<> | 149:156823d33999 | 165 | * @{ |
<> | 149:156823d33999 | 166 | */ |
<> | 149:156823d33999 | 167 | |
<> | 149:156823d33999 | 168 | /** @defgroup SMARTCARD_Error_Codes SMARTCARD Error Codes |
<> | 149:156823d33999 | 169 | * @{ |
<> | 149:156823d33999 | 170 | */ |
AnnaBridge | 184:08ed48f1de7f | 171 | #define HAL_SMARTCARD_ERROR_NONE (0x00U) /*!< No error */ |
AnnaBridge | 184:08ed48f1de7f | 172 | #define HAL_SMARTCARD_ERROR_PE (0x01U) /*!< Parity error */ |
AnnaBridge | 184:08ed48f1de7f | 173 | #define HAL_SMARTCARD_ERROR_NE (0x02U) /*!< Noise error */ |
AnnaBridge | 184:08ed48f1de7f | 174 | #define HAL_SMARTCARD_ERROR_FE (0x04U) /*!< frame error */ |
AnnaBridge | 184:08ed48f1de7f | 175 | #define HAL_SMARTCARD_ERROR_ORE (0x08U) /*!< Overrun error */ |
AnnaBridge | 184:08ed48f1de7f | 176 | #define HAL_SMARTCARD_ERROR_DMA (0x10U) /*!< DMA transfer error */ |
<> | 149:156823d33999 | 177 | |
<> | 149:156823d33999 | 178 | /** |
<> | 149:156823d33999 | 179 | * @} |
<> | 149:156823d33999 | 180 | */ |
<> | 149:156823d33999 | 181 | |
<> | 149:156823d33999 | 182 | |
<> | 149:156823d33999 | 183 | /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length |
<> | 149:156823d33999 | 184 | * @{ |
<> | 149:156823d33999 | 185 | */ |
<> | 149:156823d33999 | 186 | #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M) |
<> | 149:156823d33999 | 187 | |
<> | 149:156823d33999 | 188 | /** |
<> | 149:156823d33999 | 189 | * @} |
<> | 149:156823d33999 | 190 | */ |
<> | 149:156823d33999 | 191 | |
<> | 149:156823d33999 | 192 | /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits |
<> | 149:156823d33999 | 193 | * @{ |
<> | 149:156823d33999 | 194 | */ |
<> | 149:156823d33999 | 195 | #define SMARTCARD_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) |
<> | 149:156823d33999 | 196 | #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) |
<> | 149:156823d33999 | 197 | /** |
<> | 149:156823d33999 | 198 | * @} |
<> | 149:156823d33999 | 199 | */ |
<> | 149:156823d33999 | 200 | |
<> | 149:156823d33999 | 201 | /** @defgroup SMARTCARD_Parity SMARTCARD Parity |
<> | 149:156823d33999 | 202 | * @{ |
<> | 149:156823d33999 | 203 | */ |
<> | 149:156823d33999 | 204 | #define SMARTCARD_PARITY_EVEN ((uint32_t)USART_CR1_PCE) |
<> | 149:156823d33999 | 205 | #define SMARTCARD_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) |
<> | 149:156823d33999 | 206 | /** |
<> | 149:156823d33999 | 207 | * @} |
<> | 149:156823d33999 | 208 | */ |
<> | 149:156823d33999 | 209 | |
<> | 149:156823d33999 | 210 | /** @defgroup SMARTCARD_Mode SMARTCARD Mode |
<> | 149:156823d33999 | 211 | * @{ |
<> | 149:156823d33999 | 212 | */ |
<> | 149:156823d33999 | 213 | #define SMARTCARD_MODE_RX ((uint32_t)USART_CR1_RE) |
<> | 149:156823d33999 | 214 | #define SMARTCARD_MODE_TX ((uint32_t)USART_CR1_TE) |
<> | 149:156823d33999 | 215 | #define SMARTCARD_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) |
<> | 149:156823d33999 | 216 | /** |
<> | 149:156823d33999 | 217 | * @} |
<> | 149:156823d33999 | 218 | */ |
<> | 149:156823d33999 | 219 | |
<> | 149:156823d33999 | 220 | /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity |
<> | 149:156823d33999 | 221 | * @{ |
<> | 149:156823d33999 | 222 | */ |
AnnaBridge | 184:08ed48f1de7f | 223 | #define SMARTCARD_POLARITY_LOW (0x00000000U) |
<> | 149:156823d33999 | 224 | #define SMARTCARD_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) |
<> | 149:156823d33999 | 225 | /** |
<> | 149:156823d33999 | 226 | * @} |
<> | 149:156823d33999 | 227 | */ |
<> | 149:156823d33999 | 228 | |
<> | 149:156823d33999 | 229 | /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase |
<> | 149:156823d33999 | 230 | * @{ |
<> | 149:156823d33999 | 231 | */ |
AnnaBridge | 184:08ed48f1de7f | 232 | #define SMARTCARD_PHASE_1EDGE (0x00000000U) |
<> | 149:156823d33999 | 233 | #define SMARTCARD_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) |
<> | 149:156823d33999 | 234 | /** |
<> | 149:156823d33999 | 235 | * @} |
<> | 149:156823d33999 | 236 | */ |
<> | 149:156823d33999 | 237 | |
<> | 149:156823d33999 | 238 | /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit |
<> | 149:156823d33999 | 239 | * @{ |
<> | 149:156823d33999 | 240 | */ |
AnnaBridge | 184:08ed48f1de7f | 241 | #define SMARTCARD_LASTBIT_DISABLE (0x00000000U) |
<> | 149:156823d33999 | 242 | #define SMARTCARD_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) |
<> | 149:156823d33999 | 243 | /** |
<> | 149:156823d33999 | 244 | * @} |
<> | 149:156823d33999 | 245 | */ |
<> | 149:156823d33999 | 246 | |
<> | 149:156823d33999 | 247 | /** @defgroup SMARTCARD_OneBit_Sampling SMARTCARD One Bit Sampling Method |
<> | 149:156823d33999 | 248 | * @{ |
<> | 149:156823d33999 | 249 | */ |
AnnaBridge | 184:08ed48f1de7f | 250 | #define SMARTCARD_ONE_BIT_SAMPLE_DISABLE (0x00000000U) |
<> | 149:156823d33999 | 251 | #define SMARTCARD_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT) |
<> | 149:156823d33999 | 252 | /** |
<> | 149:156823d33999 | 253 | * @} |
<> | 149:156823d33999 | 254 | */ |
<> | 149:156823d33999 | 255 | |
<> | 149:156823d33999 | 256 | /** @defgroup SMARTCARD_NACK_State SMARTCARD NACK State |
<> | 149:156823d33999 | 257 | * @{ |
<> | 149:156823d33999 | 258 | */ |
<> | 149:156823d33999 | 259 | #define SMARTCARD_NACK_ENABLE ((uint32_t)USART_CR3_NACK) |
AnnaBridge | 184:08ed48f1de7f | 260 | #define SMARTCARD_NACK_DISABLE (0x00000000U) |
<> | 149:156823d33999 | 261 | /** |
<> | 149:156823d33999 | 262 | * @} |
<> | 149:156823d33999 | 263 | */ |
<> | 149:156823d33999 | 264 | |
<> | 149:156823d33999 | 265 | /** @defgroup SMARTCARD_DMA_Requests SMARTCARD DMA requests |
<> | 149:156823d33999 | 266 | * @{ |
<> | 149:156823d33999 | 267 | */ |
<> | 149:156823d33999 | 268 | |
<> | 149:156823d33999 | 269 | #define SMARTCARD_DMAREQ_TX ((uint32_t)USART_CR3_DMAT) |
<> | 149:156823d33999 | 270 | #define SMARTCARD_DMAREQ_RX ((uint32_t)USART_CR3_DMAR) |
<> | 149:156823d33999 | 271 | |
<> | 149:156823d33999 | 272 | /** |
<> | 149:156823d33999 | 273 | * @} |
<> | 149:156823d33999 | 274 | */ |
<> | 149:156823d33999 | 275 | |
<> | 149:156823d33999 | 276 | /** @defgroup SMARTCARD_Prescaler SMARTCARD Prescaler |
<> | 149:156823d33999 | 277 | * @{ |
<> | 149:156823d33999 | 278 | */ |
AnnaBridge | 184:08ed48f1de7f | 279 | #define SMARTCARD_PRESCALER_SYSCLK_DIV2 (0x00000001U) /*!< SYSCLK divided by 2 */ |
AnnaBridge | 184:08ed48f1de7f | 280 | #define SMARTCARD_PRESCALER_SYSCLK_DIV4 (0x00000002U) /*!< SYSCLK divided by 4 */ |
AnnaBridge | 184:08ed48f1de7f | 281 | #define SMARTCARD_PRESCALER_SYSCLK_DIV6 (0x00000003U) /*!< SYSCLK divided by 6 */ |
AnnaBridge | 184:08ed48f1de7f | 282 | #define SMARTCARD_PRESCALER_SYSCLK_DIV8 (0x00000004U) /*!< SYSCLK divided by 8 */ |
AnnaBridge | 184:08ed48f1de7f | 283 | #define SMARTCARD_PRESCALER_SYSCLK_DIV10 (0x00000005U) /*!< SYSCLK divided by 10 */ |
AnnaBridge | 184:08ed48f1de7f | 284 | #define SMARTCARD_PRESCALER_SYSCLK_DIV12 (0x00000006U) /*!< SYSCLK divided by 12 */ |
AnnaBridge | 184:08ed48f1de7f | 285 | #define SMARTCARD_PRESCALER_SYSCLK_DIV14 (0x00000007U) /*!< SYSCLK divided by 14 */ |
AnnaBridge | 184:08ed48f1de7f | 286 | #define SMARTCARD_PRESCALER_SYSCLK_DIV16 (0x00000008U) /*!< SYSCLK divided by 16 */ |
AnnaBridge | 184:08ed48f1de7f | 287 | #define SMARTCARD_PRESCALER_SYSCLK_DIV18 (0x00000009U) /*!< SYSCLK divided by 18 */ |
AnnaBridge | 184:08ed48f1de7f | 288 | #define SMARTCARD_PRESCALER_SYSCLK_DIV20 (0x0000000AU) /*!< SYSCLK divided by 20 */ |
AnnaBridge | 184:08ed48f1de7f | 289 | #define SMARTCARD_PRESCALER_SYSCLK_DIV22 (0x0000000BU) /*!< SYSCLK divided by 22 */ |
AnnaBridge | 184:08ed48f1de7f | 290 | #define SMARTCARD_PRESCALER_SYSCLK_DIV24 (0x0000000CU) /*!< SYSCLK divided by 24 */ |
AnnaBridge | 184:08ed48f1de7f | 291 | #define SMARTCARD_PRESCALER_SYSCLK_DIV26 (0x0000000DU) /*!< SYSCLK divided by 26 */ |
AnnaBridge | 184:08ed48f1de7f | 292 | #define SMARTCARD_PRESCALER_SYSCLK_DIV28 (0x0000000EU) /*!< SYSCLK divided by 28 */ |
AnnaBridge | 184:08ed48f1de7f | 293 | #define SMARTCARD_PRESCALER_SYSCLK_DIV30 (0x0000000FU) /*!< SYSCLK divided by 30 */ |
AnnaBridge | 184:08ed48f1de7f | 294 | #define SMARTCARD_PRESCALER_SYSCLK_DIV32 (0x00000010U) /*!< SYSCLK divided by 32 */ |
AnnaBridge | 184:08ed48f1de7f | 295 | #define SMARTCARD_PRESCALER_SYSCLK_DIV34 (0x00000011U) /*!< SYSCLK divided by 34 */ |
AnnaBridge | 184:08ed48f1de7f | 296 | #define SMARTCARD_PRESCALER_SYSCLK_DIV36 (0x00000012U) /*!< SYSCLK divided by 36 */ |
AnnaBridge | 184:08ed48f1de7f | 297 | #define SMARTCARD_PRESCALER_SYSCLK_DIV38 (0x00000013U) /*!< SYSCLK divided by 38 */ |
AnnaBridge | 184:08ed48f1de7f | 298 | #define SMARTCARD_PRESCALER_SYSCLK_DIV40 (0x00000014U) /*!< SYSCLK divided by 40 */ |
AnnaBridge | 184:08ed48f1de7f | 299 | #define SMARTCARD_PRESCALER_SYSCLK_DIV42 (0x00000015U) /*!< SYSCLK divided by 42 */ |
AnnaBridge | 184:08ed48f1de7f | 300 | #define SMARTCARD_PRESCALER_SYSCLK_DIV44 (0x00000016U) /*!< SYSCLK divided by 44 */ |
AnnaBridge | 184:08ed48f1de7f | 301 | #define SMARTCARD_PRESCALER_SYSCLK_DIV46 (0x00000017U) /*!< SYSCLK divided by 46 */ |
AnnaBridge | 184:08ed48f1de7f | 302 | #define SMARTCARD_PRESCALER_SYSCLK_DIV48 (0x00000018U) /*!< SYSCLK divided by 48 */ |
AnnaBridge | 184:08ed48f1de7f | 303 | #define SMARTCARD_PRESCALER_SYSCLK_DIV50 (0x00000019U) /*!< SYSCLK divided by 50 */ |
AnnaBridge | 184:08ed48f1de7f | 304 | #define SMARTCARD_PRESCALER_SYSCLK_DIV52 (0x0000001AU) /*!< SYSCLK divided by 52 */ |
AnnaBridge | 184:08ed48f1de7f | 305 | #define SMARTCARD_PRESCALER_SYSCLK_DIV54 (0x0000001BU) /*!< SYSCLK divided by 54 */ |
AnnaBridge | 184:08ed48f1de7f | 306 | #define SMARTCARD_PRESCALER_SYSCLK_DIV56 (0x0000001CU) /*!< SYSCLK divided by 56 */ |
AnnaBridge | 184:08ed48f1de7f | 307 | #define SMARTCARD_PRESCALER_SYSCLK_DIV58 (0x0000001DU) /*!< SYSCLK divided by 58 */ |
AnnaBridge | 184:08ed48f1de7f | 308 | #define SMARTCARD_PRESCALER_SYSCLK_DIV60 (0x0000001EU) /*!< SYSCLK divided by 60 */ |
AnnaBridge | 184:08ed48f1de7f | 309 | #define SMARTCARD_PRESCALER_SYSCLK_DIV62 (0x0000001FU) /*!< SYSCLK divided by 62 */ |
<> | 149:156823d33999 | 310 | /** |
<> | 149:156823d33999 | 311 | * @} |
<> | 149:156823d33999 | 312 | */ |
<> | 149:156823d33999 | 313 | |
<> | 149:156823d33999 | 314 | |
<> | 149:156823d33999 | 315 | |
<> | 149:156823d33999 | 316 | /** @defgroup SMARTCARD_Flags SMARTCARD Flags |
<> | 149:156823d33999 | 317 | * Elements values convention: 0xXXXX |
<> | 149:156823d33999 | 318 | * - 0xXXXX : Flag mask in the SR register |
<> | 149:156823d33999 | 319 | * @{ |
<> | 149:156823d33999 | 320 | */ |
<> | 149:156823d33999 | 321 | |
<> | 149:156823d33999 | 322 | #define SMARTCARD_FLAG_TXE ((uint32_t)USART_SR_TXE) |
<> | 149:156823d33999 | 323 | #define SMARTCARD_FLAG_TC ((uint32_t)USART_SR_TC) |
<> | 149:156823d33999 | 324 | #define SMARTCARD_FLAG_RXNE ((uint32_t)USART_SR_RXNE) |
<> | 149:156823d33999 | 325 | #define SMARTCARD_FLAG_IDLE ((uint32_t)USART_SR_IDLE) |
<> | 149:156823d33999 | 326 | #define SMARTCARD_FLAG_ORE ((uint32_t)USART_SR_ORE) |
<> | 149:156823d33999 | 327 | #define SMARTCARD_FLAG_NE ((uint32_t)USART_SR_NE) |
<> | 149:156823d33999 | 328 | #define SMARTCARD_FLAG_FE ((uint32_t)USART_SR_FE) |
<> | 149:156823d33999 | 329 | #define SMARTCARD_FLAG_PE ((uint32_t)USART_SR_PE) |
<> | 149:156823d33999 | 330 | /** |
<> | 149:156823d33999 | 331 | * @} |
<> | 149:156823d33999 | 332 | */ |
<> | 149:156823d33999 | 333 | |
<> | 149:156823d33999 | 334 | /** @defgroup SMARTCARD_Interrupt_definition SMARTCARD Interrupts Definition |
<> | 149:156823d33999 | 335 | * Elements values convention: 0xY000XXXX |
<> | 149:156823d33999 | 336 | * - XXXX : Interrupt mask (16 bits) in the Y register |
<> | 149:156823d33999 | 337 | * - Y : Interrupt source register (4 bits) |
<> | 149:156823d33999 | 338 | * - 0001: CR1 register |
<> | 149:156823d33999 | 339 | * - 0010: CR3 register |
<> | 149:156823d33999 | 340 | |
<> | 149:156823d33999 | 341 | * |
<> | 149:156823d33999 | 342 | * @{ |
<> | 149:156823d33999 | 343 | */ |
<> | 149:156823d33999 | 344 | |
<> | 149:156823d33999 | 345 | #define SMARTCARD_IT_PE ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28 | USART_CR1_PEIE)) |
<> | 149:156823d33999 | 346 | #define SMARTCARD_IT_TXE ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28 | USART_CR1_TXEIE)) |
<> | 149:156823d33999 | 347 | #define SMARTCARD_IT_TC ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28 | USART_CR1_TCIE)) |
<> | 149:156823d33999 | 348 | #define SMARTCARD_IT_RXNE ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28 | USART_CR1_RXNEIE)) |
<> | 149:156823d33999 | 349 | #define SMARTCARD_IT_IDLE ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28 | USART_CR1_IDLEIE)) |
<> | 149:156823d33999 | 350 | #define SMARTCARD_IT_ERR ((uint32_t)(SMARTCARD_CR3_REG_INDEX << 28 | USART_CR3_EIE)) |
<> | 149:156823d33999 | 351 | |
<> | 149:156823d33999 | 352 | /** |
<> | 149:156823d33999 | 353 | * @} |
<> | 149:156823d33999 | 354 | */ |
<> | 149:156823d33999 | 355 | |
<> | 149:156823d33999 | 356 | /** |
<> | 149:156823d33999 | 357 | * @} |
<> | 149:156823d33999 | 358 | */ |
<> | 149:156823d33999 | 359 | |
<> | 149:156823d33999 | 360 | |
<> | 149:156823d33999 | 361 | /* Exported macro ------------------------------------------------------------*/ |
<> | 149:156823d33999 | 362 | /** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros |
<> | 149:156823d33999 | 363 | * @{ |
<> | 149:156823d33999 | 364 | */ |
<> | 149:156823d33999 | 365 | |
<> | 149:156823d33999 | 366 | |
<> | 149:156823d33999 | 367 | /** @brief Reset SMARTCARD handle state |
<> | 149:156823d33999 | 368 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 369 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 370 | * @retval None |
<> | 149:156823d33999 | 371 | */ |
<> | 149:156823d33999 | 372 | #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMARTCARD_STATE_RESET) |
<> | 149:156823d33999 | 373 | |
<> | 149:156823d33999 | 374 | /** @brief Flush the Smartcard DR register |
<> | 149:156823d33999 | 375 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 376 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 377 | * @retval None |
<> | 149:156823d33999 | 378 | */ |
<> | 149:156823d33999 | 379 | #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) |
<> | 149:156823d33999 | 380 | |
<> | 149:156823d33999 | 381 | /** @brief Check whether the specified Smartcard flag is set or not. |
<> | 149:156823d33999 | 382 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 383 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 384 | * @param __FLAG__: specifies the flag to check. |
<> | 149:156823d33999 | 385 | * This parameter can be one of the following values: |
<> | 149:156823d33999 | 386 | * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag |
<> | 149:156823d33999 | 387 | * @arg SMARTCARD_FLAG_TC: Transmission Complete flag |
<> | 149:156823d33999 | 388 | * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag |
<> | 149:156823d33999 | 389 | * @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag |
<> | 149:156823d33999 | 390 | * @arg SMARTCARD_FLAG_ORE: OverRun Error flag |
<> | 149:156823d33999 | 391 | * @arg SMARTCARD_FLAG_NE: Noise Error flag |
<> | 149:156823d33999 | 392 | * @arg SMARTCARD_FLAG_FE: Framing Error flag |
<> | 149:156823d33999 | 393 | * @arg SMARTCARD_FLAG_PE: Parity Error flag |
<> | 149:156823d33999 | 394 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
<> | 149:156823d33999 | 395 | */ |
<> | 149:156823d33999 | 396 | #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
<> | 149:156823d33999 | 397 | |
<> | 149:156823d33999 | 398 | /** @brief Clear the specified Smartcard pending flags. |
<> | 149:156823d33999 | 399 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 400 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 401 | * @param __FLAG__: specifies the flag to check. |
<> | 149:156823d33999 | 402 | * This parameter can be any combination of the following values: |
<> | 149:156823d33999 | 403 | * @arg SMARTCARD_FLAG_TC: Transmission Complete flag. |
<> | 149:156823d33999 | 404 | * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag. |
<> | 149:156823d33999 | 405 | * @retval None |
<> | 149:156823d33999 | 406 | * |
<> | 149:156823d33999 | 407 | * @note PE (Parity error), FE (Framing error), NE (Noise error) and ORE (OverRun |
<> | 149:156823d33999 | 408 | * error) flags are cleared by software sequence: a read operation to |
<> | 149:156823d33999 | 409 | * USART_SR register followed by a read operation to USART_DR register. |
<> | 149:156823d33999 | 410 | * @note RXNE flag can be also cleared by a read to the USART_DR register. |
<> | 149:156823d33999 | 411 | * @note TC flag can be also cleared by software sequence: a read operation to |
<> | 149:156823d33999 | 412 | * USART_SR register followed by a write operation to USART_DR register. |
<> | 149:156823d33999 | 413 | * @note TXE flag is cleared only by a write to the USART_DR register. |
<> | 149:156823d33999 | 414 | * |
<> | 149:156823d33999 | 415 | * @retval None |
<> | 149:156823d33999 | 416 | */ |
<> | 149:156823d33999 | 417 | #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) |
<> | 149:156823d33999 | 418 | |
<> | 149:156823d33999 | 419 | /** @brief Clear the SMARTCARD PE pending flag. |
<> | 149:156823d33999 | 420 | * @param __HANDLE__: specifies the USART Handle. |
<> | 149:156823d33999 | 421 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 422 | * @retval None |
<> | 149:156823d33999 | 423 | */ |
<> | 149:156823d33999 | 424 | #define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) \ |
<> | 149:156823d33999 | 425 | do{ \ |
<> | 149:156823d33999 | 426 | __IO uint32_t tmpreg; \ |
<> | 149:156823d33999 | 427 | tmpreg = (__HANDLE__)->Instance->SR; \ |
<> | 149:156823d33999 | 428 | tmpreg = (__HANDLE__)->Instance->DR; \ |
<> | 149:156823d33999 | 429 | UNUSED(tmpreg); \ |
<> | 149:156823d33999 | 430 | }while(0) |
<> | 149:156823d33999 | 431 | |
<> | 149:156823d33999 | 432 | |
<> | 149:156823d33999 | 433 | |
<> | 149:156823d33999 | 434 | /** @brief Clear the SMARTCARD FE pending flag. |
<> | 149:156823d33999 | 435 | * @param __HANDLE__: specifies the USART Handle. |
<> | 149:156823d33999 | 436 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 437 | * @retval None |
<> | 149:156823d33999 | 438 | */ |
<> | 149:156823d33999 | 439 | #define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) |
<> | 149:156823d33999 | 440 | |
<> | 149:156823d33999 | 441 | /** @brief Clear the SMARTCARD NE pending flag. |
<> | 149:156823d33999 | 442 | * @param __HANDLE__: specifies the USART Handle. |
<> | 149:156823d33999 | 443 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 444 | * @retval None |
<> | 149:156823d33999 | 445 | */ |
<> | 149:156823d33999 | 446 | #define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) |
<> | 149:156823d33999 | 447 | |
<> | 149:156823d33999 | 448 | /** @brief Clear the SMARTCARD ORE pending flag. |
<> | 149:156823d33999 | 449 | * @param __HANDLE__: specifies the USART Handle. |
<> | 149:156823d33999 | 450 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 451 | * @retval None |
<> | 149:156823d33999 | 452 | */ |
<> | 149:156823d33999 | 453 | #define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) |
<> | 149:156823d33999 | 454 | |
<> | 149:156823d33999 | 455 | /** @brief Clear the SMARTCARD IDLE pending flag. |
<> | 149:156823d33999 | 456 | * @param __HANDLE__: specifies the USART Handle. |
<> | 149:156823d33999 | 457 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 458 | * @retval None |
<> | 149:156823d33999 | 459 | */ |
<> | 149:156823d33999 | 460 | #define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) |
<> | 149:156823d33999 | 461 | |
<> | 149:156823d33999 | 462 | /** @brief Enable the specified SmartCard interrupt. |
<> | 149:156823d33999 | 463 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 464 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 465 | * @param __INTERRUPT__: specifies the SMARTCARD interrupt to enable. |
<> | 149:156823d33999 | 466 | * This parameter can be one of the following values: |
<> | 149:156823d33999 | 467 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
<> | 149:156823d33999 | 468 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
<> | 149:156823d33999 | 469 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
<> | 149:156823d33999 | 470 | * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt |
<> | 149:156823d33999 | 471 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
<> | 149:156823d33999 | 472 | * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
<> | 149:156823d33999 | 473 | * @retval None |
<> | 149:156823d33999 | 474 | */ |
<> | 149:156823d33999 | 475 | #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == SMARTCARD_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)): \ |
<> | 149:156823d33999 | 476 | ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK))) |
<> | 149:156823d33999 | 477 | |
<> | 149:156823d33999 | 478 | /** @brief Disable the specified SmartCard interrupts. |
<> | 149:156823d33999 | 479 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 480 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 481 | * @param __INTERRUPT__: specifies the SMARTCARD interrupt to disable. |
<> | 149:156823d33999 | 482 | * This parameter can be one of the following values: |
<> | 149:156823d33999 | 483 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
<> | 149:156823d33999 | 484 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
<> | 149:156823d33999 | 485 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
<> | 149:156823d33999 | 486 | * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt |
<> | 149:156823d33999 | 487 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
<> | 149:156823d33999 | 488 | * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
<> | 149:156823d33999 | 489 | */ |
<> | 149:156823d33999 | 490 | #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == SMARTCARD_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & SMARTCARD_IT_MASK)): \ |
<> | 149:156823d33999 | 491 | ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK))) |
<> | 149:156823d33999 | 492 | |
<> | 149:156823d33999 | 493 | /** @brief Check whether the specified SmartCard interrupt has occurred or not. |
<> | 149:156823d33999 | 494 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 495 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 496 | * @param __IT__: specifies the SMARTCARD interrupt source to check. |
<> | 149:156823d33999 | 497 | * This parameter can be one of the following values: |
<> | 149:156823d33999 | 498 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
<> | 149:156823d33999 | 499 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
<> | 149:156823d33999 | 500 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
<> | 149:156823d33999 | 501 | * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt |
<> | 149:156823d33999 | 502 | * @arg SMARTCARD_IT_ERR: Error interrupt |
<> | 149:156823d33999 | 503 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
<> | 149:156823d33999 | 504 | * @retval The new state of __IT__ (TRUE or FALSE). |
<> | 149:156823d33999 | 505 | */ |
<> | 149:156823d33999 | 506 | #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == SMARTCARD_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1: (__HANDLE__)->Instance->CR3) & (((uint32_t)(__IT__)) & SMARTCARD_IT_MASK)) |
<> | 149:156823d33999 | 507 | |
<> | 149:156823d33999 | 508 | /** @brief Enables the SMARTCARD one bit sample method |
<> | 149:156823d33999 | 509 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 510 | * @retval None |
<> | 149:156823d33999 | 511 | */ |
<> | 149:156823d33999 | 512 | #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR3, (USART_CR3_ONEBIT))) |
<> | 149:156823d33999 | 513 | |
<> | 149:156823d33999 | 514 | /** @brief Disables the SMARTCARD one bit sample method |
<> | 149:156823d33999 | 515 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 516 | * @retval None |
<> | 149:156823d33999 | 517 | */ |
<> | 149:156823d33999 | 518 | #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR3, (USART_CR3_ONEBIT))) |
<> | 149:156823d33999 | 519 | |
<> | 149:156823d33999 | 520 | /** @brief Enable the USART associated to the SMARTCARD Handle |
<> | 149:156823d33999 | 521 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 522 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 523 | * @retval None |
<> | 149:156823d33999 | 524 | */ |
<> | 149:156823d33999 | 525 | #define __HAL_SMARTCARD_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE)) |
<> | 149:156823d33999 | 526 | |
<> | 149:156823d33999 | 527 | /** @brief Disable the USART associated to the SMARTCARD Handle |
<> | 149:156823d33999 | 528 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
<> | 149:156823d33999 | 529 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 530 | * @retval None |
<> | 149:156823d33999 | 531 | */ |
<> | 149:156823d33999 | 532 | #define __HAL_SMARTCARD_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE)) |
<> | 149:156823d33999 | 533 | |
<> | 149:156823d33999 | 534 | /** @brief Enable the SmartCard DMA request. |
<> | 149:156823d33999 | 535 | * @param __HANDLE__: specifies the SmartCard Handle. |
<> | 149:156823d33999 | 536 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 537 | * @param __REQUEST__: specifies the SmartCard DMA request. |
<> | 149:156823d33999 | 538 | * This parameter can be one of the following values: |
<> | 149:156823d33999 | 539 | * @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request |
<> | 149:156823d33999 | 540 | * @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request |
<> | 149:156823d33999 | 541 | * @retval None |
<> | 149:156823d33999 | 542 | */ |
<> | 149:156823d33999 | 543 | #define __HAL_SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__) (SET_BIT((__HANDLE__)->Instance->CR3, (__REQUEST__))) |
<> | 149:156823d33999 | 544 | |
<> | 149:156823d33999 | 545 | /** @brief Disable the SmartCard DMA request. |
<> | 149:156823d33999 | 546 | * @param __HANDLE__: specifies the SmartCard Handle. |
<> | 149:156823d33999 | 547 | * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device). |
<> | 149:156823d33999 | 548 | * @param __REQUEST__: specifies the SmartCard DMA request. |
<> | 149:156823d33999 | 549 | * This parameter can be one of the following values: |
<> | 149:156823d33999 | 550 | * @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request |
<> | 149:156823d33999 | 551 | * @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request |
<> | 149:156823d33999 | 552 | * @retval None |
<> | 149:156823d33999 | 553 | */ |
<> | 149:156823d33999 | 554 | #define __HAL_SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__) (CLEAR_BIT((__HANDLE__)->Instance->CR3, (__REQUEST__))) |
<> | 149:156823d33999 | 555 | |
<> | 149:156823d33999 | 556 | |
<> | 149:156823d33999 | 557 | /** |
<> | 149:156823d33999 | 558 | * @} |
<> | 149:156823d33999 | 559 | */ |
<> | 149:156823d33999 | 560 | |
<> | 149:156823d33999 | 561 | |
<> | 149:156823d33999 | 562 | /* Private macros --------------------------------------------------------*/ |
<> | 149:156823d33999 | 563 | /** @defgroup SMARTCARD_Private_Macros SMARTCARD Private Macros |
<> | 149:156823d33999 | 564 | * @{ |
<> | 149:156823d33999 | 565 | */ |
<> | 149:156823d33999 | 566 | |
<> | 149:156823d33999 | 567 | #define SMARTCARD_CR1_REG_INDEX 1 |
<> | 149:156823d33999 | 568 | #define SMARTCARD_CR3_REG_INDEX 3 |
<> | 149:156823d33999 | 569 | |
<> | 149:156823d33999 | 570 | #define SMARTCARD_DIV(__PCLK__, __BAUD__) (((__PCLK__)*25)/(4*(__BAUD__))) |
<> | 149:156823d33999 | 571 | #define SMARTCARD_DIVMANT(__PCLK__, __BAUD__) (SMARTCARD_DIV((__PCLK__), (__BAUD__))/100) |
<> | 149:156823d33999 | 572 | #define SMARTCARD_DIVFRAQ(__PCLK__, __BAUD__) (((SMARTCARD_DIV((__PCLK__), (__BAUD__)) - (SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) * 100)) * 16 + 50) / 100) |
<> | 149:156823d33999 | 573 | /* UART BRR = mantissa + overflow + fraction |
<> | 149:156823d33999 | 574 | = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0F) */ |
<> | 149:156823d33999 | 575 | #define SMARTCARD_BRR(_PCLK_, _BAUD_) (((SMARTCARD_DIVMANT((_PCLK_), (_BAUD_)) << 4) + \ |
<> | 149:156823d33999 | 576 | (SMARTCARD_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0)) + \ |
<> | 149:156823d33999 | 577 | (SMARTCARD_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F)) |
<> | 149:156823d33999 | 578 | |
<> | 149:156823d33999 | 579 | /** Check the Baud rate range. |
<> | 149:156823d33999 | 580 | * The maximum Baud Rate is derived from the maximum clock on APB (i.e. 32 MHz) |
<> | 149:156823d33999 | 581 | * divided by the smallest oversampling used on the USART (i.e. 16) |
<> | 149:156823d33999 | 582 | * __BAUDRATE__: Baud rate set by the configuration function. |
<> | 149:156823d33999 | 583 | * Return : TRUE or FALSE |
<> | 149:156823d33999 | 584 | */ |
<> | 149:156823d33999 | 585 | #define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 2000001) |
<> | 149:156823d33999 | 586 | |
<> | 149:156823d33999 | 587 | #define IS_SMARTCARD_WORD_LENGTH(LENGTH) ((LENGTH) == SMARTCARD_WORDLENGTH_9B) |
<> | 149:156823d33999 | 588 | |
<> | 149:156823d33999 | 589 | #define IS_SMARTCARD_STOPBITS(STOPBITS) (((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \ |
<> | 149:156823d33999 | 590 | ((STOPBITS) == SMARTCARD_STOPBITS_1_5)) |
<> | 149:156823d33999 | 591 | |
<> | 149:156823d33999 | 592 | #define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_EVEN) || \ |
<> | 149:156823d33999 | 593 | ((PARITY) == SMARTCARD_PARITY_ODD)) |
<> | 149:156823d33999 | 594 | |
AnnaBridge | 184:08ed48f1de7f | 595 | #define IS_SMARTCARD_MODE(MODE) ((((MODE) & (~((uint32_t)SMARTCARD_MODE_TX_RX))) == 0x00U) && \ |
AnnaBridge | 184:08ed48f1de7f | 596 | ((MODE) != 0x00000000U)) |
<> | 149:156823d33999 | 597 | |
<> | 149:156823d33999 | 598 | #define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH)) |
<> | 149:156823d33999 | 599 | |
<> | 149:156823d33999 | 600 | #define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE)) |
<> | 149:156823d33999 | 601 | |
<> | 149:156823d33999 | 602 | #define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \ |
<> | 149:156823d33999 | 603 | ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE)) |
<> | 149:156823d33999 | 604 | |
<> | 149:156823d33999 | 605 | #define IS_SMARTCARD_ONE_BIT_SAMPLE(ONEBIT) (((ONEBIT) == SMARTCARD_ONE_BIT_SAMPLE_DISABLE) || \ |
<> | 149:156823d33999 | 606 | ((ONEBIT) == SMARTCARD_ONE_BIT_SAMPLE_ENABLE)) |
<> | 149:156823d33999 | 607 | |
<> | 149:156823d33999 | 608 | #define IS_SMARTCARD_NACK_STATE(NACK) (((NACK) == SMARTCARD_NACK_ENABLE) || \ |
<> | 149:156823d33999 | 609 | ((NACK) == SMARTCARD_NACK_DISABLE)) |
<> | 149:156823d33999 | 610 | |
<> | 149:156823d33999 | 611 | #define IS_SMARTCARD_PRESCALER(PRESCALER) (((PRESCALER) >= SMARTCARD_PRESCALER_SYSCLK_DIV2) && \ |
<> | 149:156823d33999 | 612 | ((PRESCALER) <= SMARTCARD_PRESCALER_SYSCLK_DIV62) ) |
<> | 149:156823d33999 | 613 | |
<> | 149:156823d33999 | 614 | /** SMARTCARD interruptions flag mask |
<> | 149:156823d33999 | 615 | * |
<> | 149:156823d33999 | 616 | */ |
<> | 149:156823d33999 | 617 | #define SMARTCARD_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \ |
<> | 149:156823d33999 | 618 | USART_CR1_IDLEIE | USART_CR3_EIE ) |
<> | 149:156823d33999 | 619 | |
<> | 149:156823d33999 | 620 | |
<> | 149:156823d33999 | 621 | /** |
<> | 149:156823d33999 | 622 | * @} |
<> | 149:156823d33999 | 623 | */ |
<> | 149:156823d33999 | 624 | |
<> | 149:156823d33999 | 625 | |
<> | 149:156823d33999 | 626 | /* Exported functions --------------------------------------------------------*/ |
<> | 149:156823d33999 | 627 | |
<> | 149:156823d33999 | 628 | /** @addtogroup SMARTCARD_Exported_Functions SMARTCARD Exported Functions |
<> | 149:156823d33999 | 629 | * @{ |
<> | 149:156823d33999 | 630 | */ |
<> | 149:156823d33999 | 631 | |
<> | 149:156823d33999 | 632 | /** @addtogroup SMARTCARD_Exported_Functions_Group1 Initialization and de-initialization functions |
<> | 149:156823d33999 | 633 | * @{ |
<> | 149:156823d33999 | 634 | */ |
<> | 149:156823d33999 | 635 | |
<> | 149:156823d33999 | 636 | /* Initialization/de-initialization functions **********************************/ |
<> | 149:156823d33999 | 637 | HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 638 | HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 639 | void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 640 | void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 641 | |
<> | 149:156823d33999 | 642 | /** |
<> | 149:156823d33999 | 643 | * @} |
<> | 149:156823d33999 | 644 | */ |
<> | 149:156823d33999 | 645 | |
<> | 149:156823d33999 | 646 | /** @addtogroup SMARTCARD_Exported_Functions_Group2 IO operation functions |
<> | 149:156823d33999 | 647 | * @{ |
<> | 149:156823d33999 | 648 | */ |
<> | 149:156823d33999 | 649 | |
<> | 149:156823d33999 | 650 | /* IO operation functions *******************************************************/ |
<> | 149:156823d33999 | 651 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
<> | 149:156823d33999 | 652 | HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
<> | 149:156823d33999 | 653 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
<> | 149:156823d33999 | 654 | HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
<> | 149:156823d33999 | 655 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
<> | 149:156823d33999 | 656 | HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
<> | 149:156823d33999 | 657 | void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 658 | void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 659 | void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 660 | void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 661 | |
<> | 149:156823d33999 | 662 | /** |
<> | 149:156823d33999 | 663 | * @} |
<> | 149:156823d33999 | 664 | */ |
<> | 149:156823d33999 | 665 | |
<> | 149:156823d33999 | 666 | /** @addtogroup SMARTCARD_Exported_Functions_Group3 Peripheral State and Errors functions |
<> | 149:156823d33999 | 667 | * @{ |
<> | 149:156823d33999 | 668 | */ |
<> | 149:156823d33999 | 669 | |
<> | 149:156823d33999 | 670 | /* Peripheral State and Errors functions functions *****************************/ |
<> | 149:156823d33999 | 671 | HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 672 | uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc); |
<> | 149:156823d33999 | 673 | |
<> | 149:156823d33999 | 674 | /** |
<> | 149:156823d33999 | 675 | * @} |
<> | 149:156823d33999 | 676 | */ |
<> | 149:156823d33999 | 677 | |
<> | 149:156823d33999 | 678 | /** |
<> | 149:156823d33999 | 679 | * @} |
<> | 149:156823d33999 | 680 | */ |
<> | 149:156823d33999 | 681 | |
<> | 149:156823d33999 | 682 | /** |
<> | 149:156823d33999 | 683 | * @} |
<> | 149:156823d33999 | 684 | */ |
<> | 149:156823d33999 | 685 | |
<> | 149:156823d33999 | 686 | /** |
<> | 149:156823d33999 | 687 | * @} |
<> | 149:156823d33999 | 688 | */ |
<> | 149:156823d33999 | 689 | |
<> | 149:156823d33999 | 690 | #ifdef __cplusplus |
<> | 149:156823d33999 | 691 | } |
<> | 149:156823d33999 | 692 | #endif |
<> | 149:156823d33999 | 693 | |
<> | 149:156823d33999 | 694 | #endif /* __STM32L1xx_HAL_SMARTCARD_H */ |
<> | 149:156823d33999 | 695 | |
<> | 149:156823d33999 | 696 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |