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.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew 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_EMVSIM_H_
AnnaBridge 145:64910690c574 32 #define _FSL_SMARTCARD_EMVSIM_H_
AnnaBridge 145:64910690c574 33
AnnaBridge 145:64910690c574 34 #include "fsl_smartcard.h"
AnnaBridge 145:64910690c574 35
AnnaBridge 145:64910690c574 36 /*!
AnnaBridge 145:64910690c574 37 * @addtogroup smartcard_emvsim_driver
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 /*! @brief EMV RX NACK interrupt generation threshold */
AnnaBridge 145:64910690c574 47 #define SMARTCARD_EMV_RX_NACK_THRESHOLD (5u)
AnnaBridge 145:64910690c574 48
AnnaBridge 145:64910690c574 49 /*! @brief EMV TX NACK interrupt generation threshold */
AnnaBridge 145:64910690c574 50 #define SMARTCARD_EMV_TX_NACK_THRESHOLD (5u)
AnnaBridge 145:64910690c574 51
AnnaBridge 145:64910690c574 52 /*! @brief Smart card Word Wait Timer adjustment value */
AnnaBridge 145:64910690c574 53 #define SMARTCARD_WWT_ADJUSTMENT (160u)
AnnaBridge 145:64910690c574 54
AnnaBridge 145:64910690c574 55 /*! @brief Smart card Character Wait Timer adjustment value */
AnnaBridge 145:64910690c574 56 #define SMARTCARD_CWT_ADJUSTMENT (3u)
AnnaBridge 145:64910690c574 57
AnnaBridge 145:64910690c574 58 /*! @brief General Purpose Counter clock selections */
AnnaBridge 145:64910690c574 59 typedef enum _emvsim_gpc_clock_select
AnnaBridge 145:64910690c574 60 {
AnnaBridge 145:64910690c574 61 kEMVSIM_GPCClockDisable = 0u, /*!< Disabled */
AnnaBridge 145:64910690c574 62 kEMVSIM_GPCCardClock = 1u, /*!< Card clock */
AnnaBridge 145:64910690c574 63 kEMVSIM_GPCRxClock = 2u, /*!< Receive clock */
AnnaBridge 145:64910690c574 64 kEMVSIM_GPCTxClock = 3u, /*!< Transmit ETU clock */
AnnaBridge 145:64910690c574 65 } emvsim_gpc_clock_select_t;
AnnaBridge 145:64910690c574 66
AnnaBridge 145:64910690c574 67 /*! @brief EMVSIM card presence detection edge control */
AnnaBridge 145:64910690c574 68 typedef enum _presence_detect_edge
AnnaBridge 145:64910690c574 69 {
AnnaBridge 145:64910690c574 70 kEMVSIM_DetectOnFallingEdge = 0u, /*!< Presence detected on the falling edge */
AnnaBridge 145:64910690c574 71 kEMVSIM_DetectOnRisingEdge = 1u, /*!< Presence detected on the rising edge */
AnnaBridge 145:64910690c574 72 } emvsim_presence_detect_edge_t;
AnnaBridge 145:64910690c574 73
AnnaBridge 145:64910690c574 74 /*! @brief EMVSIM card presence detection status */
AnnaBridge 145:64910690c574 75 typedef enum _presence_detect_status
AnnaBridge 145:64910690c574 76 {
AnnaBridge 145:64910690c574 77 kEMVSIM_DetectPinIsLow = 0u, /*!< Presence detected pin is logic low */
AnnaBridge 145:64910690c574 78 kEMVSIM_DetectPinIsHigh = 1u, /*!< Presence detected pin is logic high */
AnnaBridge 145:64910690c574 79 } emvsim_presence_detect_status_t;
AnnaBridge 145:64910690c574 80
AnnaBridge 145:64910690c574 81 /*******************************************************************************
AnnaBridge 145:64910690c574 82 * API
AnnaBridge 145:64910690c574 83 ******************************************************************************/
AnnaBridge 145:64910690c574 84 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 85 extern "C" {
AnnaBridge 145:64910690c574 86 #endif
AnnaBridge 145:64910690c574 87
AnnaBridge 145:64910690c574 88 /*!
AnnaBridge 145:64910690c574 89 * @name Smart card EMVSIM Driver
AnnaBridge 145:64910690c574 90 * @{
AnnaBridge 145:64910690c574 91 */
AnnaBridge 145:64910690c574 92
AnnaBridge 145:64910690c574 93 /*!
AnnaBridge 145:64910690c574 94 * @brief Fills in the smartcard_card_params structure with default values according to the EMV 4.3 specification.
AnnaBridge 145:64910690c574 95 *
AnnaBridge 145:64910690c574 96 * @param cardParams The configuration structure of type smartcard_interface_config_t.
AnnaBridge 145:64910690c574 97 * Function fill in members:
AnnaBridge 145:64910690c574 98 * Fi = 372;
AnnaBridge 145:64910690c574 99 * Di = 1;
AnnaBridge 145:64910690c574 100 * currentD = 1;
AnnaBridge 145:64910690c574 101 * WI = 0x0A;
AnnaBridge 145:64910690c574 102 * GTN = 0x00;
AnnaBridge 145:64910690c574 103 * with default values.
AnnaBridge 145:64910690c574 104 */
AnnaBridge 145:64910690c574 105 void SMARTCARD_EMVSIM_GetDefaultConfig(smartcard_card_params_t *cardParams);
AnnaBridge 145:64910690c574 106
AnnaBridge 145:64910690c574 107 /*!
AnnaBridge 145:64910690c574 108 * @brief Initializes an EMVSIM peripheral for the Smart card/ISO-7816 operation.
AnnaBridge 145:64910690c574 109 *
AnnaBridge 145:64910690c574 110 * This function un-gates the EMVSIM clock, initializes the module to EMV default settings,
AnnaBridge 145:64910690c574 111 * configures the IRQ, enables the module-level interrupt to the core and, initializes the driver context.
AnnaBridge 145:64910690c574 112 *
AnnaBridge 145:64910690c574 113 * @param base The EMVSIM peripheral base address.
AnnaBridge 145:64910690c574 114 * @param context A pointer to the smart card driver context structure.
AnnaBridge 145:64910690c574 115 * @param srcClock_Hz Smart card clock generation module source clock.
AnnaBridge 145:64910690c574 116 *
AnnaBridge 145:64910690c574 117 * @return An error code or kStatus_SMARTCARD_Success.
AnnaBridge 145:64910690c574 118 */
AnnaBridge 145:64910690c574 119 status_t SMARTCARD_EMVSIM_Init(EMVSIM_Type *base, smartcard_context_t *context, uint32_t srcClock_Hz);
AnnaBridge 145:64910690c574 120
AnnaBridge 145:64910690c574 121 /*!
AnnaBridge 145:64910690c574 122 * @brief This function disables the EMVSIM interrupts, disables the transmitter and receiver,
AnnaBridge 145:64910690c574 123 * flushes the FIFOs, and gates EMVSIM clock in SIM.
AnnaBridge 145:64910690c574 124 *
AnnaBridge 145:64910690c574 125 * @param base The EMVSIM module base address.
AnnaBridge 145:64910690c574 126 */
AnnaBridge 145:64910690c574 127 void SMARTCARD_EMVSIM_Deinit(EMVSIM_Type *base);
AnnaBridge 145:64910690c574 128
AnnaBridge 145:64910690c574 129 /*!
AnnaBridge 145:64910690c574 130 * @brief Returns whether the previous EMVSIM transfer has finished.
AnnaBridge 145:64910690c574 131 *
AnnaBridge 145:64910690c574 132 * When performing an async transfer, call this function to ascertain the context of the
AnnaBridge 145:64910690c574 133 * current transfer: in progress (or busy) or complete (success). If the
AnnaBridge 145:64910690c574 134 * transfer is still in progress, the user can obtain the number of words that have not been
AnnaBridge 145:64910690c574 135 * transferred.
AnnaBridge 145:64910690c574 136 *
AnnaBridge 145:64910690c574 137 * @param base The EMVSIM module base address.
AnnaBridge 145:64910690c574 138 * @param context A pointer to a smart card driver context structure.
AnnaBridge 145:64910690c574 139 *
AnnaBridge 145:64910690c574 140 * @return The number of bytes not transferred.
AnnaBridge 145:64910690c574 141 */
AnnaBridge 145:64910690c574 142 int32_t SMARTCARD_EMVSIM_GetTransferRemainingBytes(EMVSIM_Type *base, smartcard_context_t *context);
AnnaBridge 145:64910690c574 143
AnnaBridge 145:64910690c574 144 /*!
AnnaBridge 145:64910690c574 145 * @brief Terminates an asynchronous EMVSIM transfer early.
AnnaBridge 145:64910690c574 146 *
AnnaBridge 145:64910690c574 147 * During an async EMVSIM transfer, the user can terminate the transfer early
AnnaBridge 145:64910690c574 148 * if the transfer is still in progress.
AnnaBridge 145:64910690c574 149 *
AnnaBridge 145:64910690c574 150 * @param base The EMVSIM peripheral address.
AnnaBridge 145:64910690c574 151 * @param context A pointer to a smart card driver context structure.
AnnaBridge 145:64910690c574 152 * @retval kStatus_SMARTCARD_Success The transmit abort was successful.
AnnaBridge 145:64910690c574 153 * @retval kStatus_SMARTCARD_NoTransmitInProgress No transmission is currently in progress.
AnnaBridge 145:64910690c574 154 */
AnnaBridge 145:64910690c574 155 status_t SMARTCARD_EMVSIM_AbortTransfer(EMVSIM_Type *base, smartcard_context_t *context);
AnnaBridge 145:64910690c574 156
AnnaBridge 145:64910690c574 157 /*!
AnnaBridge 145:64910690c574 158 * @brief Transfer data using interrupts.
AnnaBridge 145:64910690c574 159 *
AnnaBridge 145:64910690c574 160 * A non-blocking (also known as asynchronous) function means that the function returns
AnnaBridge 145:64910690c574 161 * immediately after initiating the transfer function. The application has to get the
AnnaBridge 145:64910690c574 162 * transfer status to see when the transfer is complete. In other words, after calling the non-blocking
AnnaBridge 145:64910690c574 163 * (asynchronous) transfer function, the application must get the transfer status to check if the transmit
AnnaBridge 145:64910690c574 164 * is completed or not.
AnnaBridge 145:64910690c574 165 *
AnnaBridge 145:64910690c574 166 * @param base The EMVSIM peripheral base address.
AnnaBridge 145:64910690c574 167 * @param context A pointer to a smart card driver context structure.
AnnaBridge 145:64910690c574 168 * @param xfer A pointer to the smart card transfer structure where the linked buffers and sizes are stored.
AnnaBridge 145:64910690c574 169 *
AnnaBridge 145:64910690c574 170 * @return An error code or kStatus_SMARTCARD_Success.
AnnaBridge 145:64910690c574 171 */
AnnaBridge 145:64910690c574 172 status_t SMARTCARD_EMVSIM_TransferNonBlocking(EMVSIM_Type *base, smartcard_context_t *context, smartcard_xfer_t *xfer);
AnnaBridge 145:64910690c574 173
AnnaBridge 145:64910690c574 174 /*!
AnnaBridge 145:64910690c574 175 * @brief Controls the EMVSIM module per different user request.
AnnaBridge 145:64910690c574 176 *
AnnaBridge 145:64910690c574 177 * @param base The EMVSIM peripheral base address.
AnnaBridge 145:64910690c574 178 * @param context A pointer to a smart card driver context structure.
AnnaBridge 145:64910690c574 179 * @param control Control type.
AnnaBridge 145:64910690c574 180 * @param param Integer value of specific to control command.
AnnaBridge 145:64910690c574 181 *
AnnaBridge 145:64910690c574 182 * return kStatus_SMARTCARD_Success in success.
AnnaBridge 145:64910690c574 183 * return kStatus_SMARTCARD_OtherError in case of error.
AnnaBridge 145:64910690c574 184 */
AnnaBridge 145:64910690c574 185 status_t SMARTCARD_EMVSIM_Control(EMVSIM_Type *base,
AnnaBridge 145:64910690c574 186 smartcard_context_t *context,
AnnaBridge 145:64910690c574 187 smartcard_control_t control,
AnnaBridge 145:64910690c574 188 uint32_t param);
AnnaBridge 145:64910690c574 189
AnnaBridge 145:64910690c574 190 /*!
AnnaBridge 145:64910690c574 191 * @brief Handles EMVSIM module interrupts.
AnnaBridge 145:64910690c574 192 *
AnnaBridge 145:64910690c574 193 * @param base The EMVSIM peripheral base address.
AnnaBridge 145:64910690c574 194 * @param context A pointer to a smart card driver context structure.
AnnaBridge 145:64910690c574 195 */
AnnaBridge 145:64910690c574 196 void SMARTCARD_EMVSIM_IRQHandler(EMVSIM_Type *base, smartcard_context_t *context);
AnnaBridge 145:64910690c574 197 /*@}*/
AnnaBridge 145:64910690c574 198
AnnaBridge 145:64910690c574 199 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 200 }
AnnaBridge 145:64910690c574 201 #endif
AnnaBridge 145:64910690c574 202
AnnaBridge 145:64910690c574 203 /*! @}*/
AnnaBridge 145:64910690c574 204
AnnaBridge 145:64910690c574 205 #endif /* _FSL_SMARTCARD_EMVSIM_H_*/