mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_STM32L1/stm32l1xx_hal_smartcard.h@636:b0d178e9fa10, 2016-07-07 (annotated)
- Committer:
- lzbpli
- Date:
- Thu Jul 07 06:48:59 2016 +0000
- Revision:
- 636:b0d178e9fa10
- Parent:
- 394:83f921546702
l053
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 354:e67efb2aab0e | 1 | /** |
mbed_official | 354:e67efb2aab0e | 2 | ****************************************************************************** |
mbed_official | 354:e67efb2aab0e | 3 | * @file stm32l1xx_hal_smartcard.h |
mbed_official | 354:e67efb2aab0e | 4 | * @author MCD Application Team |
mbed_official | 354:e67efb2aab0e | 5 | * @version V1.0.0 |
mbed_official | 354:e67efb2aab0e | 6 | * @date 5-September-2014 |
mbed_official | 354:e67efb2aab0e | 7 | * @brief This file contains all the functions prototypes for the SMARTCARD |
mbed_official | 354:e67efb2aab0e | 8 | * firmware library. |
mbed_official | 354:e67efb2aab0e | 9 | ****************************************************************************** |
mbed_official | 354:e67efb2aab0e | 10 | * @attention |
mbed_official | 354:e67efb2aab0e | 11 | * |
mbed_official | 354:e67efb2aab0e | 12 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 354:e67efb2aab0e | 13 | * |
mbed_official | 354:e67efb2aab0e | 14 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 354:e67efb2aab0e | 15 | * are permitted provided that the following conditions are met: |
mbed_official | 354:e67efb2aab0e | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 354:e67efb2aab0e | 17 | * this list of conditions and the following disclaimer. |
mbed_official | 354:e67efb2aab0e | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 354:e67efb2aab0e | 19 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 354:e67efb2aab0e | 20 | * and/or other materials provided with the distribution. |
mbed_official | 354:e67efb2aab0e | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 354:e67efb2aab0e | 22 | * may be used to endorse or promote products derived from this software |
mbed_official | 354:e67efb2aab0e | 23 | * without specific prior written permission. |
mbed_official | 354:e67efb2aab0e | 24 | * |
mbed_official | 354:e67efb2aab0e | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 354:e67efb2aab0e | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 354:e67efb2aab0e | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 354:e67efb2aab0e | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 354:e67efb2aab0e | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 354:e67efb2aab0e | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 354:e67efb2aab0e | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 354:e67efb2aab0e | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 354:e67efb2aab0e | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 354:e67efb2aab0e | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 354:e67efb2aab0e | 35 | * |
mbed_official | 354:e67efb2aab0e | 36 | ****************************************************************************** |
mbed_official | 354:e67efb2aab0e | 37 | */ |
mbed_official | 354:e67efb2aab0e | 38 | |
mbed_official | 354:e67efb2aab0e | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
mbed_official | 354:e67efb2aab0e | 40 | #ifndef __STM32L1xx_HAL_SMARTCARD_H |
mbed_official | 354:e67efb2aab0e | 41 | #define __STM32L1xx_HAL_SMARTCARD_H |
mbed_official | 354:e67efb2aab0e | 42 | |
mbed_official | 354:e67efb2aab0e | 43 | #ifdef __cplusplus |
mbed_official | 354:e67efb2aab0e | 44 | extern "C" { |
mbed_official | 354:e67efb2aab0e | 45 | #endif |
mbed_official | 354:e67efb2aab0e | 46 | |
mbed_official | 354:e67efb2aab0e | 47 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 354:e67efb2aab0e | 48 | #include "stm32l1xx_hal_def.h" |
mbed_official | 354:e67efb2aab0e | 49 | |
mbed_official | 354:e67efb2aab0e | 50 | /** @addtogroup STM32L1xx_HAL_Driver |
mbed_official | 354:e67efb2aab0e | 51 | * @{ |
mbed_official | 354:e67efb2aab0e | 52 | */ |
mbed_official | 354:e67efb2aab0e | 53 | |
mbed_official | 354:e67efb2aab0e | 54 | /** @addtogroup SMARTCARD |
mbed_official | 354:e67efb2aab0e | 55 | * @{ |
mbed_official | 354:e67efb2aab0e | 56 | */ |
mbed_official | 354:e67efb2aab0e | 57 | |
mbed_official | 354:e67efb2aab0e | 58 | /* Exported types ------------------------------------------------------------*/ |
mbed_official | 354:e67efb2aab0e | 59 | /** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types |
mbed_official | 354:e67efb2aab0e | 60 | * @{ |
mbed_official | 354:e67efb2aab0e | 61 | */ |
mbed_official | 354:e67efb2aab0e | 62 | |
mbed_official | 354:e67efb2aab0e | 63 | |
mbed_official | 354:e67efb2aab0e | 64 | /** |
mbed_official | 354:e67efb2aab0e | 65 | * @brief SMARTCARD Init Structure definition |
mbed_official | 354:e67efb2aab0e | 66 | */ |
mbed_official | 354:e67efb2aab0e | 67 | typedef struct |
mbed_official | 354:e67efb2aab0e | 68 | { |
mbed_official | 354:e67efb2aab0e | 69 | uint32_t BaudRate; /*!< This member configures the SmartCard communication baud rate. |
mbed_official | 354:e67efb2aab0e | 70 | The baud rate is computed using the following formula: |
mbed_official | 354:e67efb2aab0e | 71 | - IntegerDivider = ((PCLKx) / (8 * (hsc->Init.BaudRate))) |
mbed_official | 354:e67efb2aab0e | 72 | - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ |
mbed_official | 354:e67efb2aab0e | 73 | |
mbed_official | 354:e67efb2aab0e | 74 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
mbed_official | 354:e67efb2aab0e | 75 | This parameter can be a value of @ref SMARTCARD_Word_Length */ |
mbed_official | 354:e67efb2aab0e | 76 | |
mbed_official | 354:e67efb2aab0e | 77 | uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. |
mbed_official | 354:e67efb2aab0e | 78 | This parameter can be a value of @ref SMARTCARD_Stop_Bits */ |
mbed_official | 354:e67efb2aab0e | 79 | |
mbed_official | 354:e67efb2aab0e | 80 | uint32_t Parity; /*!< Specifies the parity mode. |
mbed_official | 354:e67efb2aab0e | 81 | This parameter can be a value of @ref SMARTCARD_Parity |
mbed_official | 354:e67efb2aab0e | 82 | @note When parity is enabled, the computed parity is inserted |
mbed_official | 354:e67efb2aab0e | 83 | at the MSB position of the transmitted data (9th bit when |
mbed_official | 354:e67efb2aab0e | 84 | the word length is set to 9 data bits; 8th bit when the |
mbed_official | 354:e67efb2aab0e | 85 | word length is set to 8 data bits).*/ |
mbed_official | 354:e67efb2aab0e | 86 | |
mbed_official | 354:e67efb2aab0e | 87 | uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. |
mbed_official | 354:e67efb2aab0e | 88 | This parameter can be a value of @ref SMARTCARD_Mode */ |
mbed_official | 354:e67efb2aab0e | 89 | |
mbed_official | 354:e67efb2aab0e | 90 | uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. |
mbed_official | 354:e67efb2aab0e | 91 | This parameter can be a value of @ref SMARTCARD_Clock_Polarity */ |
mbed_official | 354:e67efb2aab0e | 92 | |
mbed_official | 354:e67efb2aab0e | 93 | uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. |
mbed_official | 354:e67efb2aab0e | 94 | This parameter can be a value of @ref SMARTCARD_Clock_Phase */ |
mbed_official | 354:e67efb2aab0e | 95 | |
mbed_official | 354:e67efb2aab0e | 96 | uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
mbed_official | 354:e67efb2aab0e | 97 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
mbed_official | 354:e67efb2aab0e | 98 | This parameter can be a value of @ref SMARTCARD_Last_Bit */ |
mbed_official | 354:e67efb2aab0e | 99 | |
mbed_official | 354:e67efb2aab0e | 100 | uint32_t Prescaler; /*!< Specifies the SmartCard Prescaler |
mbed_official | 354:e67efb2aab0e | 101 | This parameter must be a number between Min_Data = 0 and Max_Data = 255 */ |
mbed_official | 354:e67efb2aab0e | 102 | |
mbed_official | 354:e67efb2aab0e | 103 | uint32_t GuardTime; /*!< Specifies the SmartCard Guard Time |
mbed_official | 354:e67efb2aab0e | 104 | This parameter must be a number between Min_Data = 0 and Max_Data = 255 */ |
mbed_official | 354:e67efb2aab0e | 105 | |
mbed_official | 354:e67efb2aab0e | 106 | uint32_t NACKState; /*!< Specifies the SmartCard NACK Transmission state |
mbed_official | 354:e67efb2aab0e | 107 | This parameter can be a value of @ref SMARTCARD_NACK_State */ |
mbed_official | 354:e67efb2aab0e | 108 | }SMARTCARD_InitTypeDef; |
mbed_official | 354:e67efb2aab0e | 109 | |
mbed_official | 354:e67efb2aab0e | 110 | /** |
mbed_official | 354:e67efb2aab0e | 111 | * @brief HAL State structures definition |
mbed_official | 354:e67efb2aab0e | 112 | */ |
mbed_official | 354:e67efb2aab0e | 113 | typedef enum |
mbed_official | 354:e67efb2aab0e | 114 | { |
mbed_official | 354:e67efb2aab0e | 115 | HAL_SMARTCARD_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ |
mbed_official | 354:e67efb2aab0e | 116 | HAL_SMARTCARD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
mbed_official | 354:e67efb2aab0e | 117 | HAL_SMARTCARD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
mbed_official | 354:e67efb2aab0e | 118 | HAL_SMARTCARD_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
mbed_official | 354:e67efb2aab0e | 119 | HAL_SMARTCARD_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
mbed_official | 354:e67efb2aab0e | 120 | HAL_SMARTCARD_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ |
mbed_official | 354:e67efb2aab0e | 121 | HAL_SMARTCARD_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
mbed_official | 354:e67efb2aab0e | 122 | HAL_SMARTCARD_STATE_ERROR = 0x04 /*!< Error */ |
mbed_official | 354:e67efb2aab0e | 123 | }HAL_SMARTCARD_StateTypeDef; |
mbed_official | 354:e67efb2aab0e | 124 | |
mbed_official | 354:e67efb2aab0e | 125 | /** |
mbed_official | 354:e67efb2aab0e | 126 | * @brief HAL SMARTCARD Error Code structure definition |
mbed_official | 354:e67efb2aab0e | 127 | */ |
mbed_official | 354:e67efb2aab0e | 128 | typedef enum |
mbed_official | 354:e67efb2aab0e | 129 | { |
mbed_official | 354:e67efb2aab0e | 130 | HAL_SMARTCARD_ERROR_NONE = 0x00, /*!< No error */ |
mbed_official | 354:e67efb2aab0e | 131 | HAL_SMARTCARD_ERROR_PE = 0x01, /*!< Parity error */ |
mbed_official | 354:e67efb2aab0e | 132 | HAL_SMARTCARD_ERROR_NE = 0x02, /*!< Noise error */ |
mbed_official | 354:e67efb2aab0e | 133 | HAL_SMARTCARD_ERROR_FE = 0x04, /*!< frame error */ |
mbed_official | 354:e67efb2aab0e | 134 | HAL_SMARTCARD_ERROR_ORE = 0x08, /*!< Overrun error */ |
mbed_official | 354:e67efb2aab0e | 135 | HAL_SMARTCARD_ERROR_DMA = 0x10 /*!< DMA transfer error */ |
mbed_official | 354:e67efb2aab0e | 136 | }HAL_SMARTCARD_ErrorTypeDef; |
mbed_official | 354:e67efb2aab0e | 137 | |
mbed_official | 354:e67efb2aab0e | 138 | /** |
mbed_official | 354:e67efb2aab0e | 139 | * @brief SMARTCARD handle Structure definition |
mbed_official | 354:e67efb2aab0e | 140 | */ |
mbed_official | 354:e67efb2aab0e | 141 | typedef struct |
mbed_official | 354:e67efb2aab0e | 142 | { |
mbed_official | 354:e67efb2aab0e | 143 | USART_TypeDef *Instance; /* USART registers base address */ |
mbed_official | 354:e67efb2aab0e | 144 | |
mbed_official | 354:e67efb2aab0e | 145 | SMARTCARD_InitTypeDef Init; /* SmartCard communication parameters */ |
mbed_official | 354:e67efb2aab0e | 146 | |
mbed_official | 354:e67efb2aab0e | 147 | uint8_t *pTxBuffPtr; /* Pointer to SmartCard Tx transfer Buffer */ |
mbed_official | 354:e67efb2aab0e | 148 | |
mbed_official | 354:e67efb2aab0e | 149 | uint16_t TxXferSize; /* SmartCard Tx Transfer size */ |
mbed_official | 354:e67efb2aab0e | 150 | |
mbed_official | 354:e67efb2aab0e | 151 | uint16_t TxXferCount; /* SmartCard Tx Transfer Counter */ |
mbed_official | 354:e67efb2aab0e | 152 | |
mbed_official | 354:e67efb2aab0e | 153 | uint8_t *pRxBuffPtr; /* Pointer to SmartCard Rx transfer Buffer */ |
mbed_official | 354:e67efb2aab0e | 154 | |
mbed_official | 354:e67efb2aab0e | 155 | uint16_t RxXferSize; /* SmartCard Rx Transfer size */ |
mbed_official | 354:e67efb2aab0e | 156 | |
mbed_official | 354:e67efb2aab0e | 157 | uint16_t RxXferCount; /* SmartCard Rx Transfer Counter */ |
mbed_official | 354:e67efb2aab0e | 158 | |
mbed_official | 354:e67efb2aab0e | 159 | DMA_HandleTypeDef *hdmatx; /* SmartCard Tx DMA Handle parameters */ |
mbed_official | 354:e67efb2aab0e | 160 | |
mbed_official | 354:e67efb2aab0e | 161 | DMA_HandleTypeDef *hdmarx; /* SmartCard Rx DMA Handle parameters */ |
mbed_official | 354:e67efb2aab0e | 162 | |
mbed_official | 354:e67efb2aab0e | 163 | HAL_LockTypeDef Lock; /* Locking object */ |
mbed_official | 354:e67efb2aab0e | 164 | |
mbed_official | 354:e67efb2aab0e | 165 | __IO HAL_SMARTCARD_StateTypeDef State; /* SmartCard communication state */ |
mbed_official | 354:e67efb2aab0e | 166 | |
mbed_official | 354:e67efb2aab0e | 167 | __IO HAL_SMARTCARD_ErrorTypeDef ErrorCode; /* SmartCard Error code */ |
mbed_official | 354:e67efb2aab0e | 168 | }SMARTCARD_HandleTypeDef; |
mbed_official | 354:e67efb2aab0e | 169 | |
mbed_official | 354:e67efb2aab0e | 170 | /** |
mbed_official | 354:e67efb2aab0e | 171 | * @} |
mbed_official | 354:e67efb2aab0e | 172 | */ |
mbed_official | 354:e67efb2aab0e | 173 | |
mbed_official | 354:e67efb2aab0e | 174 | /* Exported constants --------------------------------------------------------*/ |
mbed_official | 354:e67efb2aab0e | 175 | /** @defgroup SMARTCARD_Exported_Constants SMARTCARD Exported constants |
mbed_official | 354:e67efb2aab0e | 176 | * @{ |
mbed_official | 354:e67efb2aab0e | 177 | */ |
mbed_official | 354:e67efb2aab0e | 178 | |
mbed_official | 354:e67efb2aab0e | 179 | /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length |
mbed_official | 354:e67efb2aab0e | 180 | * @{ |
mbed_official | 354:e67efb2aab0e | 181 | */ |
mbed_official | 354:e67efb2aab0e | 182 | #define SMARTCARD_WORDLENGTH_8B ((uint32_t)0x00000000) |
mbed_official | 354:e67efb2aab0e | 183 | #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M) |
mbed_official | 354:e67efb2aab0e | 184 | #define IS_SMARTCARD_WORD_LENGTH(LENGTH) ((LENGTH) == SMARTCARD_WORDLENGTH_9B) |
mbed_official | 354:e67efb2aab0e | 185 | /** |
mbed_official | 354:e67efb2aab0e | 186 | * @} |
mbed_official | 354:e67efb2aab0e | 187 | */ |
mbed_official | 354:e67efb2aab0e | 188 | |
mbed_official | 354:e67efb2aab0e | 189 | /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits |
mbed_official | 354:e67efb2aab0e | 190 | * @{ |
mbed_official | 354:e67efb2aab0e | 191 | */ |
mbed_official | 354:e67efb2aab0e | 192 | #define SMARTCARD_STOPBITS_1 ((uint32_t)0x00000000) |
mbed_official | 354:e67efb2aab0e | 193 | #define SMARTCARD_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) |
mbed_official | 354:e67efb2aab0e | 194 | #define SMARTCARD_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) |
mbed_official | 354:e67efb2aab0e | 195 | #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) |
mbed_official | 354:e67efb2aab0e | 196 | #define IS_SMARTCARD_STOPBITS(STOPBITS) (((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \ |
mbed_official | 354:e67efb2aab0e | 197 | ((STOPBITS) == SMARTCARD_STOPBITS_1_5)) |
mbed_official | 354:e67efb2aab0e | 198 | /** |
mbed_official | 354:e67efb2aab0e | 199 | * @} |
mbed_official | 354:e67efb2aab0e | 200 | */ |
mbed_official | 354:e67efb2aab0e | 201 | |
mbed_official | 354:e67efb2aab0e | 202 | /** @defgroup SMARTCARD_Parity SMARTCARD Parity |
mbed_official | 354:e67efb2aab0e | 203 | * @{ |
mbed_official | 354:e67efb2aab0e | 204 | */ |
mbed_official | 354:e67efb2aab0e | 205 | #define SMARTCARD_PARITY_NONE ((uint32_t)0x00000000) |
mbed_official | 354:e67efb2aab0e | 206 | #define SMARTCARD_PARITY_EVEN ((uint32_t)USART_CR1_PCE) |
mbed_official | 354:e67efb2aab0e | 207 | #define SMARTCARD_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) |
mbed_official | 354:e67efb2aab0e | 208 | #define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_EVEN) || \ |
mbed_official | 354:e67efb2aab0e | 209 | ((PARITY) == SMARTCARD_PARITY_ODD)) |
mbed_official | 354:e67efb2aab0e | 210 | /** |
mbed_official | 354:e67efb2aab0e | 211 | * @} |
mbed_official | 354:e67efb2aab0e | 212 | */ |
mbed_official | 354:e67efb2aab0e | 213 | |
mbed_official | 354:e67efb2aab0e | 214 | /** @defgroup SMARTCARD_Mode SMARTCARD Mode |
mbed_official | 354:e67efb2aab0e | 215 | * @{ |
mbed_official | 354:e67efb2aab0e | 216 | */ |
mbed_official | 354:e67efb2aab0e | 217 | #define SMARTCARD_MODE_RX ((uint32_t)USART_CR1_RE) |
mbed_official | 354:e67efb2aab0e | 218 | #define SMARTCARD_MODE_TX ((uint32_t)USART_CR1_TE) |
mbed_official | 354:e67efb2aab0e | 219 | #define SMARTCARD_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) |
mbed_official | 354:e67efb2aab0e | 220 | #define IS_SMARTCARD_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3) == 0x00) && ((MODE) != (uint32_t)0x00000000)) |
mbed_official | 354:e67efb2aab0e | 221 | /** |
mbed_official | 354:e67efb2aab0e | 222 | * @} |
mbed_official | 354:e67efb2aab0e | 223 | */ |
mbed_official | 354:e67efb2aab0e | 224 | |
mbed_official | 354:e67efb2aab0e | 225 | /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity |
mbed_official | 354:e67efb2aab0e | 226 | * @{ |
mbed_official | 354:e67efb2aab0e | 227 | */ |
mbed_official | 354:e67efb2aab0e | 228 | #define SMARTCARD_POLARITY_LOW ((uint32_t)0x00000000) |
mbed_official | 354:e67efb2aab0e | 229 | #define SMARTCARD_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) |
mbed_official | 354:e67efb2aab0e | 230 | #define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH)) |
mbed_official | 354:e67efb2aab0e | 231 | /** |
mbed_official | 354:e67efb2aab0e | 232 | * @} |
mbed_official | 354:e67efb2aab0e | 233 | */ |
mbed_official | 354:e67efb2aab0e | 234 | |
mbed_official | 354:e67efb2aab0e | 235 | /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase |
mbed_official | 354:e67efb2aab0e | 236 | * @{ |
mbed_official | 354:e67efb2aab0e | 237 | */ |
mbed_official | 354:e67efb2aab0e | 238 | #define SMARTCARD_PHASE_1EDGE ((uint32_t)0x00000000) |
mbed_official | 354:e67efb2aab0e | 239 | #define SMARTCARD_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) |
mbed_official | 354:e67efb2aab0e | 240 | #define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE)) |
mbed_official | 354:e67efb2aab0e | 241 | /** |
mbed_official | 354:e67efb2aab0e | 242 | * @} |
mbed_official | 354:e67efb2aab0e | 243 | */ |
mbed_official | 354:e67efb2aab0e | 244 | |
mbed_official | 354:e67efb2aab0e | 245 | /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit |
mbed_official | 354:e67efb2aab0e | 246 | * @{ |
mbed_official | 354:e67efb2aab0e | 247 | */ |
mbed_official | 354:e67efb2aab0e | 248 | #define SMARTCARD_LASTBIT_DISABLE ((uint32_t)0x00000000) |
mbed_official | 354:e67efb2aab0e | 249 | #define SMARTCARD_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) |
mbed_official | 354:e67efb2aab0e | 250 | #define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \ |
mbed_official | 354:e67efb2aab0e | 251 | ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE)) |
mbed_official | 354:e67efb2aab0e | 252 | /** |
mbed_official | 354:e67efb2aab0e | 253 | * @} |
mbed_official | 354:e67efb2aab0e | 254 | */ |
mbed_official | 354:e67efb2aab0e | 255 | |
mbed_official | 354:e67efb2aab0e | 256 | /** @defgroup SMARTCARD_NACK_State SMARTCARD NACK State |
mbed_official | 354:e67efb2aab0e | 257 | * @{ |
mbed_official | 354:e67efb2aab0e | 258 | */ |
mbed_official | 354:e67efb2aab0e | 259 | #define SMARTCARD_NACK_ENABLED ((uint32_t)USART_CR3_NACK) |
mbed_official | 354:e67efb2aab0e | 260 | #define SMARTCARD_NACK_DISABLED ((uint32_t)0x00000000) |
mbed_official | 354:e67efb2aab0e | 261 | #define IS_SMARTCARD_NACK_STATE(NACK) (((NACK) == SMARTCARD_NACK_ENABLED) || \ |
mbed_official | 354:e67efb2aab0e | 262 | ((NACK) == SMARTCARD_NACK_DISABLED)) |
mbed_official | 354:e67efb2aab0e | 263 | /** |
mbed_official | 354:e67efb2aab0e | 264 | * @} |
mbed_official | 354:e67efb2aab0e | 265 | */ |
mbed_official | 354:e67efb2aab0e | 266 | |
mbed_official | 354:e67efb2aab0e | 267 | /** @defgroup SMARTCARD_DMA_Requests SMARTCARD DMA requests |
mbed_official | 354:e67efb2aab0e | 268 | * @{ |
mbed_official | 354:e67efb2aab0e | 269 | */ |
mbed_official | 354:e67efb2aab0e | 270 | |
mbed_official | 354:e67efb2aab0e | 271 | #define SMARTCARD_DMAREQ_TX ((uint32_t)USART_CR3_DMAT) |
mbed_official | 354:e67efb2aab0e | 272 | #define SMARTCARD_DMAREQ_RX ((uint32_t)USART_CR3_DMAR) |
mbed_official | 354:e67efb2aab0e | 273 | |
mbed_official | 354:e67efb2aab0e | 274 | /** |
mbed_official | 354:e67efb2aab0e | 275 | * @} |
mbed_official | 354:e67efb2aab0e | 276 | */ |
mbed_official | 354:e67efb2aab0e | 277 | |
mbed_official | 354:e67efb2aab0e | 278 | /** @defgroup SMARTCARD_Flags SMARTCARD Flags |
mbed_official | 354:e67efb2aab0e | 279 | * Elements values convention: 0xXXXX |
mbed_official | 354:e67efb2aab0e | 280 | * - 0xXXXX : Flag mask in the SR register |
mbed_official | 354:e67efb2aab0e | 281 | * @{ |
mbed_official | 354:e67efb2aab0e | 282 | */ |
mbed_official | 354:e67efb2aab0e | 283 | |
mbed_official | 354:e67efb2aab0e | 284 | #define SMARTCARD_FLAG_TXE ((uint32_t)USART_SR_TXE) |
mbed_official | 354:e67efb2aab0e | 285 | #define SMARTCARD_FLAG_TC ((uint32_t)USART_SR_TC) |
mbed_official | 354:e67efb2aab0e | 286 | #define SMARTCARD_FLAG_RXNE ((uint32_t)USART_SR_RXNE) |
mbed_official | 354:e67efb2aab0e | 287 | #define SMARTCARD_FLAG_IDLE ((uint32_t)USART_SR_IDLE) |
mbed_official | 354:e67efb2aab0e | 288 | #define SMARTCARD_FLAG_ORE ((uint32_t)USART_SR_ORE) |
mbed_official | 354:e67efb2aab0e | 289 | #define SMARTCARD_FLAG_NE ((uint32_t)USART_SR_NE) |
mbed_official | 354:e67efb2aab0e | 290 | #define SMARTCARD_FLAG_FE ((uint32_t)USART_SR_FE) |
mbed_official | 354:e67efb2aab0e | 291 | #define SMARTCARD_FLAG_PE ((uint32_t)USART_SR_PE) |
mbed_official | 354:e67efb2aab0e | 292 | /** |
mbed_official | 354:e67efb2aab0e | 293 | * @} |
mbed_official | 354:e67efb2aab0e | 294 | */ |
mbed_official | 354:e67efb2aab0e | 295 | |
mbed_official | 354:e67efb2aab0e | 296 | /** @defgroup SMARTCARD_Interrupt_definition SMARTCARD Interrupts Definition |
mbed_official | 354:e67efb2aab0e | 297 | * Elements values convention: 0xY000XXXX |
mbed_official | 354:e67efb2aab0e | 298 | * - XXXX : Interrupt mask in the XX register |
mbed_official | 354:e67efb2aab0e | 299 | * - Y : Interrupt source register (4 bits) |
mbed_official | 354:e67efb2aab0e | 300 | * - 01: CR1 register |
mbed_official | 354:e67efb2aab0e | 301 | * - 10: CR3 register |
mbed_official | 354:e67efb2aab0e | 302 | |
mbed_official | 354:e67efb2aab0e | 303 | * |
mbed_official | 354:e67efb2aab0e | 304 | * @{ |
mbed_official | 354:e67efb2aab0e | 305 | */ |
mbed_official | 354:e67efb2aab0e | 306 | #define SMARTCARD_IT_PE ((uint32_t)0x10000100) |
mbed_official | 354:e67efb2aab0e | 307 | #define SMARTCARD_IT_TXE ((uint32_t)0x10000080) |
mbed_official | 354:e67efb2aab0e | 308 | #define SMARTCARD_IT_TC ((uint32_t)0x10000040) |
mbed_official | 354:e67efb2aab0e | 309 | #define SMARTCARD_IT_RXNE ((uint32_t)0x10000020) |
mbed_official | 354:e67efb2aab0e | 310 | #define SMARTCARD_IT_IDLE ((uint32_t)0x10000010) |
mbed_official | 354:e67efb2aab0e | 311 | #define SMARTCARD_IT_ERR ((uint32_t)0x20000001) |
mbed_official | 354:e67efb2aab0e | 312 | |
mbed_official | 354:e67efb2aab0e | 313 | /** |
mbed_official | 354:e67efb2aab0e | 314 | * @} |
mbed_official | 354:e67efb2aab0e | 315 | */ |
mbed_official | 354:e67efb2aab0e | 316 | |
mbed_official | 354:e67efb2aab0e | 317 | /** @defgroup SMARTCARD_Interruption_Mask SMARTCARD interruptions flag mask |
mbed_official | 354:e67efb2aab0e | 318 | * @{ |
mbed_official | 354:e67efb2aab0e | 319 | */ |
mbed_official | 354:e67efb2aab0e | 320 | #define SMARTCARD_IT_MASK ((uint32_t)0x0000FFFF) |
mbed_official | 354:e67efb2aab0e | 321 | /** |
mbed_official | 354:e67efb2aab0e | 322 | * @} |
mbed_official | 354:e67efb2aab0e | 323 | */ |
mbed_official | 354:e67efb2aab0e | 324 | |
mbed_official | 354:e67efb2aab0e | 325 | /** |
mbed_official | 354:e67efb2aab0e | 326 | * @} |
mbed_official | 354:e67efb2aab0e | 327 | */ |
mbed_official | 354:e67efb2aab0e | 328 | |
mbed_official | 354:e67efb2aab0e | 329 | /* Exported macro ------------------------------------------------------------*/ |
mbed_official | 354:e67efb2aab0e | 330 | /** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros |
mbed_official | 354:e67efb2aab0e | 331 | * @{ |
mbed_official | 354:e67efb2aab0e | 332 | */ |
mbed_official | 354:e67efb2aab0e | 333 | |
mbed_official | 354:e67efb2aab0e | 334 | |
mbed_official | 354:e67efb2aab0e | 335 | /** @brief Reset SMARTCARD handle state |
mbed_official | 354:e67efb2aab0e | 336 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 337 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 338 | * @retval None |
mbed_official | 354:e67efb2aab0e | 339 | */ |
mbed_official | 354:e67efb2aab0e | 340 | #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMARTCARD_STATE_RESET) |
mbed_official | 354:e67efb2aab0e | 341 | |
mbed_official | 354:e67efb2aab0e | 342 | /** @brief Flushs the Smartcard DR register |
mbed_official | 354:e67efb2aab0e | 343 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 344 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 345 | */ |
mbed_official | 354:e67efb2aab0e | 346 | #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) |
mbed_official | 354:e67efb2aab0e | 347 | |
mbed_official | 354:e67efb2aab0e | 348 | /** @brief Checks whether the specified Smartcard flag is set or not. |
mbed_official | 354:e67efb2aab0e | 349 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 350 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 351 | * @param __FLAG__: specifies the flag to check. |
mbed_official | 354:e67efb2aab0e | 352 | * This parameter can be one of the following values: |
mbed_official | 354:e67efb2aab0e | 353 | * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag |
mbed_official | 354:e67efb2aab0e | 354 | * @arg SMARTCARD_FLAG_TC: Transmission Complete flag |
mbed_official | 354:e67efb2aab0e | 355 | * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag |
mbed_official | 354:e67efb2aab0e | 356 | * @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag |
mbed_official | 354:e67efb2aab0e | 357 | * @arg SMARTCARD_FLAG_ORE: OverRun Error flag |
mbed_official | 354:e67efb2aab0e | 358 | * @arg SMARTCARD_FLAG_NE: Noise Error flag |
mbed_official | 354:e67efb2aab0e | 359 | * @arg SMARTCARD_FLAG_FE: Framing Error flag |
mbed_official | 354:e67efb2aab0e | 360 | * @arg SMARTCARD_FLAG_PE: Parity Error flag |
mbed_official | 354:e67efb2aab0e | 361 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
mbed_official | 354:e67efb2aab0e | 362 | */ |
mbed_official | 354:e67efb2aab0e | 363 | #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
mbed_official | 354:e67efb2aab0e | 364 | |
mbed_official | 354:e67efb2aab0e | 365 | /** @brief Clears the specified Smartcard pending flags. |
mbed_official | 354:e67efb2aab0e | 366 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 367 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 368 | * @param __FLAG__: specifies the flag to check. |
mbed_official | 354:e67efb2aab0e | 369 | * This parameter can be any combination of the following values: |
mbed_official | 354:e67efb2aab0e | 370 | * @arg SMARTCARD_FLAG_TC: Transmission Complete flag. |
mbed_official | 354:e67efb2aab0e | 371 | * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag. |
mbed_official | 354:e67efb2aab0e | 372 | * |
mbed_official | 354:e67efb2aab0e | 373 | * @note PE (Parity error), FE (Framing error), NE (Noise error) and ORE (OverRun |
mbed_official | 354:e67efb2aab0e | 374 | * error) flags are cleared by software sequence: a read operation to |
mbed_official | 354:e67efb2aab0e | 375 | * USART_SR register followed by a read operation to USART_DR register. |
mbed_official | 354:e67efb2aab0e | 376 | * @note RXNE flag can be also cleared by a read to the USART_DR register. |
mbed_official | 354:e67efb2aab0e | 377 | * @note TC flag can be also cleared by software sequence: a read operation to |
mbed_official | 354:e67efb2aab0e | 378 | * USART_SR register followed by a write operation to USART_DR register. |
mbed_official | 354:e67efb2aab0e | 379 | * @note TXE flag is cleared only by a write to the USART_DR register. |
mbed_official | 354:e67efb2aab0e | 380 | * |
mbed_official | 354:e67efb2aab0e | 381 | * @retval None |
mbed_official | 354:e67efb2aab0e | 382 | */ |
mbed_official | 354:e67efb2aab0e | 383 | #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) |
mbed_official | 354:e67efb2aab0e | 384 | |
mbed_official | 354:e67efb2aab0e | 385 | /** @brief Clear the SMARTCARD PE pending flag. |
mbed_official | 354:e67efb2aab0e | 386 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 354:e67efb2aab0e | 387 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 388 | * @retval None |
mbed_official | 354:e67efb2aab0e | 389 | */ |
mbed_official | 354:e67efb2aab0e | 390 | #define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\ |
mbed_official | 354:e67efb2aab0e | 391 | (__HANDLE__)->Instance->DR;}while(0) |
mbed_official | 354:e67efb2aab0e | 392 | /** @brief Clear the SMARTCARD FE pending flag. |
mbed_official | 354:e67efb2aab0e | 393 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 354:e67efb2aab0e | 394 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 395 | * @retval None |
mbed_official | 354:e67efb2aab0e | 396 | */ |
mbed_official | 354:e67efb2aab0e | 397 | #define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) |
mbed_official | 354:e67efb2aab0e | 398 | |
mbed_official | 354:e67efb2aab0e | 399 | /** @brief Clear the SMARTCARD NE pending flag. |
mbed_official | 354:e67efb2aab0e | 400 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 354:e67efb2aab0e | 401 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 402 | * @retval None |
mbed_official | 354:e67efb2aab0e | 403 | */ |
mbed_official | 354:e67efb2aab0e | 404 | #define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) |
mbed_official | 354:e67efb2aab0e | 405 | |
mbed_official | 354:e67efb2aab0e | 406 | /** @brief Clear the SMARTCARD ORE pending flag. |
mbed_official | 354:e67efb2aab0e | 407 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 354:e67efb2aab0e | 408 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 409 | * @retval None |
mbed_official | 354:e67efb2aab0e | 410 | */ |
mbed_official | 354:e67efb2aab0e | 411 | #define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) |
mbed_official | 354:e67efb2aab0e | 412 | |
mbed_official | 354:e67efb2aab0e | 413 | /** @brief Clear the SMARTCARD IDLE pending flag. |
mbed_official | 354:e67efb2aab0e | 414 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 354:e67efb2aab0e | 415 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 416 | * @retval None |
mbed_official | 354:e67efb2aab0e | 417 | */ |
mbed_official | 354:e67efb2aab0e | 418 | #define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) |
mbed_official | 354:e67efb2aab0e | 419 | |
mbed_official | 354:e67efb2aab0e | 420 | /** @brief Enables the specified SmartCard interrupt. |
mbed_official | 354:e67efb2aab0e | 421 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 422 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 423 | * @param __INTERRUPT__: specifies the SMARTCARD interrupt to enable. |
mbed_official | 354:e67efb2aab0e | 424 | * This parameter can be one of the following values: |
mbed_official | 354:e67efb2aab0e | 425 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
mbed_official | 354:e67efb2aab0e | 426 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
mbed_official | 354:e67efb2aab0e | 427 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
mbed_official | 354:e67efb2aab0e | 428 | * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt |
mbed_official | 354:e67efb2aab0e | 429 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
mbed_official | 354:e67efb2aab0e | 430 | * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
mbed_official | 354:e67efb2aab0e | 431 | */ |
mbed_official | 354:e67efb2aab0e | 432 | #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)): \ |
mbed_official | 354:e67efb2aab0e | 433 | ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK))) |
mbed_official | 354:e67efb2aab0e | 434 | |
mbed_official | 354:e67efb2aab0e | 435 | /** @brief Disables the specified SmartCard interrupts. |
mbed_official | 354:e67efb2aab0e | 436 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 437 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 438 | * @param __INTERRUPT__: specifies the SMARTCARD interrupt to disable. |
mbed_official | 354:e67efb2aab0e | 439 | * This parameter can be one of the following values: |
mbed_official | 354:e67efb2aab0e | 440 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
mbed_official | 354:e67efb2aab0e | 441 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
mbed_official | 354:e67efb2aab0e | 442 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
mbed_official | 354:e67efb2aab0e | 443 | * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt |
mbed_official | 354:e67efb2aab0e | 444 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
mbed_official | 354:e67efb2aab0e | 445 | * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
mbed_official | 354:e67efb2aab0e | 446 | */ |
mbed_official | 354:e67efb2aab0e | 447 | #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & SMARTCARD_IT_MASK)): \ |
mbed_official | 354:e67efb2aab0e | 448 | ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK))) |
mbed_official | 354:e67efb2aab0e | 449 | |
mbed_official | 354:e67efb2aab0e | 450 | /** @brief Checks whether the specified SmartCard interrupt has occurred or not. |
mbed_official | 354:e67efb2aab0e | 451 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 452 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 453 | * @param __IT__: specifies the SMARTCARD interrupt source to check. |
mbed_official | 354:e67efb2aab0e | 454 | * This parameter can be one of the following values: |
mbed_official | 354:e67efb2aab0e | 455 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
mbed_official | 354:e67efb2aab0e | 456 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
mbed_official | 354:e67efb2aab0e | 457 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
mbed_official | 354:e67efb2aab0e | 458 | * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt |
mbed_official | 354:e67efb2aab0e | 459 | * @arg SMARTCARD_IT_ERR: Error interrupt |
mbed_official | 354:e67efb2aab0e | 460 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
mbed_official | 354:e67efb2aab0e | 461 | * @retval The new state of __IT__ (TRUE or FALSE). |
mbed_official | 354:e67efb2aab0e | 462 | */ |
mbed_official | 354:e67efb2aab0e | 463 | #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1: (__HANDLE__)->Instance->CR3) & (((uint32_t)(__IT__)) & SMARTCARD_IT_MASK)) |
mbed_official | 354:e67efb2aab0e | 464 | |
mbed_official | 354:e67efb2aab0e | 465 | /** @brief Enable the USART associated to the SMARTCARD Handle |
mbed_official | 354:e67efb2aab0e | 466 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 467 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 468 | * @retval None |
mbed_official | 354:e67efb2aab0e | 469 | */ |
mbed_official | 354:e67efb2aab0e | 470 | #define __HAL_SMARTCARD_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE)) |
mbed_official | 354:e67efb2aab0e | 471 | |
mbed_official | 354:e67efb2aab0e | 472 | /** @brief Disable the USART associated to the SMARTCARD Handle |
mbed_official | 354:e67efb2aab0e | 473 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 354:e67efb2aab0e | 474 | * This parameter can be USARTx with x: 1, 2 or 3. |
mbed_official | 354:e67efb2aab0e | 475 | * @retval None |
mbed_official | 354:e67efb2aab0e | 476 | */ |
mbed_official | 354:e67efb2aab0e | 477 | #define __HAL_SMARTCARD_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE)) |
mbed_official | 354:e67efb2aab0e | 478 | |
mbed_official | 354:e67efb2aab0e | 479 | |
mbed_official | 354:e67efb2aab0e | 480 | /** |
mbed_official | 354:e67efb2aab0e | 481 | * @} |
mbed_official | 354:e67efb2aab0e | 482 | */ |
mbed_official | 354:e67efb2aab0e | 483 | |
mbed_official | 354:e67efb2aab0e | 484 | /* Private macros --------------------------------------------------------*/ |
mbed_official | 354:e67efb2aab0e | 485 | /** @defgroup SMARTCARD_Private_Macros SMARTCARD Private Macros |
mbed_official | 354:e67efb2aab0e | 486 | * @{ |
mbed_official | 354:e67efb2aab0e | 487 | */ |
mbed_official | 354:e67efb2aab0e | 488 | |
mbed_official | 354:e67efb2aab0e | 489 | /** @brief Macros to enable or disable the SmartCard DMA request. |
mbed_official | 354:e67efb2aab0e | 490 | * @param __HANDLE__: specifies the SmartCard Handle. |
mbed_official | 354:e67efb2aab0e | 491 | * @param __REQUEST__: specifies the SmartCard DMA request. |
mbed_official | 354:e67efb2aab0e | 492 | * This parameter can be one of the following values: |
mbed_official | 354:e67efb2aab0e | 493 | * @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request |
mbed_official | 354:e67efb2aab0e | 494 | * @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request |
mbed_official | 354:e67efb2aab0e | 495 | */ |
mbed_official | 354:e67efb2aab0e | 496 | #define SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__) (SET_BIT((__HANDLE__)->Instance->CR3, (__REQUEST__))) |
mbed_official | 354:e67efb2aab0e | 497 | #define SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__) (CLEAR_BIT((__HANDLE__)->Instance->CR3, (__REQUEST__))) |
mbed_official | 354:e67efb2aab0e | 498 | |
mbed_official | 354:e67efb2aab0e | 499 | #define SMARTCARD_DIV(__PCLK__, __BAUD__) (((__PCLK__)*25)/(4*(__BAUD__))) |
mbed_official | 354:e67efb2aab0e | 500 | #define SMARTCARD_DIVMANT(__PCLK__, __BAUD__) (SMARTCARD_DIV((__PCLK__), (__BAUD__))/100) |
mbed_official | 354:e67efb2aab0e | 501 | #define SMARTCARD_DIVFRAQ(__PCLK__, __BAUD__) (((SMARTCARD_DIV((__PCLK__), (__BAUD__)) - (SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) * 100)) * 16 + 50) / 100) |
mbed_official | 354:e67efb2aab0e | 502 | #define SMARTCARD_BRR(__PCLK__, __BAUD__) ((SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) << 4)|(SMARTCARD_DIVFRAQ((__PCLK__), (__BAUD__)) & 0x0F)) |
mbed_official | 354:e67efb2aab0e | 503 | |
mbed_official | 354:e67efb2aab0e | 504 | /** @brief Check the Baud rate range. The maximum Baud Rate is derived from the |
mbed_official | 354:e67efb2aab0e | 505 | * maximum clock on L1 (i.e. 32 MHz) divided by the oversampling used |
mbed_official | 354:e67efb2aab0e | 506 | * on the SMARTCARD (i.e. 16). No overSampling by 16 on Smartcard. |
mbed_official | 354:e67efb2aab0e | 507 | * @param __BAUDRATE__: Baud rate set by the configuration function. |
mbed_official | 354:e67efb2aab0e | 508 | * @retval Test result (TRUE or FALSE) |
mbed_official | 354:e67efb2aab0e | 509 | */ |
mbed_official | 354:e67efb2aab0e | 510 | #define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 2000001) |
mbed_official | 354:e67efb2aab0e | 511 | /** |
mbed_official | 354:e67efb2aab0e | 512 | * @} |
mbed_official | 354:e67efb2aab0e | 513 | */ |
mbed_official | 354:e67efb2aab0e | 514 | |
mbed_official | 354:e67efb2aab0e | 515 | |
mbed_official | 354:e67efb2aab0e | 516 | /* Exported functions --------------------------------------------------------*/ |
mbed_official | 354:e67efb2aab0e | 517 | |
mbed_official | 354:e67efb2aab0e | 518 | /** @addtogroup SMARTCARD_Exported_Functions SMARTCARD Exported Functions |
mbed_official | 354:e67efb2aab0e | 519 | * @{ |
mbed_official | 354:e67efb2aab0e | 520 | */ |
mbed_official | 354:e67efb2aab0e | 521 | |
mbed_official | 354:e67efb2aab0e | 522 | /** @addtogroup SMARTCARD_Exported_Functions_Group1 SmartCard Initialization and de-initialization functions |
mbed_official | 354:e67efb2aab0e | 523 | * @{ |
mbed_official | 354:e67efb2aab0e | 524 | */ |
mbed_official | 354:e67efb2aab0e | 525 | |
mbed_official | 354:e67efb2aab0e | 526 | /* Initialization/de-initialization functions **********************************/ |
mbed_official | 354:e67efb2aab0e | 527 | HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 528 | HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 529 | HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 530 | void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 531 | void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 532 | |
mbed_official | 354:e67efb2aab0e | 533 | /** |
mbed_official | 354:e67efb2aab0e | 534 | * @} |
mbed_official | 354:e67efb2aab0e | 535 | */ |
mbed_official | 354:e67efb2aab0e | 536 | |
mbed_official | 354:e67efb2aab0e | 537 | /** @addtogroup SMARTCARD_Exported_Functions_Group2 IO operation functions |
mbed_official | 354:e67efb2aab0e | 538 | * @{ |
mbed_official | 354:e67efb2aab0e | 539 | */ |
mbed_official | 354:e67efb2aab0e | 540 | |
mbed_official | 354:e67efb2aab0e | 541 | /* IO operation functions *******************************************************/ |
mbed_official | 354:e67efb2aab0e | 542 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
mbed_official | 354:e67efb2aab0e | 543 | HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
mbed_official | 354:e67efb2aab0e | 544 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
mbed_official | 354:e67efb2aab0e | 545 | HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
mbed_official | 354:e67efb2aab0e | 546 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
mbed_official | 354:e67efb2aab0e | 547 | HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
mbed_official | 354:e67efb2aab0e | 548 | void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 549 | void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 550 | void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 551 | void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 552 | |
mbed_official | 354:e67efb2aab0e | 553 | /** |
mbed_official | 354:e67efb2aab0e | 554 | * @} |
mbed_official | 354:e67efb2aab0e | 555 | */ |
mbed_official | 354:e67efb2aab0e | 556 | |
mbed_official | 354:e67efb2aab0e | 557 | /** @addtogroup SMARTCARD_Exported_Functions_Group3 Peripheral State and Errors functions |
mbed_official | 354:e67efb2aab0e | 558 | * @{ |
mbed_official | 354:e67efb2aab0e | 559 | */ |
mbed_official | 354:e67efb2aab0e | 560 | |
mbed_official | 354:e67efb2aab0e | 561 | /* Peripheral State and Errors functions functions *****************************/ |
mbed_official | 354:e67efb2aab0e | 562 | HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 563 | uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 354:e67efb2aab0e | 564 | |
mbed_official | 354:e67efb2aab0e | 565 | /** |
mbed_official | 354:e67efb2aab0e | 566 | * @} |
mbed_official | 354:e67efb2aab0e | 567 | */ |
mbed_official | 354:e67efb2aab0e | 568 | |
mbed_official | 354:e67efb2aab0e | 569 | /** |
mbed_official | 354:e67efb2aab0e | 570 | * @} |
mbed_official | 354:e67efb2aab0e | 571 | */ |
mbed_official | 354:e67efb2aab0e | 572 | |
mbed_official | 354:e67efb2aab0e | 573 | /** |
mbed_official | 354:e67efb2aab0e | 574 | * @} |
mbed_official | 354:e67efb2aab0e | 575 | */ |
mbed_official | 354:e67efb2aab0e | 576 | |
mbed_official | 354:e67efb2aab0e | 577 | /** |
mbed_official | 354:e67efb2aab0e | 578 | * @} |
mbed_official | 354:e67efb2aab0e | 579 | */ |
mbed_official | 354:e67efb2aab0e | 580 | |
mbed_official | 354:e67efb2aab0e | 581 | #ifdef __cplusplus |
mbed_official | 354:e67efb2aab0e | 582 | } |
mbed_official | 354:e67efb2aab0e | 583 | #endif |
mbed_official | 354:e67efb2aab0e | 584 | |
mbed_official | 354:e67efb2aab0e | 585 | #endif /* __STM32L1xx_HAL_SMARTCARD_H */ |
mbed_official | 354:e67efb2aab0e | 586 | |
mbed_official | 354:e67efb2aab0e | 587 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |