mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h@106:ced8cbb51063, 2014-02-26 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Feb 26 09:45:12 2014 +0000
- Revision:
- 106:ced8cbb51063
- Parent:
- 87:085cde657901
- Child:
- 226:b062af740e40
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd
Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/
[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 87:085cde657901 | 1 | /** |
mbed_official | 87:085cde657901 | 2 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 3 | * @file stm32f4xx_hal_smartcard.h |
mbed_official | 87:085cde657901 | 4 | * @author MCD Application Team |
mbed_official | 106:ced8cbb51063 | 5 | * @version V1.0.0 |
mbed_official | 106:ced8cbb51063 | 6 | * @date 18-February-2014 |
mbed_official | 87:085cde657901 | 7 | * @brief Header file of SMARTCARD HAL module. |
mbed_official | 87:085cde657901 | 8 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 9 | * @attention |
mbed_official | 87:085cde657901 | 10 | * |
mbed_official | 87:085cde657901 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 87:085cde657901 | 12 | * |
mbed_official | 87:085cde657901 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 87:085cde657901 | 14 | * are permitted provided that the following conditions are met: |
mbed_official | 87:085cde657901 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 87:085cde657901 | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 87:085cde657901 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 87:085cde657901 | 18 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 87:085cde657901 | 19 | * and/or other materials provided with the distribution. |
mbed_official | 87:085cde657901 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 87:085cde657901 | 21 | * may be used to endorse or promote products derived from this software |
mbed_official | 87:085cde657901 | 22 | * without specific prior written permission. |
mbed_official | 87:085cde657901 | 23 | * |
mbed_official | 87:085cde657901 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 87:085cde657901 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 87:085cde657901 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 87:085cde657901 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 87:085cde657901 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 87:085cde657901 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 87:085cde657901 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 87:085cde657901 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 87:085cde657901 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 87:085cde657901 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 87:085cde657901 | 34 | * |
mbed_official | 87:085cde657901 | 35 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 36 | */ |
mbed_official | 87:085cde657901 | 37 | |
mbed_official | 87:085cde657901 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
mbed_official | 87:085cde657901 | 39 | #ifndef __STM32F4xx_HAL_SMARTCARD_H |
mbed_official | 87:085cde657901 | 40 | #define __STM32F4xx_HAL_SMARTCARD_H |
mbed_official | 87:085cde657901 | 41 | |
mbed_official | 87:085cde657901 | 42 | #ifdef __cplusplus |
mbed_official | 87:085cde657901 | 43 | extern "C" { |
mbed_official | 87:085cde657901 | 44 | #endif |
mbed_official | 87:085cde657901 | 45 | |
mbed_official | 87:085cde657901 | 46 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 47 | #include "stm32f4xx_hal_def.h" |
mbed_official | 87:085cde657901 | 48 | |
mbed_official | 87:085cde657901 | 49 | /** @addtogroup STM32F4xx_HAL_Driver |
mbed_official | 87:085cde657901 | 50 | * @{ |
mbed_official | 87:085cde657901 | 51 | */ |
mbed_official | 87:085cde657901 | 52 | |
mbed_official | 87:085cde657901 | 53 | /** @addtogroup SMARTCARD |
mbed_official | 87:085cde657901 | 54 | * @{ |
mbed_official | 87:085cde657901 | 55 | */ |
mbed_official | 87:085cde657901 | 56 | |
mbed_official | 87:085cde657901 | 57 | /* Exported types ------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 58 | /** |
mbed_official | 87:085cde657901 | 59 | * @brief SMARTCARD Init Structure definition |
mbed_official | 87:085cde657901 | 60 | */ |
mbed_official | 87:085cde657901 | 61 | typedef struct |
mbed_official | 87:085cde657901 | 62 | { |
mbed_official | 87:085cde657901 | 63 | uint32_t BaudRate; /*!< This member configures the SmartCard communication baud rate. |
mbed_official | 87:085cde657901 | 64 | The baud rate is computed using the following formula: |
mbed_official | 87:085cde657901 | 65 | - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate))) |
mbed_official | 87:085cde657901 | 66 | - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ |
mbed_official | 87:085cde657901 | 67 | |
mbed_official | 87:085cde657901 | 68 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
mbed_official | 87:085cde657901 | 69 | This parameter can be a value of @ref SMARTCARD_Word_Length */ |
mbed_official | 87:085cde657901 | 70 | |
mbed_official | 87:085cde657901 | 71 | uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. |
mbed_official | 87:085cde657901 | 72 | This parameter can be a value of @ref SMARTCARD_Stop_Bits */ |
mbed_official | 87:085cde657901 | 73 | |
mbed_official | 87:085cde657901 | 74 | uint32_t Parity; /*!< Specifies the parity mode. |
mbed_official | 87:085cde657901 | 75 | This parameter can be a value of @ref SMARTCARD_Parity |
mbed_official | 87:085cde657901 | 76 | @note When parity is enabled, the computed parity is inserted |
mbed_official | 87:085cde657901 | 77 | at the MSB position of the transmitted data (9th bit when |
mbed_official | 87:085cde657901 | 78 | the word length is set to 9 data bits; 8th bit when the |
mbed_official | 87:085cde657901 | 79 | word length is set to 8 data bits).*/ |
mbed_official | 87:085cde657901 | 80 | |
mbed_official | 87:085cde657901 | 81 | uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. |
mbed_official | 87:085cde657901 | 82 | This parameter can be a value of @ref SMARTCARD_Mode */ |
mbed_official | 87:085cde657901 | 83 | |
mbed_official | 87:085cde657901 | 84 | uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. |
mbed_official | 87:085cde657901 | 85 | This parameter can be a value of @ref SMARTCARD_Clock_Polarity */ |
mbed_official | 87:085cde657901 | 86 | |
mbed_official | 87:085cde657901 | 87 | uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. |
mbed_official | 87:085cde657901 | 88 | This parameter can be a value of @ref SMARTCARD_Clock_Phase */ |
mbed_official | 87:085cde657901 | 89 | |
mbed_official | 87:085cde657901 | 90 | uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
mbed_official | 87:085cde657901 | 91 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
mbed_official | 87:085cde657901 | 92 | This parameter can be a value of @ref SMARTCARD_Last_Bit */ |
mbed_official | 87:085cde657901 | 93 | |
mbed_official | 87:085cde657901 | 94 | uint32_t Prescaler; /*!< Specifies the SmartCard Prescaler |
mbed_official | 87:085cde657901 | 95 | This parameter must be a number between Min_Data = 0 and Max_Data = 255 */ |
mbed_official | 87:085cde657901 | 96 | |
mbed_official | 87:085cde657901 | 97 | uint32_t GuardTime; /*!< Specifies the SmartCard Guard Time |
mbed_official | 87:085cde657901 | 98 | This parameter must be a number between Min_Data = 0 and Max_Data = 255 */ |
mbed_official | 87:085cde657901 | 99 | |
mbed_official | 87:085cde657901 | 100 | uint32_t NACKState; /*!< Specifies the SmartCard NACK Transmission state |
mbed_official | 87:085cde657901 | 101 | This parameter can be a value of @ref SmartCard_NACK_State */ |
mbed_official | 87:085cde657901 | 102 | }SMARTCARD_InitTypeDef; |
mbed_official | 87:085cde657901 | 103 | |
mbed_official | 87:085cde657901 | 104 | /** |
mbed_official | 87:085cde657901 | 105 | * @brief HAL State structures definition |
mbed_official | 87:085cde657901 | 106 | */ |
mbed_official | 87:085cde657901 | 107 | typedef enum |
mbed_official | 87:085cde657901 | 108 | { |
mbed_official | 87:085cde657901 | 109 | HAL_SMARTCARD_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ |
mbed_official | 87:085cde657901 | 110 | HAL_SMARTCARD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
mbed_official | 87:085cde657901 | 111 | HAL_SMARTCARD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
mbed_official | 87:085cde657901 | 112 | HAL_SMARTCARD_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
mbed_official | 87:085cde657901 | 113 | HAL_SMARTCARD_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
mbed_official | 87:085cde657901 | 114 | HAL_SMARTCARD_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
mbed_official | 87:085cde657901 | 115 | HAL_SMARTCARD_STATE_ERROR = 0x04 /*!< Error */ |
mbed_official | 87:085cde657901 | 116 | }HAL_SMARTCARD_StateTypeDef; |
mbed_official | 87:085cde657901 | 117 | |
mbed_official | 87:085cde657901 | 118 | /** |
mbed_official | 87:085cde657901 | 119 | * @brief HAL SMARTCARD Error Code structure definition |
mbed_official | 87:085cde657901 | 120 | */ |
mbed_official | 87:085cde657901 | 121 | typedef enum |
mbed_official | 87:085cde657901 | 122 | { |
mbed_official | 87:085cde657901 | 123 | HAL_SMARTCARD_ERROR_NONE = 0x00, /*!< No error */ |
mbed_official | 87:085cde657901 | 124 | HAL_SMARTCARD_ERROR_PE = 0x01, /*!< Parity error */ |
mbed_official | 87:085cde657901 | 125 | HAL_SMARTCARD_ERROR_NE = 0x02, /*!< Noise error */ |
mbed_official | 87:085cde657901 | 126 | HAL_SMARTCARD_ERROR_FE = 0x04, /*!< frame error */ |
mbed_official | 87:085cde657901 | 127 | HAL_SMARTCARD_ERROR_ORE = 0x08, /*!< Overrun error */ |
mbed_official | 87:085cde657901 | 128 | HAL_SMARTCARD_ERROR_DMA = 0x10 /*!< DMA transfer error */ |
mbed_official | 87:085cde657901 | 129 | }HAL_SMARTCARD_ErrorTypeDef; |
mbed_official | 87:085cde657901 | 130 | |
mbed_official | 87:085cde657901 | 131 | /** |
mbed_official | 87:085cde657901 | 132 | * @brief SMARTCARD handle Structure definition |
mbed_official | 87:085cde657901 | 133 | */ |
mbed_official | 87:085cde657901 | 134 | typedef struct |
mbed_official | 87:085cde657901 | 135 | { |
mbed_official | 87:085cde657901 | 136 | USART_TypeDef *Instance; /* USART registers base address */ |
mbed_official | 87:085cde657901 | 137 | |
mbed_official | 87:085cde657901 | 138 | SMARTCARD_InitTypeDef Init; /* SmartCard communication parameters */ |
mbed_official | 87:085cde657901 | 139 | |
mbed_official | 87:085cde657901 | 140 | uint8_t *pTxBuffPtr; /* Pointer to SmartCard Tx transfer Buffer */ |
mbed_official | 87:085cde657901 | 141 | |
mbed_official | 87:085cde657901 | 142 | uint16_t TxXferSize; /* SmartCard Tx Transfer size */ |
mbed_official | 87:085cde657901 | 143 | |
mbed_official | 87:085cde657901 | 144 | uint16_t TxXferCount; /* SmartCard Tx Transfer Counter */ |
mbed_official | 87:085cde657901 | 145 | |
mbed_official | 87:085cde657901 | 146 | uint8_t *pRxBuffPtr; /* Pointer to SmartCard Rx transfer Buffer */ |
mbed_official | 87:085cde657901 | 147 | |
mbed_official | 87:085cde657901 | 148 | uint16_t RxXferSize; /* SmartCard Rx Transfer size */ |
mbed_official | 87:085cde657901 | 149 | |
mbed_official | 87:085cde657901 | 150 | uint16_t RxXferCount; /* SmartCard Rx Transfer Counter */ |
mbed_official | 87:085cde657901 | 151 | |
mbed_official | 87:085cde657901 | 152 | DMA_HandleTypeDef *hdmatx; /* SmartCard Tx DMA Handle parameters */ |
mbed_official | 87:085cde657901 | 153 | |
mbed_official | 87:085cde657901 | 154 | DMA_HandleTypeDef *hdmarx; /* SmartCard Rx DMA Handle parameters */ |
mbed_official | 87:085cde657901 | 155 | |
mbed_official | 87:085cde657901 | 156 | HAL_LockTypeDef Lock; /* Locking object */ |
mbed_official | 87:085cde657901 | 157 | |
mbed_official | 87:085cde657901 | 158 | __IO HAL_SMARTCARD_StateTypeDef State; /* SmartCard communication state */ |
mbed_official | 87:085cde657901 | 159 | |
mbed_official | 87:085cde657901 | 160 | __IO HAL_SMARTCARD_ErrorTypeDef ErrorCode; /* SMARTCARD Error code */ |
mbed_official | 87:085cde657901 | 161 | }SMARTCARD_HandleTypeDef; |
mbed_official | 87:085cde657901 | 162 | |
mbed_official | 87:085cde657901 | 163 | /* Exported constants --------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 164 | /** @defgroup SMARTCARD_Exported_Constants |
mbed_official | 87:085cde657901 | 165 | * @{ |
mbed_official | 87:085cde657901 | 166 | */ |
mbed_official | 87:085cde657901 | 167 | |
mbed_official | 87:085cde657901 | 168 | /** @defgroup SMARTCARD_Word_Length |
mbed_official | 87:085cde657901 | 169 | * @{ |
mbed_official | 87:085cde657901 | 170 | */ |
mbed_official | 87:085cde657901 | 171 | #define SMARTCARD_WORDLENGTH_8B ((uint32_t)0x00000000) |
mbed_official | 87:085cde657901 | 172 | #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M) |
mbed_official | 87:085cde657901 | 173 | #define IS_SMARTCARD_WORD_LENGTH(LENGTH) (((LENGTH) == SMARTCARD_WORDLENGTH_8B) || \ |
mbed_official | 87:085cde657901 | 174 | ((LENGTH) == SMARTCARD_WORDLENGTH_9B)) |
mbed_official | 87:085cde657901 | 175 | /** |
mbed_official | 87:085cde657901 | 176 | * @} |
mbed_official | 87:085cde657901 | 177 | */ |
mbed_official | 87:085cde657901 | 178 | |
mbed_official | 87:085cde657901 | 179 | /** @defgroup SMARTCARD_Stop_Bits |
mbed_official | 87:085cde657901 | 180 | * @{ |
mbed_official | 87:085cde657901 | 181 | */ |
mbed_official | 87:085cde657901 | 182 | #define SMARTCARD_STOPBITS_1 ((uint32_t)0x00000000) |
mbed_official | 87:085cde657901 | 183 | #define SMARTCARD_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) |
mbed_official | 87:085cde657901 | 184 | #define SMARTCARD_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) |
mbed_official | 87:085cde657901 | 185 | #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) |
mbed_official | 87:085cde657901 | 186 | #define IS_SMARTCARD_STOPBITS(STOPBITS) (((STOPBITS) == SMARTCARD_STOPBITS_1) || \ |
mbed_official | 87:085cde657901 | 187 | ((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \ |
mbed_official | 87:085cde657901 | 188 | ((STOPBITS) == SMARTCARD_STOPBITS_1_5) || \ |
mbed_official | 87:085cde657901 | 189 | ((STOPBITS) == SMARTCARD_STOPBITS_2)) |
mbed_official | 87:085cde657901 | 190 | /** |
mbed_official | 87:085cde657901 | 191 | * @} |
mbed_official | 87:085cde657901 | 192 | */ |
mbed_official | 87:085cde657901 | 193 | |
mbed_official | 87:085cde657901 | 194 | /** @defgroup SMARTCARD_Parity |
mbed_official | 87:085cde657901 | 195 | * @{ |
mbed_official | 87:085cde657901 | 196 | */ |
mbed_official | 87:085cde657901 | 197 | #define SMARTCARD_PARITY_NONE ((uint32_t)0x00000000) |
mbed_official | 87:085cde657901 | 198 | #define SMARTCARD_PARITY_EVEN ((uint32_t)USART_CR1_PCE) |
mbed_official | 87:085cde657901 | 199 | #define SMARTCARD_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) |
mbed_official | 87:085cde657901 | 200 | #define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_NONE) || \ |
mbed_official | 87:085cde657901 | 201 | ((PARITY) == SMARTCARD_PARITY_EVEN) || \ |
mbed_official | 87:085cde657901 | 202 | ((PARITY) == SMARTCARD_PARITY_ODD)) |
mbed_official | 87:085cde657901 | 203 | /** |
mbed_official | 87:085cde657901 | 204 | * @} |
mbed_official | 87:085cde657901 | 205 | */ |
mbed_official | 87:085cde657901 | 206 | |
mbed_official | 87:085cde657901 | 207 | /** @defgroup SMARTCARD_Mode |
mbed_official | 87:085cde657901 | 208 | * @{ |
mbed_official | 87:085cde657901 | 209 | */ |
mbed_official | 87:085cde657901 | 210 | #define SMARTCARD_MODE_RX ((uint32_t)USART_CR1_RE) |
mbed_official | 87:085cde657901 | 211 | #define SMARTCARD_MODE_TX ((uint32_t)USART_CR1_TE) |
mbed_official | 87:085cde657901 | 212 | #define SMARTCARD_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) |
mbed_official | 87:085cde657901 | 213 | #define IS_SMARTCARD_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3) == 0x00) && ((MODE) != (uint32_t)0x000000)) |
mbed_official | 87:085cde657901 | 214 | /** |
mbed_official | 87:085cde657901 | 215 | * @} |
mbed_official | 87:085cde657901 | 216 | */ |
mbed_official | 87:085cde657901 | 217 | |
mbed_official | 87:085cde657901 | 218 | /** @defgroup SMARTCARD_Clock_Polarity |
mbed_official | 87:085cde657901 | 219 | * @{ |
mbed_official | 87:085cde657901 | 220 | */ |
mbed_official | 87:085cde657901 | 221 | #define SMARTCARD_POLARITY_LOW ((uint32_t)0x00000000) |
mbed_official | 87:085cde657901 | 222 | #define SMARTCARD_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) |
mbed_official | 87:085cde657901 | 223 | #define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH)) |
mbed_official | 87:085cde657901 | 224 | /** |
mbed_official | 87:085cde657901 | 225 | * @} |
mbed_official | 87:085cde657901 | 226 | */ |
mbed_official | 87:085cde657901 | 227 | |
mbed_official | 87:085cde657901 | 228 | /** @defgroup SMARTCARD_Clock_Phase |
mbed_official | 87:085cde657901 | 229 | * @{ |
mbed_official | 87:085cde657901 | 230 | */ |
mbed_official | 87:085cde657901 | 231 | #define SMARTCARD_PHASE_1EDGE ((uint32_t)0x00000000) |
mbed_official | 87:085cde657901 | 232 | #define SMARTCARD_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) |
mbed_official | 87:085cde657901 | 233 | #define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE)) |
mbed_official | 87:085cde657901 | 234 | /** |
mbed_official | 87:085cde657901 | 235 | * @} |
mbed_official | 87:085cde657901 | 236 | */ |
mbed_official | 87:085cde657901 | 237 | |
mbed_official | 87:085cde657901 | 238 | /** @defgroup SMARTCARD_Last_Bit |
mbed_official | 87:085cde657901 | 239 | * @{ |
mbed_official | 87:085cde657901 | 240 | */ |
mbed_official | 87:085cde657901 | 241 | #define SMARTCARD_LASTBIT_DISABLE ((uint32_t)0x00000000) |
mbed_official | 87:085cde657901 | 242 | #define SMARTCARD_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) |
mbed_official | 87:085cde657901 | 243 | #define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \ |
mbed_official | 87:085cde657901 | 244 | ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE)) |
mbed_official | 87:085cde657901 | 245 | /** |
mbed_official | 87:085cde657901 | 246 | * @} |
mbed_official | 87:085cde657901 | 247 | */ |
mbed_official | 87:085cde657901 | 248 | |
mbed_official | 87:085cde657901 | 249 | /** @defgroup SmartCard_NACK_State |
mbed_official | 87:085cde657901 | 250 | * @{ |
mbed_official | 87:085cde657901 | 251 | */ |
mbed_official | 87:085cde657901 | 252 | #define SMARTCARD_NACK_ENABLED ((uint32_t)USART_CR3_NACK) |
mbed_official | 87:085cde657901 | 253 | #define SMARTCARD_NACK_DISABLED ((uint32_t)0x00000000) |
mbed_official | 87:085cde657901 | 254 | #define IS_SMARTCARD_NACK_STATE(NACK) (((NACK) == SMARTCARD_NACK_ENABLED) || \ |
mbed_official | 87:085cde657901 | 255 | ((NACK) == SMARTCARD_NACK_DISABLED)) |
mbed_official | 87:085cde657901 | 256 | /** |
mbed_official | 87:085cde657901 | 257 | * @} |
mbed_official | 87:085cde657901 | 258 | */ |
mbed_official | 87:085cde657901 | 259 | |
mbed_official | 87:085cde657901 | 260 | /** @defgroup SmartCard_DMA_Requests |
mbed_official | 87:085cde657901 | 261 | * @{ |
mbed_official | 87:085cde657901 | 262 | */ |
mbed_official | 87:085cde657901 | 263 | |
mbed_official | 87:085cde657901 | 264 | #define SMARTCARD_DMAREQ_TX ((uint32_t)USART_CR3_DMAT) |
mbed_official | 87:085cde657901 | 265 | #define SMARTCARD_DMAREQ_RX ((uint32_t)USART_CR3_DMAR) |
mbed_official | 87:085cde657901 | 266 | |
mbed_official | 87:085cde657901 | 267 | /** |
mbed_official | 87:085cde657901 | 268 | * @} |
mbed_official | 87:085cde657901 | 269 | */ |
mbed_official | 87:085cde657901 | 270 | |
mbed_official | 87:085cde657901 | 271 | /** @defgroup SmartCard_Flags |
mbed_official | 87:085cde657901 | 272 | * Elements values convention: 0xXXXX |
mbed_official | 87:085cde657901 | 273 | * - 0xXXXX : Flag mask in the SR register |
mbed_official | 87:085cde657901 | 274 | * @{ |
mbed_official | 87:085cde657901 | 275 | */ |
mbed_official | 87:085cde657901 | 276 | |
mbed_official | 87:085cde657901 | 277 | #define SMARTCARD_FLAG_TXE ((uint32_t)0x00000080) |
mbed_official | 87:085cde657901 | 278 | #define SMARTCARD_FLAG_TC ((uint32_t)0x00000040) |
mbed_official | 87:085cde657901 | 279 | #define SMARTCARD_FLAG_RXNE ((uint32_t)0x00000020) |
mbed_official | 87:085cde657901 | 280 | #define SMARTCARD_FLAG_IDLE ((uint32_t)0x00000010) |
mbed_official | 87:085cde657901 | 281 | #define SMARTCARD_FLAG_ORE ((uint32_t)0x00000008) |
mbed_official | 87:085cde657901 | 282 | #define SMARTCARD_FLAG_NE ((uint32_t)0x00000004) |
mbed_official | 87:085cde657901 | 283 | #define SMARTCARD_FLAG_FE ((uint32_t)0x00000002) |
mbed_official | 87:085cde657901 | 284 | #define SMARTCARD_FLAG_PE ((uint32_t)0x00000001) |
mbed_official | 87:085cde657901 | 285 | /** |
mbed_official | 87:085cde657901 | 286 | * @} |
mbed_official | 87:085cde657901 | 287 | */ |
mbed_official | 87:085cde657901 | 288 | |
mbed_official | 87:085cde657901 | 289 | /** @defgroup SmartCard_Interrupt_definition |
mbed_official | 87:085cde657901 | 290 | * Elements values convention: 0xY000XXXX |
mbed_official | 87:085cde657901 | 291 | * - XXXX : Interrupt mask in the XX register |
mbed_official | 87:085cde657901 | 292 | * - Y : Interrupt source register (2bits) |
mbed_official | 87:085cde657901 | 293 | * - 01: CR1 register |
mbed_official | 87:085cde657901 | 294 | * - 10: CR3 register |
mbed_official | 87:085cde657901 | 295 | |
mbed_official | 87:085cde657901 | 296 | * |
mbed_official | 87:085cde657901 | 297 | * @{ |
mbed_official | 87:085cde657901 | 298 | */ |
mbed_official | 87:085cde657901 | 299 | #define SMARTCARD_IT_PE ((uint32_t)0x10000100) |
mbed_official | 87:085cde657901 | 300 | #define SMARTCARD_IT_TXE ((uint32_t)0x10000080) |
mbed_official | 87:085cde657901 | 301 | #define SMARTCARD_IT_TC ((uint32_t)0x10000040) |
mbed_official | 87:085cde657901 | 302 | #define SMARTCARD_IT_RXNE ((uint32_t)0x10000020) |
mbed_official | 87:085cde657901 | 303 | #define SMARTCARD_IT_IDLE ((uint32_t)0x10000010) |
mbed_official | 87:085cde657901 | 304 | #define SMARTCARD_IT_ERR ((uint32_t)0x20000001) |
mbed_official | 87:085cde657901 | 305 | |
mbed_official | 87:085cde657901 | 306 | /** |
mbed_official | 87:085cde657901 | 307 | * @} |
mbed_official | 87:085cde657901 | 308 | */ |
mbed_official | 87:085cde657901 | 309 | |
mbed_official | 87:085cde657901 | 310 | /** |
mbed_official | 87:085cde657901 | 311 | * @} |
mbed_official | 87:085cde657901 | 312 | */ |
mbed_official | 87:085cde657901 | 313 | |
mbed_official | 87:085cde657901 | 314 | /* Exported macro ------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 315 | |
mbed_official | 87:085cde657901 | 316 | /** @brief Flushs the Smartcard DR register |
mbed_official | 87:085cde657901 | 317 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 87:085cde657901 | 318 | */ |
mbed_official | 87:085cde657901 | 319 | #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) |
mbed_official | 87:085cde657901 | 320 | |
mbed_official | 87:085cde657901 | 321 | /** @brief Checks whether the specified Smartcard flag is set or not. |
mbed_official | 87:085cde657901 | 322 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 87:085cde657901 | 323 | * @param __FLAG__: specifies the flag to check. |
mbed_official | 87:085cde657901 | 324 | * This parameter can be one of the following values: |
mbed_official | 87:085cde657901 | 325 | * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag |
mbed_official | 87:085cde657901 | 326 | * @arg SMARTCARD_FLAG_TC: Transmission Complete flag |
mbed_official | 87:085cde657901 | 327 | * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag |
mbed_official | 87:085cde657901 | 328 | * @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag |
mbed_official | 87:085cde657901 | 329 | * @arg SMARTCARD_FLAG_ORE: OverRun Error flag |
mbed_official | 87:085cde657901 | 330 | * @arg SMARTCARD_FLAG_NE: Noise Error flag |
mbed_official | 87:085cde657901 | 331 | * @arg SMARTCARD_FLAG_FE: Framing Error flag |
mbed_official | 87:085cde657901 | 332 | * @arg SMARTCARD_FLAG_PE: Parity Error flag |
mbed_official | 87:085cde657901 | 333 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
mbed_official | 87:085cde657901 | 334 | */ |
mbed_official | 87:085cde657901 | 335 | #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
mbed_official | 87:085cde657901 | 336 | |
mbed_official | 87:085cde657901 | 337 | /** @brief Clears the specified Smartcard pending flags. |
mbed_official | 87:085cde657901 | 338 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 87:085cde657901 | 339 | * @param __FLAG__: specifies the flag to check. |
mbed_official | 87:085cde657901 | 340 | * This parameter can be any combination of the following values: |
mbed_official | 87:085cde657901 | 341 | * @arg SMARTCARD_FLAG_TC: Transmission Complete flag. |
mbed_official | 87:085cde657901 | 342 | * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag. |
mbed_official | 87:085cde657901 | 343 | * |
mbed_official | 87:085cde657901 | 344 | * @note PE (Parity error), FE (Framing error), NE (Noise error) and ORE (OverRun |
mbed_official | 87:085cde657901 | 345 | * error) flags are cleared by software sequence: a read operation to |
mbed_official | 87:085cde657901 | 346 | * USART_SR register followed by a read operation to USART_DR register. |
mbed_official | 87:085cde657901 | 347 | * @note RXNE flag can be also cleared by a read to the USART_DR register. |
mbed_official | 87:085cde657901 | 348 | * @note TC flag can be also cleared by software sequence: a read operation to |
mbed_official | 87:085cde657901 | 349 | * USART_SR register followed by a write operation to USART_DR register. |
mbed_official | 87:085cde657901 | 350 | * @note TXE flag is cleared only by a write to the USART_DR register. |
mbed_official | 87:085cde657901 | 351 | */ |
mbed_official | 87:085cde657901 | 352 | #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR &= ~(__FLAG__)) |
mbed_official | 87:085cde657901 | 353 | |
mbed_official | 87:085cde657901 | 354 | /** @brief Enables or disables the specified SmartCard interrupts. |
mbed_official | 87:085cde657901 | 355 | * @param __HANDLE__: specifies the SMARTCARD Handle. |
mbed_official | 87:085cde657901 | 356 | * @param __INTERRUPT__: specifies the SMARTCARD interrupt source to check. |
mbed_official | 87:085cde657901 | 357 | * This parameter can be one of the following values: |
mbed_official | 87:085cde657901 | 358 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
mbed_official | 87:085cde657901 | 359 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
mbed_official | 87:085cde657901 | 360 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
mbed_official | 87:085cde657901 | 361 | * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt |
mbed_official | 87:085cde657901 | 362 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
mbed_official | 87:085cde657901 | 363 | * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
mbed_official | 87:085cde657901 | 364 | */ |
mbed_official | 87:085cde657901 | 365 | #define SMARTCARD_IT_MASK ((uint32_t)0x0000FFFF) |
mbed_official | 87:085cde657901 | 366 | #define __SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)): \ |
mbed_official | 87:085cde657901 | 367 | ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK))) |
mbed_official | 87:085cde657901 | 368 | #define __SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & SMARTCARD_IT_MASK)): \ |
mbed_official | 87:085cde657901 | 369 | ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK))) |
mbed_official | 87:085cde657901 | 370 | |
mbed_official | 87:085cde657901 | 371 | /** @brief Checks whether the specified SmartCard interrupt has occurred or not. |
mbed_official | 87:085cde657901 | 372 | * @param __HANDLE__: specifies the SmartCard Handle. |
mbed_official | 87:085cde657901 | 373 | * @param __IT__: specifies the SMARTCARD interrupt source to check. |
mbed_official | 87:085cde657901 | 374 | * This parameter can be one of the following values: |
mbed_official | 87:085cde657901 | 375 | * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt |
mbed_official | 87:085cde657901 | 376 | * @arg SMARTCARD_IT_TC: Transmission complete interrupt |
mbed_official | 87:085cde657901 | 377 | * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt |
mbed_official | 87:085cde657901 | 378 | * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt |
mbed_official | 87:085cde657901 | 379 | * @arg SMARTCARD_IT_ERR: Error interrupt |
mbed_official | 87:085cde657901 | 380 | * @arg SMARTCARD_IT_PE: Parity Error interrupt |
mbed_official | 87:085cde657901 | 381 | * @retval The new state of __IT__ (TRUE or FALSE). |
mbed_official | 87:085cde657901 | 382 | */ |
mbed_official | 87:085cde657901 | 383 | #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 | 87:085cde657901 | 384 | |
mbed_official | 87:085cde657901 | 385 | /** @brief Macros to enable or disable the SmartCard interface. |
mbed_official | 87:085cde657901 | 386 | * @param __HANDLE__: specifies the SmartCard Handle. |
mbed_official | 87:085cde657901 | 387 | */ |
mbed_official | 87:085cde657901 | 388 | #define __SMARTCARD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
mbed_official | 87:085cde657901 | 389 | #define __SMARTCARD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
mbed_official | 87:085cde657901 | 390 | |
mbed_official | 87:085cde657901 | 391 | /** @brief Macros to enable or disable the SmartCard DMA request. |
mbed_official | 87:085cde657901 | 392 | * @param __HANDLE__: specifies the SmartCard Handle. |
mbed_official | 87:085cde657901 | 393 | * @param __REQUEST__: specifies the SmartCard DMA request. |
mbed_official | 87:085cde657901 | 394 | * This parameter can be one of the following values: |
mbed_official | 87:085cde657901 | 395 | * @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request |
mbed_official | 87:085cde657901 | 396 | * @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request |
mbed_official | 87:085cde657901 | 397 | */ |
mbed_official | 87:085cde657901 | 398 | #define __SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 |= (__REQUEST__)) |
mbed_official | 87:085cde657901 | 399 | #define __SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 &= ~(__REQUEST__)) |
mbed_official | 87:085cde657901 | 400 | |
mbed_official | 87:085cde657901 | 401 | #define __DIV(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_))) |
mbed_official | 87:085cde657901 | 402 | #define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_))/100) |
mbed_official | 87:085cde657901 | 403 | #define __DIVFRAQ(_PCLK_, _BAUD_) (((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100) |
mbed_official | 87:085cde657901 | 404 | #define __SMARTCARD_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4)|(__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F)) |
mbed_official | 87:085cde657901 | 405 | |
mbed_official | 87:085cde657901 | 406 | #define IS_SMARTCARD_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001) |
mbed_official | 87:085cde657901 | 407 | |
mbed_official | 87:085cde657901 | 408 | /* Exported functions --------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 409 | /* Initialization/de-initialization functions **********************************/ |
mbed_official | 87:085cde657901 | 410 | HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 87:085cde657901 | 411 | HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 87:085cde657901 | 412 | HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 106:ced8cbb51063 | 413 | void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 106:ced8cbb51063 | 414 | void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 87:085cde657901 | 415 | /* IO operation functions *******************************************************/ |
mbed_official | 87:085cde657901 | 416 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
mbed_official | 87:085cde657901 | 417 | HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
mbed_official | 87:085cde657901 | 418 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
mbed_official | 87:085cde657901 | 419 | HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
mbed_official | 87:085cde657901 | 420 | HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
mbed_official | 87:085cde657901 | 421 | HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); |
mbed_official | 87:085cde657901 | 422 | void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 106:ced8cbb51063 | 423 | void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 106:ced8cbb51063 | 424 | void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 106:ced8cbb51063 | 425 | void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 87:085cde657901 | 426 | |
mbed_official | 87:085cde657901 | 427 | /* Peripheral State functions **************************************************/ |
mbed_official | 87:085cde657901 | 428 | HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 87:085cde657901 | 429 | uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc); |
mbed_official | 87:085cde657901 | 430 | |
mbed_official | 87:085cde657901 | 431 | /** |
mbed_official | 87:085cde657901 | 432 | * @} |
mbed_official | 87:085cde657901 | 433 | */ |
mbed_official | 87:085cde657901 | 434 | |
mbed_official | 87:085cde657901 | 435 | /** |
mbed_official | 87:085cde657901 | 436 | * @} |
mbed_official | 87:085cde657901 | 437 | */ |
mbed_official | 87:085cde657901 | 438 | |
mbed_official | 87:085cde657901 | 439 | #ifdef __cplusplus |
mbed_official | 87:085cde657901 | 440 | } |
mbed_official | 87:085cde657901 | 441 | #endif |
mbed_official | 87:085cde657901 | 442 | |
mbed_official | 87:085cde657901 | 443 | #endif /* __STM32F4xx_HAL_SMARTCARD_H */ |
mbed_official | 87:085cde657901 | 444 | |
mbed_official | 87:085cde657901 | 445 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |