The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_KL82Z/TOOLCHAIN_IAR/fsl_smartcard.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_USENSE/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_smartcard.h@145:64910690c574
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 145:64910690c574 | 1 | /* |
AnnaBridge | 145:64910690c574 | 2 | * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. |
AnnaBridge | 145:64910690c574 | 3 | * All rights reserved. |
AnnaBridge | 145:64910690c574 | 4 | * |
AnnaBridge | 145:64910690c574 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 145:64910690c574 | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 145:64910690c574 | 7 | * |
AnnaBridge | 145:64910690c574 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 145:64910690c574 | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 145:64910690c574 | 10 | * |
AnnaBridge | 145:64910690c574 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 145:64910690c574 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 145:64910690c574 | 13 | * other materials provided with the distribution. |
AnnaBridge | 145:64910690c574 | 14 | * |
AnnaBridge | 145:64910690c574 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 145:64910690c574 | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 145:64910690c574 | 17 | * software without specific prior written permission. |
AnnaBridge | 145:64910690c574 | 18 | * |
AnnaBridge | 145:64910690c574 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 145:64910690c574 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 145:64910690c574 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 145:64910690c574 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 145:64910690c574 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 145:64910690c574 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 145:64910690c574 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 145:64910690c574 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 145:64910690c574 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 145:64910690c574 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 145:64910690c574 | 29 | */ |
AnnaBridge | 145:64910690c574 | 30 | |
AnnaBridge | 145:64910690c574 | 31 | #ifndef _FSL_SMARTCARD_H_ |
AnnaBridge | 145:64910690c574 | 32 | #define _FSL_SMARTCARD_H_ |
AnnaBridge | 145:64910690c574 | 33 | |
AnnaBridge | 145:64910690c574 | 34 | #include "fsl_common.h" |
AnnaBridge | 145:64910690c574 | 35 | |
AnnaBridge | 145:64910690c574 | 36 | /*! |
AnnaBridge | 145:64910690c574 | 37 | * @addtogroup smartcard |
AnnaBridge | 145:64910690c574 | 38 | * @{ |
AnnaBridge | 145:64910690c574 | 39 | */ |
AnnaBridge | 145:64910690c574 | 40 | |
AnnaBridge | 145:64910690c574 | 41 | |
AnnaBridge | 145:64910690c574 | 42 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 43 | * Definitions |
AnnaBridge | 145:64910690c574 | 44 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 45 | |
AnnaBridge | 145:64910690c574 | 46 | /*! @name Driver version */ |
AnnaBridge | 145:64910690c574 | 47 | /*@{*/ |
AnnaBridge | 145:64910690c574 | 48 | /*! @brief Smart card driver version 2.1.1. |
AnnaBridge | 145:64910690c574 | 49 | */ |
AnnaBridge | 145:64910690c574 | 50 | #define FSL_SMARTCARD_DRIVER_VERSION (MAKE_VERSION(2, 1, 1)) |
AnnaBridge | 145:64910690c574 | 51 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 52 | |
AnnaBridge | 145:64910690c574 | 53 | /*! @brief Smart card global define which specify number of clock cycles until initial 'TS' character has to be received |
AnnaBridge | 145:64910690c574 | 54 | */ |
AnnaBridge | 145:64910690c574 | 55 | #define SMARTCARD_INIT_DELAY_CLOCK_CYCLES (42000u) |
AnnaBridge | 145:64910690c574 | 56 | |
AnnaBridge | 145:64910690c574 | 57 | /*! @brief Smart card global define which specify number of clock cycles during which ATR string has to be received */ |
AnnaBridge | 145:64910690c574 | 58 | #define SMARTCARD_EMV_ATR_DURATION_ETU (20150u) |
AnnaBridge | 145:64910690c574 | 59 | |
AnnaBridge | 145:64910690c574 | 60 | /*! @brief Smart card specification initial TS character definition of direct convention */ |
AnnaBridge | 145:64910690c574 | 61 | #define SMARTCARD_TS_DIRECT_CONVENTION (0x3Bu) |
AnnaBridge | 145:64910690c574 | 62 | |
AnnaBridge | 145:64910690c574 | 63 | /*! @brief Smart card specification initial TS character definition of inverse convention */ |
AnnaBridge | 145:64910690c574 | 64 | #define SMARTCARD_TS_INVERSE_CONVENTION (0x3Fu) |
AnnaBridge | 145:64910690c574 | 65 | |
AnnaBridge | 145:64910690c574 | 66 | /*! @brief Smart card Error codes. */ |
AnnaBridge | 145:64910690c574 | 67 | typedef enum _smartcard_status |
AnnaBridge | 145:64910690c574 | 68 | { |
AnnaBridge | 145:64910690c574 | 69 | kStatus_SMARTCARD_Success = MAKE_STATUS(kStatusGroup_SMARTCARD, 0), /*!< Transfer ends successfully */ |
AnnaBridge | 145:64910690c574 | 70 | kStatus_SMARTCARD_TxBusy = MAKE_STATUS(kStatusGroup_SMARTCARD, 1), /*!< Transmit in progress */ |
AnnaBridge | 145:64910690c574 | 71 | kStatus_SMARTCARD_RxBusy = MAKE_STATUS(kStatusGroup_SMARTCARD, 2), /*!< Receiving in progress */ |
AnnaBridge | 145:64910690c574 | 72 | kStatus_SMARTCARD_NoTransferInProgress = MAKE_STATUS(kStatusGroup_SMARTCARD, 3), /*!< No transfer in progress */ |
AnnaBridge | 145:64910690c574 | 73 | kStatus_SMARTCARD_Timeout = MAKE_STATUS(kStatusGroup_SMARTCARD, 4), /*!< Transfer ends with time-out */ |
AnnaBridge | 145:64910690c574 | 74 | kStatus_SMARTCARD_Initialized = |
AnnaBridge | 145:64910690c574 | 75 | MAKE_STATUS(kStatusGroup_SMARTCARD, 5), /*!< Smart card driver is already initialized */ |
AnnaBridge | 145:64910690c574 | 76 | kStatus_SMARTCARD_PhyInitialized = |
AnnaBridge | 145:64910690c574 | 77 | MAKE_STATUS(kStatusGroup_SMARTCARD, 6), /*!< Smart card PHY drive is already initialized */ |
AnnaBridge | 145:64910690c574 | 78 | kStatus_SMARTCARD_CardNotActivated = MAKE_STATUS(kStatusGroup_SMARTCARD, 7), /*!< Smart card is not activated */ |
AnnaBridge | 145:64910690c574 | 79 | kStatus_SMARTCARD_InvalidInput = |
AnnaBridge | 145:64910690c574 | 80 | MAKE_STATUS(kStatusGroup_SMARTCARD, 8), /*!< Function called with invalid input arguments */ |
AnnaBridge | 145:64910690c574 | 81 | kStatus_SMARTCARD_OtherError = MAKE_STATUS(kStatusGroup_SMARTCARD, 9) /*!< Some other error occur */ |
AnnaBridge | 145:64910690c574 | 82 | } smartcard_status_t; |
AnnaBridge | 145:64910690c574 | 83 | |
AnnaBridge | 145:64910690c574 | 84 | /*! @brief Control codes for the Smart card protocol timers and misc. */ |
AnnaBridge | 145:64910690c574 | 85 | typedef enum _smartcard_control |
AnnaBridge | 145:64910690c574 | 86 | { |
AnnaBridge | 145:64910690c574 | 87 | kSMARTCARD_EnableADT = 0x0u, |
AnnaBridge | 145:64910690c574 | 88 | kSMARTCARD_DisableADT = 0x1u, |
AnnaBridge | 145:64910690c574 | 89 | kSMARTCARD_EnableGTV = 0x2u, |
AnnaBridge | 145:64910690c574 | 90 | kSMARTCARD_DisableGTV = 0x3u, |
AnnaBridge | 145:64910690c574 | 91 | kSMARTCARD_ResetWWT = 0x4u, |
AnnaBridge | 145:64910690c574 | 92 | kSMARTCARD_EnableWWT = 0x5u, |
AnnaBridge | 145:64910690c574 | 93 | kSMARTCARD_DisableWWT = 0x6u, |
AnnaBridge | 145:64910690c574 | 94 | kSMARTCARD_ResetCWT = 0x7u, |
AnnaBridge | 145:64910690c574 | 95 | kSMARTCARD_EnableCWT = 0x8u, |
AnnaBridge | 145:64910690c574 | 96 | kSMARTCARD_DisableCWT = 0x9u, |
AnnaBridge | 145:64910690c574 | 97 | kSMARTCARD_ResetBWT = 0xAu, |
AnnaBridge | 145:64910690c574 | 98 | kSMARTCARD_EnableBWT = 0xBu, |
AnnaBridge | 145:64910690c574 | 99 | kSMARTCARD_DisableBWT = 0xCu, |
AnnaBridge | 145:64910690c574 | 100 | kSMARTCARD_EnableInitDetect = 0xDu, |
AnnaBridge | 145:64910690c574 | 101 | kSMARTCARD_EnableAnack = 0xEu, |
AnnaBridge | 145:64910690c574 | 102 | kSMARTCARD_DisableAnack = 0xFu, |
AnnaBridge | 145:64910690c574 | 103 | kSMARTCARD_ConfigureBaudrate = 0x10u, |
AnnaBridge | 145:64910690c574 | 104 | kSMARTCARD_SetupATRMode = 0x11u, |
AnnaBridge | 145:64910690c574 | 105 | kSMARTCARD_SetupT0Mode = 0x12u, |
AnnaBridge | 145:64910690c574 | 106 | kSMARTCARD_SetupT1Mode = 0x13u, |
AnnaBridge | 145:64910690c574 | 107 | kSMARTCARD_EnableReceiverMode = 0x14u, |
AnnaBridge | 145:64910690c574 | 108 | kSMARTCARD_DisableReceiverMode = 0x15u, |
AnnaBridge | 145:64910690c574 | 109 | kSMARTCARD_EnableTransmitterMode = 0x16u, |
AnnaBridge | 145:64910690c574 | 110 | kSMARTCARD_DisableTransmitterMode = 0x17u, |
AnnaBridge | 145:64910690c574 | 111 | kSMARTCARD_ResetWaitTimeMultiplier = 0x18u, |
AnnaBridge | 145:64910690c574 | 112 | } smartcard_control_t; |
AnnaBridge | 145:64910690c574 | 113 | |
AnnaBridge | 145:64910690c574 | 114 | /*! @brief Defines Smart card interface voltage class values */ |
AnnaBridge | 145:64910690c574 | 115 | typedef enum _smartcard_card_voltage_class |
AnnaBridge | 145:64910690c574 | 116 | { |
AnnaBridge | 145:64910690c574 | 117 | kSMARTCARD_VoltageClassUnknown = 0x0u, |
AnnaBridge | 145:64910690c574 | 118 | kSMARTCARD_VoltageClassA5_0V = 0x1u, |
AnnaBridge | 145:64910690c574 | 119 | kSMARTCARD_VoltageClassB3_3V = 0x2u, |
AnnaBridge | 145:64910690c574 | 120 | kSMARTCARD_VoltageClassC1_8V = 0x3u |
AnnaBridge | 145:64910690c574 | 121 | } smartcard_card_voltage_class_t; |
AnnaBridge | 145:64910690c574 | 122 | |
AnnaBridge | 145:64910690c574 | 123 | /*! @brief Defines Smart card I/O transfer states */ |
AnnaBridge | 145:64910690c574 | 124 | typedef enum _smartcard_transfer_state |
AnnaBridge | 145:64910690c574 | 125 | { |
AnnaBridge | 145:64910690c574 | 126 | kSMARTCARD_IdleState = 0x0u, |
AnnaBridge | 145:64910690c574 | 127 | kSMARTCARD_WaitingForTSState = 0x1u, |
AnnaBridge | 145:64910690c574 | 128 | kSMARTCARD_InvalidTSDetecetedState = 0x2u, |
AnnaBridge | 145:64910690c574 | 129 | kSMARTCARD_ReceivingState = 0x3u, |
AnnaBridge | 145:64910690c574 | 130 | kSMARTCARD_TransmittingState = 0x4u, |
AnnaBridge | 145:64910690c574 | 131 | } smartcard_transfer_state_t; |
AnnaBridge | 145:64910690c574 | 132 | |
AnnaBridge | 145:64910690c574 | 133 | /*! @brief Defines Smart card reset types */ |
AnnaBridge | 145:64910690c574 | 134 | typedef enum _smartcard_reset_type |
AnnaBridge | 145:64910690c574 | 135 | { |
AnnaBridge | 145:64910690c574 | 136 | kSMARTCARD_ColdReset = 0x0u, |
AnnaBridge | 145:64910690c574 | 137 | kSMARTCARD_WarmReset = 0x1u, |
AnnaBridge | 145:64910690c574 | 138 | kSMARTCARD_NoColdReset = 0x2u, |
AnnaBridge | 145:64910690c574 | 139 | kSMARTCARD_NoWarmReset = 0x3u, |
AnnaBridge | 145:64910690c574 | 140 | } smartcard_reset_type_t; |
AnnaBridge | 145:64910690c574 | 141 | |
AnnaBridge | 145:64910690c574 | 142 | /*! @brief Defines Smart card transport protocol types */ |
AnnaBridge | 145:64910690c574 | 143 | typedef enum _smartcard_transport_type |
AnnaBridge | 145:64910690c574 | 144 | { |
AnnaBridge | 145:64910690c574 | 145 | kSMARTCARD_T0Transport = 0x0u, |
AnnaBridge | 145:64910690c574 | 146 | kSMARTCARD_T1Transport = 0x1u |
AnnaBridge | 145:64910690c574 | 147 | } smartcard_transport_type_t; |
AnnaBridge | 145:64910690c574 | 148 | |
AnnaBridge | 145:64910690c574 | 149 | /*! @brief Defines Smart card data parity types */ |
AnnaBridge | 145:64910690c574 | 150 | typedef enum _smartcard_parity_type |
AnnaBridge | 145:64910690c574 | 151 | { |
AnnaBridge | 145:64910690c574 | 152 | kSMARTCARD_EvenParity = 0x0u, |
AnnaBridge | 145:64910690c574 | 153 | kSMARTCARD_OddParity = 0x1u |
AnnaBridge | 145:64910690c574 | 154 | } smartcard_parity_type_t; |
AnnaBridge | 145:64910690c574 | 155 | |
AnnaBridge | 145:64910690c574 | 156 | /*! @brief Defines data Convention format */ |
AnnaBridge | 145:64910690c574 | 157 | typedef enum _smartcard_card_convention |
AnnaBridge | 145:64910690c574 | 158 | { |
AnnaBridge | 145:64910690c574 | 159 | kSMARTCARD_DirectConvention = 0x0u, |
AnnaBridge | 145:64910690c574 | 160 | kSMARTCARD_InverseConvention = 0x1u |
AnnaBridge | 145:64910690c574 | 161 | } smartcard_card_convention_t; |
AnnaBridge | 145:64910690c574 | 162 | |
AnnaBridge | 145:64910690c574 | 163 | /*! @brief Defines Smart card interface IC control types */ |
AnnaBridge | 145:64910690c574 | 164 | typedef enum _smartcard_interface_control |
AnnaBridge | 145:64910690c574 | 165 | { |
AnnaBridge | 145:64910690c574 | 166 | kSMARTCARD_InterfaceSetVcc = 0x00u, |
AnnaBridge | 145:64910690c574 | 167 | kSMARTCARD_InterfaceSetClockToResetDelay = 0x01u, |
AnnaBridge | 145:64910690c574 | 168 | kSMARTCARD_InterfaceReadStatus = 0x02u |
AnnaBridge | 145:64910690c574 | 169 | } smartcard_interface_control_t; |
AnnaBridge | 145:64910690c574 | 170 | |
AnnaBridge | 145:64910690c574 | 171 | /*! @brief Defines transfer direction.*/ |
AnnaBridge | 145:64910690c574 | 172 | typedef enum _smartcard_direction |
AnnaBridge | 145:64910690c574 | 173 | { |
AnnaBridge | 145:64910690c574 | 174 | kSMARTCARD_Receive = 0u, |
AnnaBridge | 145:64910690c574 | 175 | kSMARTCARD_Transmit = 1u |
AnnaBridge | 145:64910690c574 | 176 | } smartcard_direction_t; |
AnnaBridge | 145:64910690c574 | 177 | |
AnnaBridge | 145:64910690c574 | 178 | /*! @brief Smart card interface interrupt callback function type */ |
AnnaBridge | 145:64910690c574 | 179 | typedef void (*smartcard_interface_callback_t)(void *smartcardContext, void *param); |
AnnaBridge | 145:64910690c574 | 180 | /*! @brief Smart card transfer interrupt callback function type */ |
AnnaBridge | 145:64910690c574 | 181 | typedef void (*smartcard_transfer_callback_t)(void *smartcardContext, void *param); |
AnnaBridge | 145:64910690c574 | 182 | |
AnnaBridge | 145:64910690c574 | 183 | /*! @brief Time Delay function used to passive waiting using RTOS [ms] */ |
AnnaBridge | 145:64910690c574 | 184 | typedef void (*smartcard_time_delay_t)(uint32_t miliseconds); |
AnnaBridge | 145:64910690c574 | 185 | |
AnnaBridge | 145:64910690c574 | 186 | /*! @brief Defines card-specific parameters for Smart card driver */ |
AnnaBridge | 145:64910690c574 | 187 | typedef struct _smartcard_card_params |
AnnaBridge | 145:64910690c574 | 188 | { |
AnnaBridge | 145:64910690c574 | 189 | /* ISO7816/EMV4.3 specification variables */ |
AnnaBridge | 145:64910690c574 | 190 | uint16_t Fi; /*!< 4 bits Fi - clock rate conversion integer */ |
AnnaBridge | 145:64910690c574 | 191 | uint8_t fMax; /*!< Maximum Smart card frequency in MHz */ |
AnnaBridge | 145:64910690c574 | 192 | uint8_t WI; /*!< 8 bits WI - work wait time integer */ |
AnnaBridge | 145:64910690c574 | 193 | uint8_t Di; /*!< 4 bits DI - baud rate divisor */ |
AnnaBridge | 145:64910690c574 | 194 | uint8_t BWI; /*!< 4 bits BWI - block wait time integer */ |
AnnaBridge | 145:64910690c574 | 195 | uint8_t CWI; /*!< 4 bits CWI - character wait time integer */ |
AnnaBridge | 145:64910690c574 | 196 | uint8_t BGI; /*!< 4 bits BGI - block guard time integer */ |
AnnaBridge | 145:64910690c574 | 197 | uint8_t GTN; /*!< 8 bits GTN - extended guard time integer */ |
AnnaBridge | 145:64910690c574 | 198 | uint8_t IFSC; /*!< Indicates IFSC value of the card */ |
AnnaBridge | 145:64910690c574 | 199 | uint8_t modeNegotiable; /*!< Indicates if the card acts in negotiable or a specific mode. */ |
AnnaBridge | 145:64910690c574 | 200 | uint8_t currentD; /*!< 4 bits DI - current baud rate divisor*/ |
AnnaBridge | 145:64910690c574 | 201 | /* Driver-specific variables */ |
AnnaBridge | 145:64910690c574 | 202 | uint8_t status; /*!< Indicates smart card status */ |
AnnaBridge | 145:64910690c574 | 203 | bool t0Indicated; /*!< Indicates ff T=0 indicated in TD1 byte */ |
AnnaBridge | 145:64910690c574 | 204 | bool t1Indicated; /*!< Indicates if T=1 indicated in TD2 byte */ |
AnnaBridge | 145:64910690c574 | 205 | bool atrComplete; /*!< Indicates whether the ATR received from the card was complete or not */ |
AnnaBridge | 145:64910690c574 | 206 | bool atrValid; /*!< Indicates whether the ATR received from the card was valid or not */ |
AnnaBridge | 145:64910690c574 | 207 | bool present; /*!< Indicates if a smart card is present */ |
AnnaBridge | 145:64910690c574 | 208 | bool active; /*!< Indicates if the smart card is activated */ |
AnnaBridge | 145:64910690c574 | 209 | bool faulty; /*!< Indicates whether smart card/interface is faulty */ |
AnnaBridge | 145:64910690c574 | 210 | smartcard_card_convention_t convention; /*!< Card convention, kSMARTCARD_DirectConvention for direct convention, |
AnnaBridge | 145:64910690c574 | 211 | kSMARTCARD_InverseConvention for inverse convention */ |
AnnaBridge | 145:64910690c574 | 212 | } smartcard_card_params_t; |
AnnaBridge | 145:64910690c574 | 213 | |
AnnaBridge | 145:64910690c574 | 214 | /*! @brief Smart card Defines the state of the EMV timers in the Smart card driver */ |
AnnaBridge | 145:64910690c574 | 215 | typedef struct _smartcard_timers_state |
AnnaBridge | 145:64910690c574 | 216 | { |
AnnaBridge | 145:64910690c574 | 217 | volatile bool adtExpired; /*!< Indicates whether ADT timer expired */ |
AnnaBridge | 145:64910690c574 | 218 | volatile bool wwtExpired; /*!< Indicates whether WWT timer expired */ |
AnnaBridge | 145:64910690c574 | 219 | volatile bool cwtExpired; /*!< Indicates whether CWT timer expired */ |
AnnaBridge | 145:64910690c574 | 220 | volatile bool bwtExpired; /*!< Indicates whether BWT timer expired */ |
AnnaBridge | 145:64910690c574 | 221 | volatile bool initCharTimerExpired; /*!< Indicates whether reception timer |
AnnaBridge | 145:64910690c574 | 222 | for initialization character (TS) after the RST has expired */ |
AnnaBridge | 145:64910690c574 | 223 | } smartcard_timers_state_t; |
AnnaBridge | 145:64910690c574 | 224 | |
AnnaBridge | 145:64910690c574 | 225 | /*! @brief Defines user specified configuration of Smart card interface */ |
AnnaBridge | 145:64910690c574 | 226 | typedef struct _smartcard_interface_config |
AnnaBridge | 145:64910690c574 | 227 | { |
AnnaBridge | 145:64910690c574 | 228 | uint32_t smartCardClock; /*!< Smart card interface clock [Hz] */ |
AnnaBridge | 145:64910690c574 | 229 | uint32_t clockToResetDelay; /*!< Indicates clock to RST apply delay [smart card clock cycles] */ |
AnnaBridge | 145:64910690c574 | 230 | uint8_t clockModule; /*!< Smart card clock module number */ |
AnnaBridge | 145:64910690c574 | 231 | uint8_t clockModuleChannel; /*!< Smart card clock module channel number */ |
AnnaBridge | 145:64910690c574 | 232 | uint8_t clockModuleSourceClock; /*!< Smart card clock module source clock [e.g., BusClk] */ |
AnnaBridge | 145:64910690c574 | 233 | smartcard_card_voltage_class_t vcc; /*!< Smart card voltage class */ |
AnnaBridge | 145:64910690c574 | 234 | uint8_t controlPort; /*!< Smart card PHY control port instance */ |
AnnaBridge | 145:64910690c574 | 235 | uint8_t controlPin; /*!< Smart card PHY control pin instance */ |
AnnaBridge | 145:64910690c574 | 236 | uint8_t irqPort; /*!< Smart card PHY Interrupt port instance */ |
AnnaBridge | 145:64910690c574 | 237 | uint8_t irqPin; /*!< Smart card PHY Interrupt pin instance */ |
AnnaBridge | 145:64910690c574 | 238 | uint8_t resetPort; /*!< Smart card reset port instance */ |
AnnaBridge | 145:64910690c574 | 239 | uint8_t resetPin; /*!< Smart card reset pin instance */ |
AnnaBridge | 145:64910690c574 | 240 | uint8_t vsel0Port; /*!< Smart card PHY Vsel0 control port instance */ |
AnnaBridge | 145:64910690c574 | 241 | uint8_t vsel0Pin; /*!< Smart card PHY Vsel0 control pin instance */ |
AnnaBridge | 145:64910690c574 | 242 | uint8_t vsel1Port; /*!< Smart card PHY Vsel1 control port instance */ |
AnnaBridge | 145:64910690c574 | 243 | uint8_t vsel1Pin; /*!< Smart card PHY Vsel1 control pin instance */ |
AnnaBridge | 145:64910690c574 | 244 | uint8_t dataPort; /*!< Smart card PHY data port instance */ |
AnnaBridge | 145:64910690c574 | 245 | uint8_t dataPin; /*!< Smart card PHY data pin instance */ |
AnnaBridge | 145:64910690c574 | 246 | uint8_t dataPinMux; /*!< Smart card PHY data pin mux option */ |
AnnaBridge | 145:64910690c574 | 247 | uint8_t tsTimerId; /*!< Numerical identifier of the External HW timer for Initial character detection */ |
AnnaBridge | 145:64910690c574 | 248 | } smartcard_interface_config_t; |
AnnaBridge | 145:64910690c574 | 249 | |
AnnaBridge | 145:64910690c574 | 250 | /*! @brief Defines user transfer structure used to initialize transfer */ |
AnnaBridge | 145:64910690c574 | 251 | typedef struct _smartcard_xfer |
AnnaBridge | 145:64910690c574 | 252 | { |
AnnaBridge | 145:64910690c574 | 253 | smartcard_direction_t direction; /*!< Direction of communication. (RX/TX) */ |
AnnaBridge | 145:64910690c574 | 254 | uint8_t *buff; /*!< The buffer of data. */ |
AnnaBridge | 145:64910690c574 | 255 | size_t size; /*!< The number of transferred units. */ |
AnnaBridge | 145:64910690c574 | 256 | } smartcard_xfer_t; |
AnnaBridge | 145:64910690c574 | 257 | |
AnnaBridge | 145:64910690c574 | 258 | /*! |
AnnaBridge | 145:64910690c574 | 259 | * @brief Runtime state of the Smart card driver. |
AnnaBridge | 145:64910690c574 | 260 | */ |
AnnaBridge | 145:64910690c574 | 261 | typedef struct _smartcard_context |
AnnaBridge | 145:64910690c574 | 262 | { |
AnnaBridge | 145:64910690c574 | 263 | /* Xfer part */ |
AnnaBridge | 145:64910690c574 | 264 | void *base; /*!< Smart card module base address */ |
AnnaBridge | 145:64910690c574 | 265 | smartcard_direction_t direction; /*!< Direction of communication. (RX/TX) */ |
AnnaBridge | 145:64910690c574 | 266 | uint8_t *xBuff; /*!< The buffer of data being transferred.*/ |
AnnaBridge | 145:64910690c574 | 267 | volatile size_t xSize; /*!< The number of bytes to be transferred. */ |
AnnaBridge | 145:64910690c574 | 268 | volatile bool xIsBusy; /*!< True if there is an active transfer. */ |
AnnaBridge | 145:64910690c574 | 269 | uint8_t txFifoEntryCount; /*!< Number of data word entries in transmit FIFO. */ |
AnnaBridge | 145:64910690c574 | 270 | /* Smart card Interface part */ |
AnnaBridge | 145:64910690c574 | 271 | smartcard_interface_callback_t interfaceCallback; /*!< Callback to invoke after interface IC raised interrupt.*/ |
AnnaBridge | 145:64910690c574 | 272 | smartcard_transfer_callback_t transferCallback; /*!< Callback to invoke after transfer event occur.*/ |
AnnaBridge | 145:64910690c574 | 273 | void *interfaceCallbackParam; /*!< Interface callback parameter pointer.*/ |
AnnaBridge | 145:64910690c574 | 274 | void *transferCallbackParam; /*!< Transfer callback parameter pointer.*/ |
AnnaBridge | 145:64910690c574 | 275 | smartcard_time_delay_t timeDelay; /*!< Function which handles time delay defined by user or RTOS. */ |
AnnaBridge | 145:64910690c574 | 276 | smartcard_reset_type_t resetType; /*!< Indicates whether a Cold reset or Warm reset was requested. */ |
AnnaBridge | 145:64910690c574 | 277 | smartcard_transport_type_t tType; /*!< Indicates current transfer protocol (T0 or T1) */ |
AnnaBridge | 145:64910690c574 | 278 | /* Smart card State part */ |
AnnaBridge | 145:64910690c574 | 279 | volatile smartcard_transfer_state_t transferState; /*!< Indicates the current transfer state */ |
AnnaBridge | 145:64910690c574 | 280 | smartcard_timers_state_t timersState; /*!< Indicates the state of different protocol timers used in driver */ |
AnnaBridge | 145:64910690c574 | 281 | smartcard_card_params_t |
AnnaBridge | 145:64910690c574 | 282 | cardParams; /*!< Smart card parameters(ATR and current) and interface slots states(ATR and current) */ |
AnnaBridge | 145:64910690c574 | 283 | uint8_t IFSD; /*!< Indicates the terminal IFSD */ |
AnnaBridge | 145:64910690c574 | 284 | smartcard_parity_type_t parity; /*!< Indicates current parity even/odd */ |
AnnaBridge | 145:64910690c574 | 285 | volatile bool rxtCrossed; /*!< Indicates whether RXT thresholds has been crossed */ |
AnnaBridge | 145:64910690c574 | 286 | volatile bool txtCrossed; /*!< Indicates whether TXT thresholds has been crossed */ |
AnnaBridge | 145:64910690c574 | 287 | volatile bool wtxRequested; /*!< Indicates whether WTX has been requested or not*/ |
AnnaBridge | 145:64910690c574 | 288 | volatile bool parityError; /*!< Indicates whether a parity error has been detected */ |
AnnaBridge | 145:64910690c574 | 289 | uint8_t statusBytes[2]; /*!< Used to store Status bytes SW1, SW2 of the last executed card command response */ |
AnnaBridge | 145:64910690c574 | 290 | /* Configuration part */ |
AnnaBridge | 145:64910690c574 | 291 | smartcard_interface_config_t interfaceConfig; /*!< Smart card interface configuration structure */ |
AnnaBridge | 145:64910690c574 | 292 | |
AnnaBridge | 145:64910690c574 | 293 | } smartcard_context_t; |
AnnaBridge | 145:64910690c574 | 294 | |
AnnaBridge | 145:64910690c574 | 295 | /*! @}*/ |
AnnaBridge | 145:64910690c574 | 296 | #endif /* _FSL_SMARTCARD_H_*/ |