mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 189:f392fc9709a3 1 /*
AnnaBridge 189:f392fc9709a3 2 * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
AnnaBridge 189:f392fc9709a3 3 * All rights reserved.
AnnaBridge 189:f392fc9709a3 4 *
AnnaBridge 189:f392fc9709a3 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 189:f392fc9709a3 6 * are permitted provided that the following conditions are met:
AnnaBridge 189:f392fc9709a3 7 *
AnnaBridge 189:f392fc9709a3 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 189:f392fc9709a3 9 * of conditions and the following disclaimer.
AnnaBridge 189:f392fc9709a3 10 *
AnnaBridge 189:f392fc9709a3 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 189:f392fc9709a3 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 189:f392fc9709a3 13 * other materials provided with the distribution.
AnnaBridge 189:f392fc9709a3 14 *
AnnaBridge 189:f392fc9709a3 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
AnnaBridge 189:f392fc9709a3 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 189:f392fc9709a3 17 * software without specific prior written permission.
AnnaBridge 189:f392fc9709a3 18 *
AnnaBridge 189:f392fc9709a3 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 189:f392fc9709a3 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 189:f392fc9709a3 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 189:f392fc9709a3 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 189:f392fc9709a3 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 189:f392fc9709a3 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 189:f392fc9709a3 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 189:f392fc9709a3 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 189:f392fc9709a3 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 189:f392fc9709a3 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 189:f392fc9709a3 29 */
AnnaBridge 189:f392fc9709a3 30
AnnaBridge 189:f392fc9709a3 31 #ifndef _FSL_SMARTCARD_EMVSIM_H_
AnnaBridge 189:f392fc9709a3 32 #define _FSL_SMARTCARD_EMVSIM_H_
AnnaBridge 189:f392fc9709a3 33
AnnaBridge 189:f392fc9709a3 34 #include "fsl_smartcard.h"
AnnaBridge 189:f392fc9709a3 35
AnnaBridge 189:f392fc9709a3 36 /*!
AnnaBridge 189:f392fc9709a3 37 * @addtogroup smartcard_emvsim_driver
AnnaBridge 189:f392fc9709a3 38 * @{
AnnaBridge 189:f392fc9709a3 39 */
AnnaBridge 189:f392fc9709a3 40
AnnaBridge 189:f392fc9709a3 41
AnnaBridge 189:f392fc9709a3 42 /*******************************************************************************
AnnaBridge 189:f392fc9709a3 43 * Definitions
AnnaBridge 189:f392fc9709a3 44 ******************************************************************************/
AnnaBridge 189:f392fc9709a3 45
AnnaBridge 189:f392fc9709a3 46 /*! @brief EMV RX NACK interrupt generation threshold */
AnnaBridge 189:f392fc9709a3 47 #define SMARTCARD_EMV_RX_NACK_THRESHOLD (5u)
AnnaBridge 189:f392fc9709a3 48
AnnaBridge 189:f392fc9709a3 49 /*! @brief EMV TX NACK interrupt generation threshold */
AnnaBridge 189:f392fc9709a3 50 #define SMARTCARD_EMV_TX_NACK_THRESHOLD (5u)
AnnaBridge 189:f392fc9709a3 51
AnnaBridge 189:f392fc9709a3 52 /*! @brief Smart card Word Wait Timer adjustment value */
AnnaBridge 189:f392fc9709a3 53 #define SMARTCARD_WWT_ADJUSTMENT (160u)
AnnaBridge 189:f392fc9709a3 54
AnnaBridge 189:f392fc9709a3 55 /*! @brief Smart card Character Wait Timer adjustment value */
AnnaBridge 189:f392fc9709a3 56 #define SMARTCARD_CWT_ADJUSTMENT (3u)
AnnaBridge 189:f392fc9709a3 57
AnnaBridge 189:f392fc9709a3 58 /*! @brief General Purpose Counter clock selections */
AnnaBridge 189:f392fc9709a3 59 typedef enum _emvsim_gpc_clock_select
AnnaBridge 189:f392fc9709a3 60 {
AnnaBridge 189:f392fc9709a3 61 kEMVSIM_GPCClockDisable = 0u, /*!< Disabled */
AnnaBridge 189:f392fc9709a3 62 kEMVSIM_GPCCardClock = 1u, /*!< Card clock */
AnnaBridge 189:f392fc9709a3 63 kEMVSIM_GPCRxClock = 2u, /*!< Receive clock */
AnnaBridge 189:f392fc9709a3 64 kEMVSIM_GPCTxClock = 3u, /*!< Transmit ETU clock */
AnnaBridge 189:f392fc9709a3 65 } emvsim_gpc_clock_select_t;
AnnaBridge 189:f392fc9709a3 66
AnnaBridge 189:f392fc9709a3 67 /*! @brief EMVSIM card presence detection edge control */
AnnaBridge 189:f392fc9709a3 68 typedef enum _presence_detect_edge
AnnaBridge 189:f392fc9709a3 69 {
AnnaBridge 189:f392fc9709a3 70 kEMVSIM_DetectOnFallingEdge = 0u, /*!< Presence detected on the falling edge */
AnnaBridge 189:f392fc9709a3 71 kEMVSIM_DetectOnRisingEdge = 1u, /*!< Presence detected on the rising edge */
AnnaBridge 189:f392fc9709a3 72 } emvsim_presence_detect_edge_t;
AnnaBridge 189:f392fc9709a3 73
AnnaBridge 189:f392fc9709a3 74 /*! @brief EMVSIM card presence detection status */
AnnaBridge 189:f392fc9709a3 75 typedef enum _presence_detect_status
AnnaBridge 189:f392fc9709a3 76 {
AnnaBridge 189:f392fc9709a3 77 kEMVSIM_DetectPinIsLow = 0u, /*!< Presence detected pin is logic low */
AnnaBridge 189:f392fc9709a3 78 kEMVSIM_DetectPinIsHigh = 1u, /*!< Presence detected pin is logic high */
AnnaBridge 189:f392fc9709a3 79 } emvsim_presence_detect_status_t;
AnnaBridge 189:f392fc9709a3 80
AnnaBridge 189:f392fc9709a3 81 /*******************************************************************************
AnnaBridge 189:f392fc9709a3 82 * API
AnnaBridge 189:f392fc9709a3 83 ******************************************************************************/
AnnaBridge 189:f392fc9709a3 84 #if defined(__cplusplus)
AnnaBridge 189:f392fc9709a3 85 extern "C" {
AnnaBridge 189:f392fc9709a3 86 #endif
AnnaBridge 189:f392fc9709a3 87
AnnaBridge 189:f392fc9709a3 88 /*!
AnnaBridge 189:f392fc9709a3 89 * @name Smart card EMVSIM Driver
AnnaBridge 189:f392fc9709a3 90 * @{
AnnaBridge 189:f392fc9709a3 91 */
AnnaBridge 189:f392fc9709a3 92
AnnaBridge 189:f392fc9709a3 93 /*!
AnnaBridge 189:f392fc9709a3 94 * @brief Fills in the smartcard_card_params structure with default values according to the EMV 4.3 specification.
AnnaBridge 189:f392fc9709a3 95 *
AnnaBridge 189:f392fc9709a3 96 * @param cardParams The configuration structure of type smartcard_interface_config_t.
AnnaBridge 189:f392fc9709a3 97 * Function fill in members:
AnnaBridge 189:f392fc9709a3 98 * Fi = 372;
AnnaBridge 189:f392fc9709a3 99 * Di = 1;
AnnaBridge 189:f392fc9709a3 100 * currentD = 1;
AnnaBridge 189:f392fc9709a3 101 * WI = 0x0A;
AnnaBridge 189:f392fc9709a3 102 * GTN = 0x00;
AnnaBridge 189:f392fc9709a3 103 * with default values.
AnnaBridge 189:f392fc9709a3 104 */
AnnaBridge 189:f392fc9709a3 105 void SMARTCARD_EMVSIM_GetDefaultConfig(smartcard_card_params_t *cardParams);
AnnaBridge 189:f392fc9709a3 106
AnnaBridge 189:f392fc9709a3 107 /*!
AnnaBridge 189:f392fc9709a3 108 * @brief Initializes an EMVSIM peripheral for the Smart card/ISO-7816 operation.
AnnaBridge 189:f392fc9709a3 109 *
AnnaBridge 189:f392fc9709a3 110 * This function un-gates the EMVSIM clock, initializes the module to EMV default settings,
AnnaBridge 189:f392fc9709a3 111 * configures the IRQ, enables the module-level interrupt to the core and, initializes the driver context.
AnnaBridge 189:f392fc9709a3 112 *
AnnaBridge 189:f392fc9709a3 113 * @param base The EMVSIM peripheral base address.
AnnaBridge 189:f392fc9709a3 114 * @param context A pointer to the smart card driver context structure.
AnnaBridge 189:f392fc9709a3 115 * @param srcClock_Hz Smart card clock generation module source clock.
AnnaBridge 189:f392fc9709a3 116 *
AnnaBridge 189:f392fc9709a3 117 * @return An error code or kStatus_SMARTCARD_Success.
AnnaBridge 189:f392fc9709a3 118 */
AnnaBridge 189:f392fc9709a3 119 status_t SMARTCARD_EMVSIM_Init(EMVSIM_Type *base, smartcard_context_t *context, uint32_t srcClock_Hz);
AnnaBridge 189:f392fc9709a3 120
AnnaBridge 189:f392fc9709a3 121 /*!
AnnaBridge 189:f392fc9709a3 122 * @brief This function disables the EMVSIM interrupts, disables the transmitter and receiver,
AnnaBridge 189:f392fc9709a3 123 * flushes the FIFOs, and gates EMVSIM clock in SIM.
AnnaBridge 189:f392fc9709a3 124 *
AnnaBridge 189:f392fc9709a3 125 * @param base The EMVSIM module base address.
AnnaBridge 189:f392fc9709a3 126 */
AnnaBridge 189:f392fc9709a3 127 void SMARTCARD_EMVSIM_Deinit(EMVSIM_Type *base);
AnnaBridge 189:f392fc9709a3 128
AnnaBridge 189:f392fc9709a3 129 /*!
AnnaBridge 189:f392fc9709a3 130 * @brief Returns whether the previous EMVSIM transfer has finished.
AnnaBridge 189:f392fc9709a3 131 *
AnnaBridge 189:f392fc9709a3 132 * When performing an async transfer, call this function to ascertain the context of the
AnnaBridge 189:f392fc9709a3 133 * current transfer: in progress (or busy) or complete (success). If the
AnnaBridge 189:f392fc9709a3 134 * transfer is still in progress, the user can obtain the number of words that have not been
AnnaBridge 189:f392fc9709a3 135 * transferred.
AnnaBridge 189:f392fc9709a3 136 *
AnnaBridge 189:f392fc9709a3 137 * @param base The EMVSIM module base address.
AnnaBridge 189:f392fc9709a3 138 * @param context A pointer to a smart card driver context structure.
AnnaBridge 189:f392fc9709a3 139 *
AnnaBridge 189:f392fc9709a3 140 * @return The number of bytes not transferred.
AnnaBridge 189:f392fc9709a3 141 */
AnnaBridge 189:f392fc9709a3 142 int32_t SMARTCARD_EMVSIM_GetTransferRemainingBytes(EMVSIM_Type *base, smartcard_context_t *context);
AnnaBridge 189:f392fc9709a3 143
AnnaBridge 189:f392fc9709a3 144 /*!
AnnaBridge 189:f392fc9709a3 145 * @brief Terminates an asynchronous EMVSIM transfer early.
AnnaBridge 189:f392fc9709a3 146 *
AnnaBridge 189:f392fc9709a3 147 * During an async EMVSIM transfer, the user can terminate the transfer early
AnnaBridge 189:f392fc9709a3 148 * if the transfer is still in progress.
AnnaBridge 189:f392fc9709a3 149 *
AnnaBridge 189:f392fc9709a3 150 * @param base The EMVSIM peripheral address.
AnnaBridge 189:f392fc9709a3 151 * @param context A pointer to a smart card driver context structure.
AnnaBridge 189:f392fc9709a3 152 * @retval kStatus_SMARTCARD_Success The transmit abort was successful.
AnnaBridge 189:f392fc9709a3 153 * @retval kStatus_SMARTCARD_NoTransmitInProgress No transmission is currently in progress.
AnnaBridge 189:f392fc9709a3 154 */
AnnaBridge 189:f392fc9709a3 155 status_t SMARTCARD_EMVSIM_AbortTransfer(EMVSIM_Type *base, smartcard_context_t *context);
AnnaBridge 189:f392fc9709a3 156
AnnaBridge 189:f392fc9709a3 157 /*!
AnnaBridge 189:f392fc9709a3 158 * @brief Transfer data using interrupts.
AnnaBridge 189:f392fc9709a3 159 *
AnnaBridge 189:f392fc9709a3 160 * A non-blocking (also known as asynchronous) function means that the function returns
AnnaBridge 189:f392fc9709a3 161 * immediately after initiating the transfer function. The application has to get the
AnnaBridge 189:f392fc9709a3 162 * transfer status to see when the transfer is complete. In other words, after calling the non-blocking
AnnaBridge 189:f392fc9709a3 163 * (asynchronous) transfer function, the application must get the transfer status to check if the transmit
AnnaBridge 189:f392fc9709a3 164 * is completed or not.
AnnaBridge 189:f392fc9709a3 165 *
AnnaBridge 189:f392fc9709a3 166 * @param base The EMVSIM peripheral base address.
AnnaBridge 189:f392fc9709a3 167 * @param context A pointer to a smart card driver context structure.
AnnaBridge 189:f392fc9709a3 168 * @param xfer A pointer to the smart card transfer structure where the linked buffers and sizes are stored.
AnnaBridge 189:f392fc9709a3 169 *
AnnaBridge 189:f392fc9709a3 170 * @return An error code or kStatus_SMARTCARD_Success.
AnnaBridge 189:f392fc9709a3 171 */
AnnaBridge 189:f392fc9709a3 172 status_t SMARTCARD_EMVSIM_TransferNonBlocking(EMVSIM_Type *base, smartcard_context_t *context, smartcard_xfer_t *xfer);
AnnaBridge 189:f392fc9709a3 173
AnnaBridge 189:f392fc9709a3 174 /*!
AnnaBridge 189:f392fc9709a3 175 * @brief Controls the EMVSIM module per different user request.
AnnaBridge 189:f392fc9709a3 176 *
AnnaBridge 189:f392fc9709a3 177 * @param base The EMVSIM peripheral base address.
AnnaBridge 189:f392fc9709a3 178 * @param context A pointer to a smart card driver context structure.
AnnaBridge 189:f392fc9709a3 179 * @param control Control type.
AnnaBridge 189:f392fc9709a3 180 * @param param Integer value of specific to control command.
AnnaBridge 189:f392fc9709a3 181 *
AnnaBridge 189:f392fc9709a3 182 * return kStatus_SMARTCARD_Success in success.
AnnaBridge 189:f392fc9709a3 183 * return kStatus_SMARTCARD_OtherError in case of error.
AnnaBridge 189:f392fc9709a3 184 */
AnnaBridge 189:f392fc9709a3 185 status_t SMARTCARD_EMVSIM_Control(EMVSIM_Type *base,
AnnaBridge 189:f392fc9709a3 186 smartcard_context_t *context,
AnnaBridge 189:f392fc9709a3 187 smartcard_control_t control,
AnnaBridge 189:f392fc9709a3 188 uint32_t param);
AnnaBridge 189:f392fc9709a3 189
AnnaBridge 189:f392fc9709a3 190 /*!
AnnaBridge 189:f392fc9709a3 191 * @brief Handles EMVSIM module interrupts.
AnnaBridge 189:f392fc9709a3 192 *
AnnaBridge 189:f392fc9709a3 193 * @param base The EMVSIM peripheral base address.
AnnaBridge 189:f392fc9709a3 194 * @param context A pointer to a smart card driver context structure.
AnnaBridge 189:f392fc9709a3 195 */
AnnaBridge 189:f392fc9709a3 196 void SMARTCARD_EMVSIM_IRQHandler(EMVSIM_Type *base, smartcard_context_t *context);
AnnaBridge 189:f392fc9709a3 197 /*@}*/
AnnaBridge 189:f392fc9709a3 198
AnnaBridge 189:f392fc9709a3 199 #if defined(__cplusplus)
AnnaBridge 189:f392fc9709a3 200 }
AnnaBridge 189:f392fc9709a3 201 #endif
AnnaBridge 189:f392fc9709a3 202
AnnaBridge 189:f392fc9709a3 203 /*! @}*/
AnnaBridge 189:f392fc9709a3 204
AnnaBridge 189:f392fc9709a3 205 #endif /* _FSL_SMARTCARD_EMVSIM_H_*/