The official mbed C/C SDK provides the software platform and libraries to build your applications.
Fork of mbed by
TARGET_NUCLEO_F334R8/stm32f3xx_hal_smartcard.h@86:04dd9b1680ae, 2014-07-02 (annotated)
- Committer:
- bogdanm
- Date:
- Wed Jul 02 13:22:23 2014 +0100
- Revision:
- 86:04dd9b1680ae
- Child:
- 92:4fc01daae5a5
Release 86 of the mbed library
Main changes:
- bug fixes in various backends
- mbed "error" replaced by assert logic (mbed_assert)
- new ST Nucleo targets
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 86:04dd9b1680ae | 1 | /** |
bogdanm | 86:04dd9b1680ae | 2 | ****************************************************************************** |
bogdanm | 86:04dd9b1680ae | 3 | * @file stm32f3xx_hal_smartcard.h |
bogdanm | 86:04dd9b1680ae | 4 | * @author MCD Application Team |
bogdanm | 86:04dd9b1680ae | 5 | * @version V1.0.1 |
bogdanm | 86:04dd9b1680ae | 6 | * @date 18-June-2014 |
bogdanm | 86:04dd9b1680ae | 7 | * @brief Header file of SMARTCARD HAL module. |
bogdanm | 86:04dd9b1680ae | 8 | ****************************************************************************** |
bogdanm | 86:04dd9b1680ae | 9 | * @attention |
bogdanm | 86:04dd9b1680ae | 10 | * |
bogdanm | 86:04dd9b1680ae | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
bogdanm | 86:04dd9b1680ae | 12 | * |
bogdanm | 86:04dd9b1680ae | 13 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 86:04dd9b1680ae | 14 | * are permitted provided that the following conditions are met: |
bogdanm | 86:04dd9b1680ae | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 86:04dd9b1680ae | 16 | * this list of conditions and the following disclaimer. |
bogdanm | 86:04dd9b1680ae | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 86:04dd9b1680ae | 18 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 86:04dd9b1680ae | 19 | * and/or other materials provided with the distribution. |
bogdanm | 86:04dd9b1680ae | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 86:04dd9b1680ae | 21 | * may be used to endorse or promote products derived from this software |
bogdanm | 86:04dd9b1680ae | 22 | * without specific prior written permission. |
bogdanm | 86:04dd9b1680ae | 23 | * |
bogdanm | 86:04dd9b1680ae | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 86:04dd9b1680ae | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 86:04dd9b1680ae | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 86:04dd9b1680ae | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 86:04dd9b1680ae | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 86:04dd9b1680ae | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 86:04dd9b1680ae | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 86:04dd9b1680ae | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 86:04dd9b1680ae | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 86:04dd9b1680ae | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 86:04dd9b1680ae | 34 | * |
bogdanm | 86:04dd9b1680ae | 35 | ****************************************************************************** |
bogdanm | 86:04dd9b1680ae | 36 | */ |
bogdanm | 86:04dd9b1680ae | 37 | |
bogdanm | 86:04dd9b1680ae | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 86:04dd9b1680ae | 39 | #ifndef __STM32F3xx_HAL_SMARTCARD_H |
bogdanm | 86:04dd9b1680ae | 40 | #define __STM32F3xx_HAL_SMARTCARD_H |
bogdanm | 86:04dd9b1680ae | 41 | |
bogdanm | 86:04dd9b1680ae | 42 | #ifdef __cplusplus |
bogdanm | 86:04dd9b1680ae | 43 | extern "C" { |
bogdanm | 86:04dd9b1680ae | 44 | #endif |
bogdanm | 86:04dd9b1680ae | 45 | |
bogdanm | 86:04dd9b1680ae | 46 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 86:04dd9b1680ae | 47 | #include "stm32f3xx_hal_def.h" |
bogdanm | 86:04dd9b1680ae | 48 | |
bogdanm | 86:04dd9b1680ae | 49 | /** @addtogroup STM32F3xx_HAL_Driver |
bogdanm | 86:04dd9b1680ae | 50 | * @{ |
bogdanm | 86:04dd9b1680ae | 51 | */ |
bogdanm | 86:04dd9b1680ae | 52 | |
bogdanm | 86:04dd9b1680ae | 53 | /** @addtogroup SMARTCARD |
bogdanm | 86:04dd9b1680ae | 54 | * @{ |
bogdanm | 86:04dd9b1680ae | 55 | */ |
bogdanm | 86:04dd9b1680ae | 56 | |
bogdanm | 86:04dd9b1680ae | 57 | /* Exported types ------------------------------------------------------------*/ |
bogdanm | 86:04dd9b1680ae | 58 | /** |
bogdanm | 86:04dd9b1680ae | 59 | * @brief SMARTCARD Init Structure definition |
bogdanm | 86:04dd9b1680ae | 60 | */ |
bogdanm | 86:04dd9b1680ae | 61 | typedef struct |
bogdanm | 86:04dd9b1680ae | 62 | { |
bogdanm | 86:04dd9b1680ae | 63 | uint32_t BaudRate; /*!< Configures the SmartCard communication baud rate. |
bogdanm | 86:04dd9b1680ae | 64 | The baud rate register is computed using the following formula: |
bogdanm | 86:04dd9b1680ae | 65 | Baud Rate Register = ((PCLKx) / ((hsmartcard->Init.BaudRate))) */ |
bogdanm | 86:04dd9b1680ae | 66 | |
bogdanm | 86:04dd9b1680ae | 67 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
bogdanm | 86:04dd9b1680ae | 68 | This parameter @ref SMARTCARD_Word_Length can only be set to 9 (8 data + 1 parity bits). */ |
bogdanm | 86:04dd9b1680ae | 69 | |
bogdanm | 86:04dd9b1680ae | 70 | uint32_t StopBits; /*!< Specifies the number of stop bits @ref SMARTCARD_Stop_Bits. |
bogdanm | 86:04dd9b1680ae | 71 | Only 1.5 stop bits are authorized in SmartCard mode. */ |
bogdanm | 86:04dd9b1680ae | 72 | |
bogdanm | 86:04dd9b1680ae | 73 | uint16_t Parity; /*!< Specifies the parity mode. |
bogdanm | 86:04dd9b1680ae | 74 | This parameter can be a value of @ref SMARTCARD_Parity |
bogdanm | 86:04dd9b1680ae | 75 | @note The parity is enabled by default (PCE is forced to 1). |
bogdanm | 86:04dd9b1680ae | 76 | Since the WordLength is forced to 8 bits + parity, M is |
bogdanm | 86:04dd9b1680ae | 77 | forced to 1 and the parity bit is the 9th bit. */ |
bogdanm | 86:04dd9b1680ae | 78 | |
bogdanm | 86:04dd9b1680ae | 79 | uint16_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. |
bogdanm | 86:04dd9b1680ae | 80 | This parameter can be a value of @ref SMARTCARD_Mode */ |
bogdanm | 86:04dd9b1680ae | 81 | |
bogdanm | 86:04dd9b1680ae | 82 | uint16_t CLKPolarity; /*!< Specifies the steady state of the serial clock. |
bogdanm | 86:04dd9b1680ae | 83 | This parameter can be a value of @ref SMARTCARD_Clock_Polarity */ |
bogdanm | 86:04dd9b1680ae | 84 | |
bogdanm | 86:04dd9b1680ae | 85 | uint16_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. |
bogdanm | 86:04dd9b1680ae | 86 | This parameter can be a value of @ref SMARTCARD_Clock_Phase */ |
bogdanm | 86:04dd9b1680ae | 87 | |
bogdanm | 86:04dd9b1680ae | 88 | uint16_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
bogdanm | 86:04dd9b1680ae | 89 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
bogdanm | 86:04dd9b1680ae | 90 | This parameter can be a value of @ref SMARTCARD_Last_Bit */ |
bogdanm | 86:04dd9b1680ae | 91 | |
bogdanm | 86:04dd9b1680ae | 92 | uint16_t OneBitSampling; /*!< Specifies wether a single sample or three samples' majority vote is selected. |
bogdanm | 86:04dd9b1680ae | 93 | Selecting the single sample method increases the receiver tolerance to clock |
bogdanm | 86:04dd9b1680ae | 94 | deviations. This parameter can be a value of @ref SMARTCARD_OneBit_Sampling. */ |
bogdanm | 86:04dd9b1680ae | 95 | |
bogdanm | 86:04dd9b1680ae | 96 | uint8_t Prescaler; /*!< Specifies the SmartCard Prescaler */ |
bogdanm | 86:04dd9b1680ae | 97 | |
bogdanm | 86:04dd9b1680ae | 98 | uint8_t GuardTime; /*!< Specifies the SmartCard Guard Time */ |
bogdanm | 86:04dd9b1680ae | 99 | |
bogdanm | 86:04dd9b1680ae | 100 | uint16_t NACKEnable; /*!< Specifies whether the SmartCard NACK transmission is enabled |
bogdanm | 86:04dd9b1680ae | 101 | in case of parity error. |
bogdanm | 86:04dd9b1680ae | 102 | This parameter can be a value of @ref SMARTCARD_NACK_Enable */ |
bogdanm | 86:04dd9b1680ae | 103 | |
bogdanm | 86:04dd9b1680ae | 104 | uint32_t TimeOutEnable; /*!< Specifies whether the receiver timeout is enabled. |
bogdanm | 86:04dd9b1680ae | 105 | This parameter can be a value of @ref SMARTCARD_Timeout_Enable*/ |
bogdanm | 86:04dd9b1680ae | 106 | |
bogdanm | 86:04dd9b1680ae | 107 | uint32_t TimeOutValue; /*!< Specifies the receiver time out value in number of baud blocks: |
bogdanm | 86:04dd9b1680ae | 108 | it is used to implement the Character Wait Time (CWT) and |
bogdanm | 86:04dd9b1680ae | 109 | Block Wait Time (BWT). It is coded over 24 bits. */ |
bogdanm | 86:04dd9b1680ae | 110 | |
bogdanm | 86:04dd9b1680ae | 111 | uint8_t BlockLength; /*!< Specifies the SmartCard Block Length in T=1 Reception mode. |
bogdanm | 86:04dd9b1680ae | 112 | This parameter can be any value from 0x0 to 0xFF */ |
bogdanm | 86:04dd9b1680ae | 113 | |
bogdanm | 86:04dd9b1680ae | 114 | uint8_t AutoRetryCount; /*!< Specifies the SmartCard auto-retry count (number of retries in |
bogdanm | 86:04dd9b1680ae | 115 | receive and transmit mode). When set to 0, retransmission is |
bogdanm | 86:04dd9b1680ae | 116 | disabled. Otherwise, its maximum value is 7 (before signalling |
bogdanm | 86:04dd9b1680ae | 117 | an error) */ |
bogdanm | 86:04dd9b1680ae | 118 | |
bogdanm | 86:04dd9b1680ae | 119 | }SMARTCARD_InitTypeDef; |
bogdanm | 86:04dd9b1680ae | 120 | |
bogdanm | 86:04dd9b1680ae | 121 | /** |
bogdanm | 86:04dd9b1680ae | 122 | * @brief SMARTCARD advanced features initalization structure definition |
bogdanm | 86:04dd9b1680ae | 123 | */ |
bogdanm | 86:04dd9b1680ae | 124 | typedef struct |
bogdanm | 86:04dd9b1680ae | 125 | { |
bogdanm | 86:04dd9b1680ae | 126 | uint32_t AdvFeatureInit; /*!< Specifies which advanced SMARTCARD features is initialized. Several |
bogdanm | 86:04dd9b1680ae | 127 | advanced features may be initialized at the same time. This parameter |
bogdanm | 86:04dd9b1680ae | 128 | can be a value of @ref SMARTCARD_Advanced_Features_Initialization_Type */ |
bogdanm | 86:04dd9b1680ae | 129 | |
bogdanm | 86:04dd9b1680ae | 130 | uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted. |
bogdanm | 86:04dd9b1680ae | 131 | This parameter can be a value of @ref SMARTCARD_Tx_Inv */ |
bogdanm | 86:04dd9b1680ae | 132 | |
bogdanm | 86:04dd9b1680ae | 133 | uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted. |
bogdanm | 86:04dd9b1680ae | 134 | This parameter can be a value of @ref SMARTCARD_Rx_Inv */ |
bogdanm | 86:04dd9b1680ae | 135 | |
bogdanm | 86:04dd9b1680ae | 136 | uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic |
bogdanm | 86:04dd9b1680ae | 137 | vs negative/inverted logic). |
bogdanm | 86:04dd9b1680ae | 138 | This parameter can be a value of @ref SMARTCARD_Data_Inv */ |
bogdanm | 86:04dd9b1680ae | 139 | |
bogdanm | 86:04dd9b1680ae | 140 | uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped. |
bogdanm | 86:04dd9b1680ae | 141 | This parameter can be a value of @ref SMARTCARD_Rx_Tx_Swap */ |
bogdanm | 86:04dd9b1680ae | 142 | |
bogdanm | 86:04dd9b1680ae | 143 | uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled. |
bogdanm | 86:04dd9b1680ae | 144 | This parameter can be a value of @ref SMARTCARD_Overrun_Disable */ |
bogdanm | 86:04dd9b1680ae | 145 | |
bogdanm | 86:04dd9b1680ae | 146 | uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error. |
bogdanm | 86:04dd9b1680ae | 147 | This parameter can be a value of @ref SMARTCARD_DMA_Disable_on_Rx_Error */ |
bogdanm | 86:04dd9b1680ae | 148 | |
bogdanm | 86:04dd9b1680ae | 149 | uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line. |
bogdanm | 86:04dd9b1680ae | 150 | This parameter can be a value of @ref SMARTCARD_MSB_First */ |
bogdanm | 86:04dd9b1680ae | 151 | }SMARTCARD_AdvFeatureInitTypeDef; |
bogdanm | 86:04dd9b1680ae | 152 | |
bogdanm | 86:04dd9b1680ae | 153 | /** |
bogdanm | 86:04dd9b1680ae | 154 | * @brief HAL State structures definition |
bogdanm | 86:04dd9b1680ae | 155 | */ |
bogdanm | 86:04dd9b1680ae | 156 | typedef enum |
bogdanm | 86:04dd9b1680ae | 157 | { |
bogdanm | 86:04dd9b1680ae | 158 | HAL_SMARTCARD_STATE_RESET = 0x00, /*!< Peripheral is not initialized */ |
bogdanm | 86:04dd9b1680ae | 159 | HAL_SMARTCARD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
bogdanm | 86:04dd9b1680ae | 160 | HAL_SMARTCARD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
bogdanm | 86:04dd9b1680ae | 161 | HAL_SMARTCARD_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
bogdanm | 86:04dd9b1680ae | 162 | HAL_SMARTCARD_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
bogdanm | 86:04dd9b1680ae | 163 | HAL_SMARTCARD_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ |
bogdanm | 86:04dd9b1680ae | 164 | HAL_SMARTCARD_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
bogdanm | 86:04dd9b1680ae | 165 | HAL_SMARTCARD_STATE_ERROR = 0x04 /*!< Error */ |
bogdanm | 86:04dd9b1680ae | 166 | }HAL_SMARTCARD_StateTypeDef; |
bogdanm | 86:04dd9b1680ae | 167 | |
bogdanm | 86:04dd9b1680ae | 168 | /** |
bogdanm | 86:04dd9b1680ae | 169 | * @brief HAL SMARTCARD Error Code structure definition |
bogdanm | 86:04dd9b1680ae | 170 | */ |
bogdanm | 86:04dd9b1680ae | 171 | typedef enum |
bogdanm | 86:04dd9b1680ae | 172 | { |
bogdanm | 86:04dd9b1680ae | 173 | HAL_SMARTCARD_ERROR_NONE = 0x00, /*!< No error */ |
bogdanm | 86:04dd9b1680ae | 174 | HAL_SMARTCARD_ERROR_PE = 0x01, /*!< Parity error */ |
bogdanm | 86:04dd9b1680ae | 175 | HAL_SMARTCARD_ERROR_NE = 0x02, /*!< Noise error */ |
bogdanm | 86:04dd9b1680ae | 176 | HAL_SMARTCARD_ERROR_FE = 0x04, /*!< frame error */ |
bogdanm | 86:04dd9b1680ae | 177 | HAL_SMARTCARD_ERROR_ORE = 0x08, /*!< Overrun error */ |
bogdanm | 86:04dd9b1680ae | 178 | HAL_SMARTCARD_ERROR_DMA = 0x10, /*!< DMA transfer error */ |
bogdanm | 86:04dd9b1680ae | 179 | HAL_SMARTCARD_ERROR_RTO = 0x20 /*!< Receiver TimeOut error */ |
bogdanm | 86:04dd9b1680ae | 180 | }HAL_SMARTCARD_ErrorTypeDef; |
bogdanm | 86:04dd9b1680ae | 181 | |
bogdanm | 86:04dd9b1680ae | 182 | /** |
bogdanm | 86:04dd9b1680ae | 183 | * @brief SMARTCARD handle Structure definition |
bogdanm | 86:04dd9b1680ae | 184 | */ |
bogdanm | 86:04dd9b1680ae | 185 | typedef struct |
bogdanm | 86:04dd9b1680ae | 186 | { |
bogdanm | 86:04dd9b1680ae | 187 | USART_TypeDef *Instance; /* USART registers base address */ |
bogdanm | 86:04dd9b1680ae | 188 | |
bogdanm | 86:04dd9b1680ae | 189 | SMARTCARD_InitTypeDef Init; /* SmartCard communication parameters */ |
bogdanm | 86:04dd9b1680ae | 190 | |
bogdanm | 86:04dd9b1680ae | 191 | SMARTCARD_AdvFeatureInitTypeDef AdvancedInit; /* SmartCard advanced features initialization parameters */ |
bogdanm | 86:04dd9b1680ae | 192 | |
bogdanm | 86:04dd9b1680ae | 193 | uint8_t *pTxBuffPtr; /* Pointer to SmartCard Tx transfer Buffer */ |
bogdanm | 86:04dd9b1680ae | 194 | |
bogdanm | 86:04dd9b1680ae | 195 | uint16_t TxXferSize; /* SmartCard Tx Transfer size */ |
bogdanm | 86:04dd9b1680ae | 196 | |
bogdanm | 86:04dd9b1680ae | 197 | uint16_t TxXferCount; /* SmartCard Tx Transfer Counter */ |
bogdanm | 86:04dd9b1680ae | 198 | |
bogdanm | 86:04dd9b1680ae | 199 | uint8_t *pRxBuffPtr; /* Pointer to SmartCard Rx transfer Buffer */ |
bogdanm | 86:04dd9b1680ae | 200 | |
bogdanm | 86:04dd9b1680ae | 201 | uint16_t RxXferSize; /* SmartCard Rx Transfer size */ |
bogdanm | 86:04dd9b1680ae | 202 | |
bogdanm | 86:04dd9b1680ae | 203 | uint16_t RxXferCount; /* SmartCard Rx Transfer Counter */ |
bogdanm | 86:04dd9b1680ae | 204 | |
bogdanm | 86:04dd9b1680ae | 205 | DMA_HandleTypeDef *hdmatx; /* SmartCard Tx DMA Handle parameters */ |
bogdanm | 86:04dd9b1680ae | 206 | |
bogdanm | 86:04dd9b1680ae | 207 | DMA_HandleTypeDef *hdmarx; /* SmartCard Rx DMA Handle parameters */ |
bogdanm | 86:04dd9b1680ae | 208 | |
bogdanm | 86:04dd9b1680ae | 209 | HAL_LockTypeDef Lock; /* Locking object */ |
bogdanm | 86:04dd9b1680ae | 210 | |
bogdanm | 86:04dd9b1680ae | 211 | HAL_SMARTCARD_StateTypeDef State; /* SmartCard communication state */ |
bogdanm | 86:04dd9b1680ae | 212 | |
bogdanm | 86:04dd9b1680ae | 213 | HAL_SMARTCARD_ErrorTypeDef ErrorCode; /* SmartCard Error code */ |
bogdanm | 86:04dd9b1680ae | 214 | |
bogdanm | 86:04dd9b1680ae | 215 | }SMARTCARD_HandleTypeDef; |
bogdanm | 86:04dd9b1680ae | 216 | |
bogdanm | 86:04dd9b1680ae | 217 | /** |
bogdanm | 86:04dd9b1680ae | 218 | * @brief SMARTCARD clock sources |
bogdanm | 86:04dd9b1680ae | 219 | */ |
bogdanm | 86:04dd9b1680ae | 220 | typedef enum |
bogdanm | 86:04dd9b1680ae | 221 | { |
bogdanm | 86:04dd9b1680ae | 222 | SMARTCARD_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */ |
bogdanm | 86:04dd9b1680ae | 223 | SMARTCARD_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */ |
bogdanm | 86:04dd9b1680ae | 224 | SMARTCARD_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */ |
bogdanm | 86:04dd9b1680ae | 225 | SMARTCARD_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */ |
bogdanm | 86:04dd9b1680ae | 226 | SMARTCARD_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */ |
bogdanm | 86:04dd9b1680ae | 227 | SMARTCARD_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */ |
bogdanm | 86:04dd9b1680ae | 228 | }SMARTCARD_ClockSourceTypeDef; |
bogdanm | 86:04dd9b1680ae | 229 | |
bogdanm | 86:04dd9b1680ae | 230 | |
bogdanm | 86:04dd9b1680ae | 231 | /* Exported constants --------------------------------------------------------*/ |
bogdanm | 86:04dd9b1680ae | 232 | /** @defgroup SMARTCARD_Exported_Constants |
bogdanm | 86:04dd9b1680ae | 233 | * @{ |
bogdanm | 86:04dd9b1680ae | 234 | */ |
bogdanm | 86:04dd9b1680ae | 235 | |
bogdanm | 86:04dd9b1680ae | 236 | /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length |
bogdanm | 86:04dd9b1680ae | 237 | * @{ |
bogdanm | 86:04dd9b1680ae | 238 | */ |
bogdanm | 86:04dd9b1680ae | 239 | #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) |
bogdanm | 86:04dd9b1680ae | 240 | #define IS_SMARTCARD_WORD_LENGTH(LENGTH) ((LENGTH) == SMARTCARD_WORDLENGTH_9B) |
bogdanm | 86:04dd9b1680ae | 241 | /** |
bogdanm | 86:04dd9b1680ae | 242 | * @} |
bogdanm | 86:04dd9b1680ae | 243 | */ |
bogdanm | 86:04dd9b1680ae | 244 | |
bogdanm | 86:04dd9b1680ae | 245 | /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Stop Bits |
bogdanm | 86:04dd9b1680ae | 246 | * @{ |
bogdanm | 86:04dd9b1680ae | 247 | */ |
bogdanm | 86:04dd9b1680ae | 248 | #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP)) |
bogdanm | 86:04dd9b1680ae | 249 | #define IS_SMARTCARD_STOPBITS(STOPBITS) ((STOPBITS) == SMARTCARD_STOPBITS_1_5) |
bogdanm | 86:04dd9b1680ae | 250 | /** |
bogdanm | 86:04dd9b1680ae | 251 | * @} |
bogdanm | 86:04dd9b1680ae | 252 | */ |
bogdanm | 86:04dd9b1680ae | 253 | |
bogdanm | 86:04dd9b1680ae | 254 | /** @defgroup SMARTCARD_Parity SMARTCARD Parity |
bogdanm | 86:04dd9b1680ae | 255 | * @{ |
bogdanm | 86:04dd9b1680ae | 256 | */ |
bogdanm | 86:04dd9b1680ae | 257 | #define SMARTCARD_PARITY_EVEN ((uint16_t)USART_CR1_PCE) |
bogdanm | 86:04dd9b1680ae | 258 | #define SMARTCARD_PARITY_ODD ((uint16_t)(USART_CR1_PCE | USART_CR1_PS)) |
bogdanm | 86:04dd9b1680ae | 259 | #define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_EVEN) || \ |
bogdanm | 86:04dd9b1680ae | 260 | ((PARITY) == SMARTCARD_PARITY_ODD)) |
bogdanm | 86:04dd9b1680ae | 261 | /** |
bogdanm | 86:04dd9b1680ae | 262 | * @} |
bogdanm | 86:04dd9b1680ae | 263 | */ |
bogdanm | 86:04dd9b1680ae | 264 | |
bogdanm | 86:04dd9b1680ae | 265 | /** @defgroup SMARTCARD_Mode SMARTCARD Transfer Mode |
bogdanm | 86:04dd9b1680ae | 266 | * @{ |
bogdanm | 86:04dd9b1680ae | 267 | */ |
bogdanm | 86:04dd9b1680ae | 268 | #define SMARTCARD_MODE_RX ((uint16_t)USART_CR1_RE) |
bogdanm | 86:04dd9b1680ae | 269 | #define SMARTCARD_MODE_TX ((uint16_t)USART_CR1_TE) |
bogdanm | 86:04dd9b1680ae | 270 | #define SMARTCARD_MODE_TX_RX ((uint16_t)(USART_CR1_TE |USART_CR1_RE)) |
bogdanm | 86:04dd9b1680ae | 271 | #define IS_SMARTCARD_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00)) |
bogdanm | 86:04dd9b1680ae | 272 | /** |
bogdanm | 86:04dd9b1680ae | 273 | * @} |
bogdanm | 86:04dd9b1680ae | 274 | */ |
bogdanm | 86:04dd9b1680ae | 275 | |
bogdanm | 86:04dd9b1680ae | 276 | /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity |
bogdanm | 86:04dd9b1680ae | 277 | * @{ |
bogdanm | 86:04dd9b1680ae | 278 | */ |
bogdanm | 86:04dd9b1680ae | 279 | #define SMARTCARD_POLARITY_LOW ((uint16_t)0x0000) |
bogdanm | 86:04dd9b1680ae | 280 | #define SMARTCARD_POLARITY_HIGH ((uint16_t)USART_CR2_CPOL) |
bogdanm | 86:04dd9b1680ae | 281 | #define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH)) |
bogdanm | 86:04dd9b1680ae | 282 | /** |
bogdanm | 86:04dd9b1680ae | 283 | * @} |
bogdanm | 86:04dd9b1680ae | 284 | */ |
bogdanm | 86:04dd9b1680ae | 285 | |
bogdanm | 86:04dd9b1680ae | 286 | /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase |
bogdanm | 86:04dd9b1680ae | 287 | * @{ |
bogdanm | 86:04dd9b1680ae | 288 | */ |
bogdanm | 86:04dd9b1680ae | 289 | #define SMARTCARD_PHASE_1EDGE ((uint16_t)0x0000) |
bogdanm | 86:04dd9b1680ae | 290 | #define SMARTCARD_PHASE_2EDGE ((uint16_t)USART_CR2_CPHA) |
bogdanm | 86:04dd9b1680ae | 291 | #define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE)) |
bogdanm | 86:04dd9b1680ae | 292 | /** |
bogdanm | 86:04dd9b1680ae | 293 | * @} |
bogdanm | 86:04dd9b1680ae | 294 | */ |
bogdanm | 86:04dd9b1680ae | 295 | |
bogdanm | 86:04dd9b1680ae | 296 | /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit |
bogdanm | 86:04dd9b1680ae | 297 | * @{ |
bogdanm | 86:04dd9b1680ae | 298 | */ |
bogdanm | 86:04dd9b1680ae | 299 | #define SMARTCARD_LASTBIT_DISABLED ((uint16_t)0x0000) |
bogdanm | 86:04dd9b1680ae | 300 | #define SMARTCARD_LASTBIT_ENABLED ((uint16_t)USART_CR2_LBCL) |
bogdanm | 86:04dd9b1680ae | 301 | #define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLED) || \ |
bogdanm | 86:04dd9b1680ae | 302 | ((LASTBIT) == SMARTCARD_LASTBIT_ENABLED)) |
bogdanm | 86:04dd9b1680ae | 303 | /** |
bogdanm | 86:04dd9b1680ae | 304 | * @} |
bogdanm | 86:04dd9b1680ae | 305 | */ |
bogdanm | 86:04dd9b1680ae | 306 | |
bogdanm | 86:04dd9b1680ae | 307 | /** @defgroup SMARTCARD_OneBit_Sampling SMARTCARD One Bit Sampling Method |
bogdanm | 86:04dd9b1680ae | 308 | * @{ |
bogdanm | 86:04dd9b1680ae | 309 | */ |
bogdanm | 86:04dd9b1680ae | 310 | #define SMARTCARD_ONEBIT_SAMPLING_DISABLED ((uint16_t)0x0000) |
bogdanm | 86:04dd9b1680ae | 311 | #define SMARTCARD_ONEBIT_SAMPLING_ENABLED ((uint16_t)USART_CR3_ONEBIT) |
bogdanm | 86:04dd9b1680ae | 312 | #define IS_SMARTCARD_ONEBIT_SAMPLING(ONEBIT) (((ONEBIT) == SMARTCARD_ONEBIT_SAMPLING_DISABLED) || \ |
bogdanm | 86:04dd9b1680ae | 313 | ((ONEBIT) == SMARTCARD_ONEBIT_SAMPLING_ENABLED)) |
bogdanm | 86:04dd9b1680ae | 314 | /** |
bogdanm | 86:04dd9b1680ae | 315 | * @} |
bogdanm | 86:04dd9b1680ae | 316 | */ |
bogdanm | 86:04dd9b1680ae | 317 | |
bogdanm | 86:04dd9b1680ae | 318 | |
bogdanm | 86:04dd9b1680ae | 319 | /** @defgroup SMARTCARD_NACK_Enable SMARTCARD NACK Enable |
bogdanm | 86:04dd9b1680ae | 320 | * @{ |
bogdanm | 86:04dd9b1680ae | 321 | */ |
bogdanm | 86:04dd9b1680ae | 322 | #define SMARTCARD_NACK_ENABLED ((uint16_t)USART_CR3_NACK) |
bogdanm | 86:04dd9b1680ae | 323 | #define SMARTCARD_NACK_DISABLED ((uint16_t)0x0000) |
bogdanm | 86:04dd9b1680ae | 324 | #define IS_SMARTCARD_NACK(NACK) (((NACK) == SMARTCARD_NACK_ENABLED) || \ |
bogdanm | 86:04dd9b1680ae | 325 | ((NACK) == SMARTCARD_NACK_DISABLED)) |
bogdanm | 86:04dd9b1680ae | 326 | /** |
bogdanm | 86:04dd9b1680ae | 327 | * @} |
bogdanm | 86:04dd9b1680ae | 328 | */ |
bogdanm | 86:04dd9b1680ae | 329 | |
bogdanm | 86:04dd9b1680ae | 330 | /** @defgroup SMARTCARD_Timeout_Enable SMARTCARD Timeout Enable |
bogdanm | 86:04dd9b1680ae | 331 | * @{ |
bogdanm | 86:04dd9b1680ae | 332 | */ |
bogdanm | 86:04dd9b1680ae | 333 | #define SMARTCARD_TIMEOUT_DISABLED ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 334 | #define SMARTCARD_TIMEOUT_ENABLED ((uint32_t)USART_CR2_RTOEN) |
bogdanm | 86:04dd9b1680ae | 335 | #define IS_SMARTCARD_TIMEOUT(TIMEOUT) (((TIMEOUT) == SMARTCARD_TIMEOUT_DISABLED) || \ |
bogdanm | 86:04dd9b1680ae | 336 | ((TIMEOUT) == SMARTCARD_TIMEOUT_ENABLED)) |
bogdanm | 86:04dd9b1680ae | 337 | /** |
bogdanm | 86:04dd9b1680ae | 338 | * @} |
bogdanm | 86:04dd9b1680ae | 339 | */ |
bogdanm | 86:04dd9b1680ae | 340 | |
bogdanm | 86:04dd9b1680ae | 341 | /** @defgroup SMARTCARD_Advanced_Features_Initialization_Type SMARTCARD advanced feature initialization type |
bogdanm | 86:04dd9b1680ae | 342 | * @{ |
bogdanm | 86:04dd9b1680ae | 343 | */ |
bogdanm | 86:04dd9b1680ae | 344 | #define SMARTCARD_ADVFEATURE_NO_INIT ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 345 | #define SMARTCARD_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001) |
bogdanm | 86:04dd9b1680ae | 346 | #define SMARTCARD_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002) |
bogdanm | 86:04dd9b1680ae | 347 | #define SMARTCARD_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004) |
bogdanm | 86:04dd9b1680ae | 348 | #define SMARTCARD_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008) |
bogdanm | 86:04dd9b1680ae | 349 | #define SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010) |
bogdanm | 86:04dd9b1680ae | 350 | #define SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020) |
bogdanm | 86:04dd9b1680ae | 351 | #define SMARTCARD_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080) |
bogdanm | 86:04dd9b1680ae | 352 | #define IS_SMARTCARD_ADVFEATURE_INIT(INIT) ((INIT) <= (SMARTCARD_ADVFEATURE_NO_INIT | \ |
bogdanm | 86:04dd9b1680ae | 353 | SMARTCARD_ADVFEATURE_TXINVERT_INIT | \ |
bogdanm | 86:04dd9b1680ae | 354 | SMARTCARD_ADVFEATURE_RXINVERT_INIT | \ |
bogdanm | 86:04dd9b1680ae | 355 | SMARTCARD_ADVFEATURE_DATAINVERT_INIT | \ |
bogdanm | 86:04dd9b1680ae | 356 | SMARTCARD_ADVFEATURE_SWAP_INIT | \ |
bogdanm | 86:04dd9b1680ae | 357 | SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT | \ |
bogdanm | 86:04dd9b1680ae | 358 | SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT | \ |
bogdanm | 86:04dd9b1680ae | 359 | SMARTCARD_ADVFEATURE_MSBFIRST_INIT)) |
bogdanm | 86:04dd9b1680ae | 360 | /** |
bogdanm | 86:04dd9b1680ae | 361 | * @} |
bogdanm | 86:04dd9b1680ae | 362 | */ |
bogdanm | 86:04dd9b1680ae | 363 | |
bogdanm | 86:04dd9b1680ae | 364 | /** @defgroup SMARTCARD_Tx_Inv SMARTCARD advanced feature TX pin active level inversion |
bogdanm | 86:04dd9b1680ae | 365 | * @{ |
bogdanm | 86:04dd9b1680ae | 366 | */ |
bogdanm | 86:04dd9b1680ae | 367 | #define SMARTCARD_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 368 | #define SMARTCARD_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV) |
bogdanm | 86:04dd9b1680ae | 369 | #define IS_SMARTCARD_ADVFEATURE_TXINV(TXINV) (((TXINV) == SMARTCARD_ADVFEATURE_TXINV_DISABLE) || \ |
bogdanm | 86:04dd9b1680ae | 370 | ((TXINV) == SMARTCARD_ADVFEATURE_TXINV_ENABLE)) |
bogdanm | 86:04dd9b1680ae | 371 | /** |
bogdanm | 86:04dd9b1680ae | 372 | * @} |
bogdanm | 86:04dd9b1680ae | 373 | */ |
bogdanm | 86:04dd9b1680ae | 374 | |
bogdanm | 86:04dd9b1680ae | 375 | /** @defgroup SMARTCARD_Rx_Inv SMARTCARD advanced feature RX pin active level inversion |
bogdanm | 86:04dd9b1680ae | 376 | * @{ |
bogdanm | 86:04dd9b1680ae | 377 | */ |
bogdanm | 86:04dd9b1680ae | 378 | #define SMARTCARD_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 379 | #define SMARTCARD_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV) |
bogdanm | 86:04dd9b1680ae | 380 | #define IS_SMARTCARD_ADVFEATURE_RXINV(RXINV) (((RXINV) == SMARTCARD_ADVFEATURE_RXINV_DISABLE) || \ |
bogdanm | 86:04dd9b1680ae | 381 | ((RXINV) == SMARTCARD_ADVFEATURE_RXINV_ENABLE)) |
bogdanm | 86:04dd9b1680ae | 382 | /** |
bogdanm | 86:04dd9b1680ae | 383 | * @} |
bogdanm | 86:04dd9b1680ae | 384 | */ |
bogdanm | 86:04dd9b1680ae | 385 | |
bogdanm | 86:04dd9b1680ae | 386 | /** @defgroup SMARTCARD_Data_Inv SMARTCARD advanced feature Binary Data inversion |
bogdanm | 86:04dd9b1680ae | 387 | * @{ |
bogdanm | 86:04dd9b1680ae | 388 | */ |
bogdanm | 86:04dd9b1680ae | 389 | #define SMARTCARD_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 390 | #define SMARTCARD_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV) |
bogdanm | 86:04dd9b1680ae | 391 | #define IS_SMARTCARD_ADVFEATURE_DATAINV(DATAINV) (((DATAINV) == SMARTCARD_ADVFEATURE_DATAINV_DISABLE) || \ |
bogdanm | 86:04dd9b1680ae | 392 | ((DATAINV) == SMARTCARD_ADVFEATURE_DATAINV_ENABLE)) |
bogdanm | 86:04dd9b1680ae | 393 | /** |
bogdanm | 86:04dd9b1680ae | 394 | * @} |
bogdanm | 86:04dd9b1680ae | 395 | */ |
bogdanm | 86:04dd9b1680ae | 396 | |
bogdanm | 86:04dd9b1680ae | 397 | /** @defgroup SMARTCARD_Rx_Tx_Swap SMARTCARD advanced feature RX TX pins swap |
bogdanm | 86:04dd9b1680ae | 398 | * @{ |
bogdanm | 86:04dd9b1680ae | 399 | */ |
bogdanm | 86:04dd9b1680ae | 400 | #define SMARTCARD_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 401 | #define SMARTCARD_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP) |
bogdanm | 86:04dd9b1680ae | 402 | #define IS_SMARTCARD_ADVFEATURE_SWAP(SWAP) (((SWAP) == SMARTCARD_ADVFEATURE_SWAP_DISABLE) || \ |
bogdanm | 86:04dd9b1680ae | 403 | ((SWAP) == SMARTCARD_ADVFEATURE_SWAP_ENABLE)) |
bogdanm | 86:04dd9b1680ae | 404 | /** |
bogdanm | 86:04dd9b1680ae | 405 | * @} |
bogdanm | 86:04dd9b1680ae | 406 | */ |
bogdanm | 86:04dd9b1680ae | 407 | |
bogdanm | 86:04dd9b1680ae | 408 | /** @defgroup SMARTCARD_Overrun_Disable SMARTCARD advanced feature Overrun Disable |
bogdanm | 86:04dd9b1680ae | 409 | * @{ |
bogdanm | 86:04dd9b1680ae | 410 | */ |
bogdanm | 86:04dd9b1680ae | 411 | #define SMARTCARD_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 412 | #define SMARTCARD_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS) |
bogdanm | 86:04dd9b1680ae | 413 | #define IS_SMARTCARD_OVERRUN(OVERRUN) (((OVERRUN) == SMARTCARD_ADVFEATURE_OVERRUN_ENABLE) || \ |
bogdanm | 86:04dd9b1680ae | 414 | ((OVERRUN) == SMARTCARD_ADVFEATURE_OVERRUN_DISABLE)) |
bogdanm | 86:04dd9b1680ae | 415 | /** |
bogdanm | 86:04dd9b1680ae | 416 | * @} |
bogdanm | 86:04dd9b1680ae | 417 | */ |
bogdanm | 86:04dd9b1680ae | 418 | |
bogdanm | 86:04dd9b1680ae | 419 | /** @defgroup SMARTCARD_DMA_Disable_on_Rx_Error SMARTCARD advanced feature DMA Disable on Rx Error |
bogdanm | 86:04dd9b1680ae | 420 | * @{ |
bogdanm | 86:04dd9b1680ae | 421 | */ |
bogdanm | 86:04dd9b1680ae | 422 | #define SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 423 | #define SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE) |
bogdanm | 86:04dd9b1680ae | 424 | #define IS_SMARTCARD_ADVFEATURE_DMAONRXERROR(DMA) (((DMA) == SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR) || \ |
bogdanm | 86:04dd9b1680ae | 425 | ((DMA) == SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR)) |
bogdanm | 86:04dd9b1680ae | 426 | /** |
bogdanm | 86:04dd9b1680ae | 427 | * @} |
bogdanm | 86:04dd9b1680ae | 428 | */ |
bogdanm | 86:04dd9b1680ae | 429 | |
bogdanm | 86:04dd9b1680ae | 430 | /** @defgroup SMARTCARD_MSB_First SMARTCARD advanced feature MSB first |
bogdanm | 86:04dd9b1680ae | 431 | * @{ |
bogdanm | 86:04dd9b1680ae | 432 | */ |
bogdanm | 86:04dd9b1680ae | 433 | #define SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000) |
bogdanm | 86:04dd9b1680ae | 434 | #define SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST) |
bogdanm | 86:04dd9b1680ae | 435 | #define IS_SMARTCARD_ADVFEATURE_MSBFIRST(MSBFIRST) (((MSBFIRST) == SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE) || \ |
bogdanm | 86:04dd9b1680ae | 436 | ((MSBFIRST) == SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE)) |
bogdanm | 86:04dd9b1680ae | 437 | /** |
bogdanm | 86:04dd9b1680ae | 438 | * @} |
bogdanm | 86:04dd9b1680ae | 439 | */ |
bogdanm | 86:04dd9b1680ae | 440 | |
bogdanm | 86:04dd9b1680ae | 441 | /** @defgroup SmartCard_Flags SMARTCARD Flags |
bogdanm | 86:04dd9b1680ae | 442 | * Elements values convention: 0xXXXX |
bogdanm | 86:04dd9b1680ae | 443 | * - 0xXXXX : Flag mask in the ISR register |
bogdanm | 86:04dd9b1680ae | 444 | * @{ |
bogdanm | 86:04dd9b1680ae | 445 | */ |
bogdanm | 86:04dd9b1680ae | 446 | #define SMARTCARD_FLAG_REACK ((uint32_t)0x00400000) |
bogdanm | 86:04dd9b1680ae | 447 | #define SMARTCARD_FLAG_TEACK ((uint32_t)0x00200000) |
bogdanm | 86:04dd9b1680ae | 448 | #define SMARTCARD_FLAG_BUSY ((uint32_t)0x00010000) |
bogdanm | 86:04dd9b1680ae | 449 | #define SMARTCARD_FLAG_EOBF ((uint32_t)0x00001000) |
bogdanm | 86:04dd9b1680ae | 450 | #define SMARTCARD_FLAG_RTOF ((uint32_t)0x00000800) |
bogdanm | 86:04dd9b1680ae | 451 | #define SMARTCARD_FLAG_TXE ((uint32_t)0x00000080) |
bogdanm | 86:04dd9b1680ae | 452 | #define SMARTCARD_FLAG_TC ((uint32_t)0x00000040) |
bogdanm | 86:04dd9b1680ae | 453 | #define SMARTCARD_FLAG_RXNE ((uint32_t)0x00000020) |
bogdanm | 86:04dd9b1680ae | 454 | #define SMARTCARD_FLAG_ORE ((uint32_t)0x00000008) |
bogdanm | 86:04dd9b1680ae | 455 | #define SMARTCARD_FLAG_NE ((uint32_t)0x00000004) |
bogdanm | 86:04dd9b1680ae | 456 | #define SMARTCARD_FLAG_FE ((uint32_t)0x00000002) |
bogdanm | 86:04dd9b1680ae | 457 | #define SMARTCARD_FLAG_PE ((uint32_t)0x00000001) |
bogdanm | 86:04dd9b1680ae | 458 | /** |
bogdanm | 86:04dd9b1680ae | 459 | * @} |
bogdanm | 86:04dd9b1680ae | 460 | */ |
bogdanm | 86:04dd9b1680ae | 461 | |
bogdanm | 86:04dd9b1680ae | 462 | /** @defgroup SMARTCARD_Interrupt_definition SMARTCARD Interrupts Definition |
bogdanm | 86:04dd9b1680ae | 463 | * Elements values convention: 0000ZZZZ0XXYYYYYb |
bogdanm | 86:04dd9b1680ae | 464 | * - YYYYY : Interrupt source position in the XX register (5bits) |
bogdanm | 86:04dd9b1680ae | 465 | * - XX : Interrupt source register (2bits) |
bogdanm | 86:04dd9b1680ae | 466 | * - 01: CR1 register |
bogdanm | 86:04dd9b1680ae | 467 | * - 10: CR2 register |
bogdanm | 86:04dd9b1680ae | 468 | * - 11: CR3 register |
bogdanm | 86:04dd9b1680ae | 469 | * - ZZZZ : Flag position in the ISR register(4bits) |
bogdanm | 86:04dd9b1680ae | 470 | * @{ |
bogdanm | 86:04dd9b1680ae | 471 | */ |
bogdanm | 86:04dd9b1680ae | 472 | |
bogdanm | 86:04dd9b1680ae | 473 | #define SMARTCARD_IT_PE ((uint16_t)0x0028) |
bogdanm | 86:04dd9b1680ae | 474 | #define SMARTCARD_IT_TXE ((uint16_t)0x0727) |
bogdanm | 86:04dd9b1680ae | 475 | #define SMARTCARD_IT_TC ((uint16_t)0x0626) |
bogdanm | 86:04dd9b1680ae | 476 | #define SMARTCARD_IT_RXNE ((uint16_t)0x0525) |
bogdanm | 86:04dd9b1680ae | 477 | |
bogdanm | 86:04dd9b1680ae | 478 | #define SMARTCARD_IT_ERR ((uint16_t)0x0060) |
bogdanm | 86:04dd9b1680ae | 479 | #define SMARTCARD_IT_ORE ((uint16_t)0x0300) |
bogdanm | 86:04dd9b1680ae | 480 | #define SMARTCARD_IT_NE ((uint16_t)0x0200) |
bogdanm | 86:04dd9b1680ae | 481 | #define SMARTCARD_IT_FE ((uint16_t)0x0100) |
bogdanm | 86:04dd9b1680ae | 482 | |
bogdanm | 86:04dd9b1680ae | 483 | #define SMARTCARD_IT_EOB ((uint16_t)0x0C3B) |
bogdanm | 86:04dd9b1680ae | 484 | #define SMARTCARD_IT_RTO ((uint16_t)0x0B3A) |
bogdanm | 86:04dd9b1680ae | 485 | /** |
bogdanm | 86:04dd9b1680ae | 486 | * @} |
bogdanm | 86:04dd9b1680ae | 487 | */ |
bogdanm | 86:04dd9b1680ae | 488 | |
bogdanm | 86:04dd9b1680ae | 489 | |
bogdanm | 86:04dd9b1680ae | 490 | /** @defgroup SMARTCARD_IT_CLEAR_Flags SMARTCARD Interruption Clear Flags |
bogdanm | 86:04dd9b1680ae | 491 | * @{ |
bogdanm | 86:04dd9b1680ae | 492 | */ |
bogdanm | 86:04dd9b1680ae | 493 | #define SMARTCARD_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ |
bogdanm | 86:04dd9b1680ae | 494 | #define SMARTCARD_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ |
bogdanm | 86:04dd9b1680ae | 495 | #define SMARTCARD_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */ |
bogdanm | 86:04dd9b1680ae | 496 | #define SMARTCARD_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */ |
bogdanm | 86:04dd9b1680ae | 497 | #define SMARTCARD_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ |
bogdanm | 86:04dd9b1680ae | 498 | #define SMARTCARD_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */ |
bogdanm | 86:04dd9b1680ae | 499 | #define SMARTCARD_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */ |
bogdanm | 86:04dd9b1680ae | 500 | /** |
bogdanm | 86:04dd9b1680ae | 501 | * @} |
bogdanm | 86:04dd9b1680ae | 502 | */ |
bogdanm | 86:04dd9b1680ae | 503 | |
bogdanm | 86:04dd9b1680ae | 504 | /** @defgroup SMARTCARD_Request_Parameters SMARTCARD Request Parameters |
bogdanm | 86:04dd9b1680ae | 505 | * @{ |
bogdanm | 86:04dd9b1680ae | 506 | */ |
bogdanm | 86:04dd9b1680ae | 507 | #define SMARTCARD_RXDATA_FLUSH_REQUEST ((uint16_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */ |
bogdanm | 86:04dd9b1680ae | 508 | #define SMARTCARD_TXDATA_FLUSH_REQUEST ((uint16_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */ |
bogdanm | 86:04dd9b1680ae | 509 | #define IS_SMARTCARD_REQUEST_PARAMETER(PARAM) (((PARAM) == SMARTCARD_RXDATA_FLUSH_REQUEST) || \ |
bogdanm | 86:04dd9b1680ae | 510 | ((PARAM) == SMARTCARD_TXDATA_FLUSH_REQUEST)) |
bogdanm | 86:04dd9b1680ae | 511 | /** |
bogdanm | 86:04dd9b1680ae | 512 | * @} |
bogdanm | 86:04dd9b1680ae | 513 | */ |
bogdanm | 86:04dd9b1680ae | 514 | |
bogdanm | 86:04dd9b1680ae | 515 | |
bogdanm | 86:04dd9b1680ae | 516 | /** @defgroup SMARTCARD_CR3_SCARCNT_LSB_POS SMARTCARD auto retry counter LSB position in CR3 register |
bogdanm | 86:04dd9b1680ae | 517 | * @{ |
bogdanm | 86:04dd9b1680ae | 518 | */ |
bogdanm | 86:04dd9b1680ae | 519 | #define SMARTCARD_CR3_SCARCNT_LSB_POS ((uint32_t) 17) |
bogdanm | 86:04dd9b1680ae | 520 | /** |
bogdanm | 86:04dd9b1680ae | 521 | * @} |
bogdanm | 86:04dd9b1680ae | 522 | */ |
bogdanm | 86:04dd9b1680ae | 523 | |
bogdanm | 86:04dd9b1680ae | 524 | /** @defgroup SMARTCARD_GTPR_GT_LSB_POS SMARTCARD guard time value LSB position in GTPR register |
bogdanm | 86:04dd9b1680ae | 525 | * @{ |
bogdanm | 86:04dd9b1680ae | 526 | */ |
bogdanm | 86:04dd9b1680ae | 527 | #define SMARTCARD_GTPR_GT_LSB_POS ((uint32_t) 8) |
bogdanm | 86:04dd9b1680ae | 528 | /** |
bogdanm | 86:04dd9b1680ae | 529 | * @} |
bogdanm | 86:04dd9b1680ae | 530 | */ |
bogdanm | 86:04dd9b1680ae | 531 | |
bogdanm | 86:04dd9b1680ae | 532 | /** @defgroup SMARTCARD_RTOR_BLEN_LSB_POS SMARTCARD block length LSB position in RTOR register |
bogdanm | 86:04dd9b1680ae | 533 | * @{ |
bogdanm | 86:04dd9b1680ae | 534 | */ |
bogdanm | 86:04dd9b1680ae | 535 | #define SMARTCARD_RTOR_BLEN_LSB_POS ((uint32_t) 24) |
bogdanm | 86:04dd9b1680ae | 536 | /** |
bogdanm | 86:04dd9b1680ae | 537 | * @} |
bogdanm | 86:04dd9b1680ae | 538 | */ |
bogdanm | 86:04dd9b1680ae | 539 | |
bogdanm | 86:04dd9b1680ae | 540 | /** @defgroup SMARTCARD_Interruption_Mask SMARTCARD interruptions flag mask |
bogdanm | 86:04dd9b1680ae | 541 | * @{ |
bogdanm | 86:04dd9b1680ae | 542 | */ |
bogdanm | 86:04dd9b1680ae | 543 | #define SMARTCARD_IT_MASK ((uint16_t)0x001F) |
bogdanm | 86:04dd9b1680ae | 544 | /** |
bogdanm | 86:04dd9b1680ae | 545 | * @} |
bogdanm | 86:04dd9b1680ae | 546 | */ |
bogdanm | 86:04dd9b1680ae | 547 | |
bogdanm | 86:04dd9b1680ae | 548 | /** |
bogdanm | 86:04dd9b1680ae | 549 | * @} |
bogdanm | 86:04dd9b1680ae | 550 | */ |
bogdanm | 86:04dd9b1680ae | 551 | |
bogdanm | 86:04dd9b1680ae | 552 | /* Exported macros -----------------------------------------------------------*/ |
bogdanm | 86:04dd9b1680ae | 553 | /** @defgroup SMARTCARD_Exported_Macros |
bogdanm | 86:04dd9b1680ae | 554 | * @{ |
bogdanm | 86:04dd9b1680ae | 555 | */ |
bogdanm | 86:04dd9b1680ae | 556 | |
bogdanm | 86:04dd9b1680ae | 557 | /** @brief Reset SMARTCARD handle state |
bogdanm | 86:04dd9b1680ae | 558 | * @param __HANDLE__: SMARTCARD handle. |
bogdanm | 86:04dd9b1680ae | 559 | * @retval None |
bogdanm | 86:04dd9b1680ae | 560 | */ |
bogdanm | 86:04dd9b1680ae | 561 | #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMARTCARD_STATE_RESET) |
bogdanm | 86:04dd9b1680ae | 562 | |
bogdanm | 86:04dd9b1680ae | 563 | /** @brief Checks whether the specified Smartcard flag is set or not. |
bogdanm | 86:04dd9b1680ae | 564 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 565 | * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. |
bogdanm | 86:04dd9b1680ae | 566 | * @param __FLAG__: specifies the flag to check. |
bogdanm | 86:04dd9b1680ae | 567 | * This parameter can be one of the following values: |
bogdanm | 86:04dd9b1680ae | 568 | * @arg SMARTCARD_FLAG_REACK: Receive enable ackowledge flag |
bogdanm | 86:04dd9b1680ae | 569 | * @arg SMARTCARD_FLAG_TEACK: Transmit enable ackowledge flag |
bogdanm | 86:04dd9b1680ae | 570 | * @arg SMARTCARD_FLAG_BUSY: Busy flag |
bogdanm | 86:04dd9b1680ae | 571 | * @arg SMARTCARD_FLAG_EOBF: End of block flag |
bogdanm | 86:04dd9b1680ae | 572 | * @arg SMARTCARD_FLAG_RTOF: Receiver timeout flag |
bogdanm | 86:04dd9b1680ae | 573 | * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag |
bogdanm | 86:04dd9b1680ae | 574 | * @arg SMARTCARD_FLAG_TC: Transmission Complete flag |
bogdanm | 86:04dd9b1680ae | 575 | * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag |
bogdanm | 86:04dd9b1680ae | 576 | * @arg SMARTCARD_FLAG_ORE: OverRun Error flag |
bogdanm | 86:04dd9b1680ae | 577 | * @arg SMARTCARD_FLAG_NE: Noise Error flag |
bogdanm | 86:04dd9b1680ae | 578 | * @arg SMARTCARD_FLAG_FE: Framing Error flag |
bogdanm | 86:04dd9b1680ae | 579 | * @arg SMARTCARD_FLAG_PE: Parity Error flag |
bogdanm | 86:04dd9b1680ae | 580 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
bogdanm | 86:04dd9b1680ae | 581 | */ |
bogdanm | 86:04dd9b1680ae | 582 | #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) |
bogdanm | 86:04dd9b1680ae | 583 | |
bogdanm | 86:04dd9b1680ae | 584 | |
bogdanm | 86:04dd9b1680ae | 585 | /** @brief Enables the specified SmartCard interrupt. |
bogdanm | 86:04dd9b1680ae | 586 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 587 | * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. |
bogdanm | 86:04dd9b1680ae | 588 | * @param __INTERRUPT__: specifies the SMARTCARD interrupt to enable. |
bogdanm | 86:04dd9b1680ae | 589 | * This parameter can be one of the following values: |
bogdanm | 86:04dd9b1680ae | 590 | * @arg SMARTCARD_IT_EOBF: End Of Block interrupt |
bogdanm | 86:04dd9b1680ae | 591 | * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt |
bogdanm | 86:04dd9b1680ae | 592 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
bogdanm | 86:04dd9b1680ae | 593 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
bogdanm | 86:04dd9b1680ae | 594 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
bogdanm | 86:04dd9b1680ae | 595 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
bogdanm | 86:04dd9b1680ae | 596 | * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
bogdanm | 86:04dd9b1680ae | 597 | * @retval None |
bogdanm | 86:04dd9b1680ae | 598 | */ |
bogdanm | 86:04dd9b1680ae | 599 | #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \ |
bogdanm | 86:04dd9b1680ae | 600 | ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \ |
bogdanm | 86:04dd9b1680ae | 601 | ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK)))) |
bogdanm | 86:04dd9b1680ae | 602 | |
bogdanm | 86:04dd9b1680ae | 603 | /** @brief Disables the specified SmartCard interrupt. |
bogdanm | 86:04dd9b1680ae | 604 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 605 | * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. |
bogdanm | 86:04dd9b1680ae | 606 | * @param __INTERRUPT__: specifies the SMARTCARD interrupt to disable. |
bogdanm | 86:04dd9b1680ae | 607 | * This parameter can be one of the following values: |
bogdanm | 86:04dd9b1680ae | 608 | * @arg SMARTCARD_IT_EOBF: End Of Block interrupt |
bogdanm | 86:04dd9b1680ae | 609 | * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt |
bogdanm | 86:04dd9b1680ae | 610 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
bogdanm | 86:04dd9b1680ae | 611 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
bogdanm | 86:04dd9b1680ae | 612 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
bogdanm | 86:04dd9b1680ae | 613 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
bogdanm | 86:04dd9b1680ae | 614 | * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
bogdanm | 86:04dd9b1680ae | 615 | * @retval None |
bogdanm | 86:04dd9b1680ae | 616 | */ |
bogdanm | 86:04dd9b1680ae | 617 | #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \ |
bogdanm | 86:04dd9b1680ae | 618 | ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \ |
bogdanm | 86:04dd9b1680ae | 619 | ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK)))) |
bogdanm | 86:04dd9b1680ae | 620 | |
bogdanm | 86:04dd9b1680ae | 621 | |
bogdanm | 86:04dd9b1680ae | 622 | /** @brief Checks whether the specified SmartCard interrupt has occurred or not. |
bogdanm | 86:04dd9b1680ae | 623 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 624 | * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. |
bogdanm | 86:04dd9b1680ae | 625 | * @param __IT__: specifies the SMARTCARD interrupt to check. |
bogdanm | 86:04dd9b1680ae | 626 | * This parameter can be one of the following values: |
bogdanm | 86:04dd9b1680ae | 627 | * @arg SMARTCARD_IT_EOBF: End Of Block interrupt |
bogdanm | 86:04dd9b1680ae | 628 | * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt |
bogdanm | 86:04dd9b1680ae | 629 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
bogdanm | 86:04dd9b1680ae | 630 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
bogdanm | 86:04dd9b1680ae | 631 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
bogdanm | 86:04dd9b1680ae | 632 | * @arg SMARTCARD_IT_ORE: OverRun Error interrupt |
bogdanm | 86:04dd9b1680ae | 633 | * @arg SMARTCARD_IT_NE: Noise Error interrupt |
bogdanm | 86:04dd9b1680ae | 634 | * @arg SMARTCARD_IT_FE: Framing Error interrupt |
bogdanm | 86:04dd9b1680ae | 635 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
bogdanm | 86:04dd9b1680ae | 636 | * @retval The new state of __IT__ (TRUE or FALSE). |
bogdanm | 86:04dd9b1680ae | 637 | */ |
bogdanm | 86:04dd9b1680ae | 638 | #define __HAL_SMARTCARD_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08))) |
bogdanm | 86:04dd9b1680ae | 639 | |
bogdanm | 86:04dd9b1680ae | 640 | /** @brief Checks whether the specified SmartCard interrupt interrupt source is enabled. |
bogdanm | 86:04dd9b1680ae | 641 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 642 | * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. |
bogdanm | 86:04dd9b1680ae | 643 | * @param __IT__: specifies the SMARTCARD interrupt source to check. |
bogdanm | 86:04dd9b1680ae | 644 | * This parameter can be one of the following values: |
bogdanm | 86:04dd9b1680ae | 645 | * @arg SMARTCARD_IT_EOBF: End Of Block interrupt |
bogdanm | 86:04dd9b1680ae | 646 | * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt |
bogdanm | 86:04dd9b1680ae | 647 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
bogdanm | 86:04dd9b1680ae | 648 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
bogdanm | 86:04dd9b1680ae | 649 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
bogdanm | 86:04dd9b1680ae | 650 | * @arg SMARTCARD_IT_ORE: OverRun Error interrupt |
bogdanm | 86:04dd9b1680ae | 651 | * @arg SMARTCARD_IT_NE: Noise Error interrupt |
bogdanm | 86:04dd9b1680ae | 652 | * @arg SMARTCARD_IT_FE: Framing Error interrupt |
bogdanm | 86:04dd9b1680ae | 653 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
bogdanm | 86:04dd9b1680ae | 654 | * @retval The new state of __IT__ (TRUE or FALSE). |
bogdanm | 86:04dd9b1680ae | 655 | */ |
bogdanm | 86:04dd9b1680ae | 656 | #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1 : \ |
bogdanm | 86:04dd9b1680ae | 657 | (((((uint8_t)(__IT__)) >> 5U) == 2)? (__HANDLE__)->Instance->CR2 : \ |
bogdanm | 86:04dd9b1680ae | 658 | (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & SMARTCARD_IT_MASK))) |
bogdanm | 86:04dd9b1680ae | 659 | |
bogdanm | 86:04dd9b1680ae | 660 | |
bogdanm | 86:04dd9b1680ae | 661 | /** @brief Clears the specified SMARTCARD ISR flag, in setting the proper ICR register flag. |
bogdanm | 86:04dd9b1680ae | 662 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 663 | * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. |
bogdanm | 86:04dd9b1680ae | 664 | * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set |
bogdanm | 86:04dd9b1680ae | 665 | * to clear the corresponding interrupt |
bogdanm | 86:04dd9b1680ae | 666 | * This parameter can be one of the following values: |
bogdanm | 86:04dd9b1680ae | 667 | * @arg USART_CLEAR_PEF: Parity Error Clear Flag |
bogdanm | 86:04dd9b1680ae | 668 | * @arg USART_CLEAR_FEF: Framing Error Clear Flag |
bogdanm | 86:04dd9b1680ae | 669 | * @arg USART_CLEAR_NEF: Noise detected Clear Flag |
bogdanm | 86:04dd9b1680ae | 670 | * @arg USART_CLEAR_OREF: OverRun Error Clear Flag |
bogdanm | 86:04dd9b1680ae | 671 | * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag |
bogdanm | 86:04dd9b1680ae | 672 | * @arg USART_CLEAR_RTOF: Receiver Time Out Clear Flag |
bogdanm | 86:04dd9b1680ae | 673 | * @arg USART_CLEAR_EOBF: End Of Block Clear Flag |
bogdanm | 86:04dd9b1680ae | 674 | * @retval None |
bogdanm | 86:04dd9b1680ae | 675 | */ |
bogdanm | 86:04dd9b1680ae | 676 | #define __HAL_SMARTCARD_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) |
bogdanm | 86:04dd9b1680ae | 677 | |
bogdanm | 86:04dd9b1680ae | 678 | /** @brief Set a specific SMARTCARD request flag. |
bogdanm | 86:04dd9b1680ae | 679 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 680 | * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. |
bogdanm | 86:04dd9b1680ae | 681 | * @param __REQ__: specifies the request flag to set |
bogdanm | 86:04dd9b1680ae | 682 | * This parameter can be one of the following values: |
bogdanm | 86:04dd9b1680ae | 683 | * @arg SMARTCARD_RXDATA_FLUSH_REQUEST: Receive Data flush Request |
bogdanm | 86:04dd9b1680ae | 684 | * @arg SMARTCARD_TXDATA_FLUSH_REQUEST: Transmit data flush Request |
bogdanm | 86:04dd9b1680ae | 685 | * |
bogdanm | 86:04dd9b1680ae | 686 | * @retval None |
bogdanm | 86:04dd9b1680ae | 687 | */ |
bogdanm | 86:04dd9b1680ae | 688 | #define __HAL_SMARTCARD_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__)) |
bogdanm | 86:04dd9b1680ae | 689 | |
bogdanm | 86:04dd9b1680ae | 690 | /** @brief Enable the USART associated to the SMARTCARD Handle |
bogdanm | 86:04dd9b1680ae | 691 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 692 | * The Handle Instance can be UARTx where x: 1, 2, 3 to select the USART peripheral |
bogdanm | 86:04dd9b1680ae | 693 | * @retval None |
bogdanm | 86:04dd9b1680ae | 694 | */ |
bogdanm | 86:04dd9b1680ae | 695 | #define __HAL_SMARTCARD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
bogdanm | 86:04dd9b1680ae | 696 | |
bogdanm | 86:04dd9b1680ae | 697 | /** @brief Disable the USART associated to the SMARTCARD Handle |
bogdanm | 86:04dd9b1680ae | 698 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
bogdanm | 86:04dd9b1680ae | 699 | * The Handle Instance can be UARTx where x: 1, 2, 3 to select the USART peripheral |
bogdanm | 86:04dd9b1680ae | 700 | * @retval None |
bogdanm | 86:04dd9b1680ae | 701 | */ |
bogdanm | 86:04dd9b1680ae | 702 | #define __HAL_SMARTCARD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
bogdanm | 86:04dd9b1680ae | 703 | |
bogdanm | 86:04dd9b1680ae | 704 | /** @brief Check the Baud rate range. The maximum Baud Rate is derived from the |
bogdanm | 86:04dd9b1680ae | 705 | * maximum clock on F3 (i.e. 72 MHz) divided by the oversampling used |
bogdanm | 86:04dd9b1680ae | 706 | * on the SMARTCARD (i.e. 16) |
bogdanm | 86:04dd9b1680ae | 707 | * @param __BAUDRATE__: Baud rate set by the configuration function. |
bogdanm | 86:04dd9b1680ae | 708 | * @retval Test result (TRUE or FALSE) |
bogdanm | 86:04dd9b1680ae | 709 | */ |
bogdanm | 86:04dd9b1680ae | 710 | #define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 4500001) |
bogdanm | 86:04dd9b1680ae | 711 | |
bogdanm | 86:04dd9b1680ae | 712 | /** @brief Check the block length range. The maximum SMARTCARD block length is 0xFF. |
bogdanm | 86:04dd9b1680ae | 713 | * @param __LENGTH__: block length. |
bogdanm | 86:04dd9b1680ae | 714 | * @retval Test result (TRUE or FALSE) |
bogdanm | 86:04dd9b1680ae | 715 | */ |
bogdanm | 86:04dd9b1680ae | 716 | #define IS_SMARTCARD_BLOCKLENGTH(__LENGTH__) ((__LENGTH__) <= 0xFF) |
bogdanm | 86:04dd9b1680ae | 717 | |
bogdanm | 86:04dd9b1680ae | 718 | /** @brief Check the receiver timeout value. The maximum SMARTCARD receiver timeout |
bogdanm | 86:04dd9b1680ae | 719 | * value is 0xFFFFFF. |
bogdanm | 86:04dd9b1680ae | 720 | * @param __TIMEOUTVALUE__: receiver timeout value. |
bogdanm | 86:04dd9b1680ae | 721 | * @retval Test result (TRUE or FALSE) |
bogdanm | 86:04dd9b1680ae | 722 | */ |
bogdanm | 86:04dd9b1680ae | 723 | #define IS_SMARTCARD_TIMEOUT_VALUE(__TIMEOUTVALUE__) ((__TIMEOUTVALUE__) <= 0xFFFFFF) |
bogdanm | 86:04dd9b1680ae | 724 | |
bogdanm | 86:04dd9b1680ae | 725 | /** @brief Check the SMARTCARD autoretry counter value. The maximum number of |
bogdanm | 86:04dd9b1680ae | 726 | * retransmissions is 0x7. |
bogdanm | 86:04dd9b1680ae | 727 | * @param __COUNT__: number of retransmissions |
bogdanm | 86:04dd9b1680ae | 728 | * @retval Test result (TRUE or FALSE) |
bogdanm | 86:04dd9b1680ae | 729 | */ |
bogdanm | 86:04dd9b1680ae | 730 | #define IS_SMARTCARD_AUTORETRY_COUNT(__COUNT__) ((__COUNT__) <= 0x7) |
bogdanm | 86:04dd9b1680ae | 731 | |
bogdanm | 86:04dd9b1680ae | 732 | |
bogdanm | 86:04dd9b1680ae | 733 | |
bogdanm | 86:04dd9b1680ae | 734 | /** |
bogdanm | 86:04dd9b1680ae | 735 | * @} |
bogdanm | 86:04dd9b1680ae | 736 | */ |
bogdanm | 86:04dd9b1680ae | 737 | |
bogdanm | 86:04dd9b1680ae | 738 | /* Include SMARTCARD HAL Extension module */ |
bogdanm | 86:04dd9b1680ae | 739 | #include "stm32f3xx_hal_smartcard_ex.h" |
bogdanm | 86:04dd9b1680ae | 740 | |
bogdanm | 86:04dd9b1680ae | 741 | |
bogdanm | 86:04dd9b1680ae | 742 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 86:04dd9b1680ae | 743 | /* Initialization and de-initialization functions ****************************/ |
bogdanm | 86:04dd9b1680ae | 744 | HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 745 | HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 746 | void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 747 | void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 748 | |
bogdanm | 86:04dd9b1680ae | 749 | |
bogdanm | 86:04dd9b1680ae | 750 | /* IO operation functions *****************************************************/ |
bogdanm | 86:04dd9b1680ae | 751 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
bogdanm | 86:04dd9b1680ae | 752 | HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
bogdanm | 86:04dd9b1680ae | 753 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size); |
bogdanm | 86:04dd9b1680ae | 754 | HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size); |
bogdanm | 86:04dd9b1680ae | 755 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size); |
bogdanm | 86:04dd9b1680ae | 756 | HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size); |
bogdanm | 86:04dd9b1680ae | 757 | void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 758 | void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 759 | void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 760 | void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 761 | |
bogdanm | 86:04dd9b1680ae | 762 | /* Peripheral Control functions ***********************************************/ |
bogdanm | 86:04dd9b1680ae | 763 | void SMARTCARD_AdvFeatureConfig(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 764 | |
bogdanm | 86:04dd9b1680ae | 765 | /* Peripheral State and Error functions ***************************************/ |
bogdanm | 86:04dd9b1680ae | 766 | HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 767 | uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsmartcard); |
bogdanm | 86:04dd9b1680ae | 768 | /** |
bogdanm | 86:04dd9b1680ae | 769 | * @} |
bogdanm | 86:04dd9b1680ae | 770 | */ |
bogdanm | 86:04dd9b1680ae | 771 | |
bogdanm | 86:04dd9b1680ae | 772 | /** |
bogdanm | 86:04dd9b1680ae | 773 | * @} |
bogdanm | 86:04dd9b1680ae | 774 | */ |
bogdanm | 86:04dd9b1680ae | 775 | |
bogdanm | 86:04dd9b1680ae | 776 | #ifdef __cplusplus |
bogdanm | 86:04dd9b1680ae | 777 | } |
bogdanm | 86:04dd9b1680ae | 778 | #endif |
bogdanm | 86:04dd9b1680ae | 779 | |
bogdanm | 86:04dd9b1680ae | 780 | #endif /* __STM32F3xx_HAL_SMARTCARD_H */ |
bogdanm | 86:04dd9b1680ae | 781 | |
bogdanm | 86:04dd9b1680ae | 782 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |