SClib.h

Smart Card Library

Smart Card Library
SClib.h

FileName: SClib.h Dependencies: See INCLUDES section Processor: PIC18, PIC24 & PIC32 Microcontrollers Hardware: This demo is natively intended to be used on Exp 16, LPC & HPC Exp board. This demo can be modified for use on other hardware platforms. Complier: Microchip C18 (for PIC18), C30 (for PIC24) & C30 (for PIC32) Company: Microchip Technology, Inc. 

Software License Agreement: 

The software supplied herewith by Microchip Technology Incorporated (the “Company”) for its PIC® Microcontroller is intended and supplied to you, the Company’s customer, for use solely and exclusively on Microchip PIC Microcontroller products. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. 

THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 

 

******************************************************************

File Description: 

Change History: Rev Description

--- ----------------------------------------

1.0 Initial release 1.01 Cleaned up unnecessary variables,supported T=1 protocol and improvments in T=0 functions following the coding standards 1.02.2 Modifed PPS functionality API. Modified the code in more structured way.

Enumerations
 
Name 
Description 
 
Smart Card error types 
 
Block types in T=1 protocol 
Functions
 
Name 
Description 
 
This macro checks if card is inserted in the socket 
 
This function does the PPS exchange with the smart card & configures the baud rate of the PIC UART module as per the PPS response from the smart card. 
 
This function returns the current state of SmartCard 
 
This function initializes the smart card library 
 
This function performs the power on sequence of the SmartCard and interprets the Answer-to-Reset data received from the card. 
 
This function Performs the Power Down sequence of the SmartCard 
 
This function Sends/recieves the ISO 7816-4 compaliant APDU commands to the card. 
 
This function Sends/recieves the ISO 7816-4 compaliant T = 1 commands to the card. 
Macros
 
Name 
Description 
 
Smart Card Library 
 
PCB byte for Abort Response of T1 Protocol 
 
Authenticate Command code to the Smart Card 
 
DEFAULT Value of BWI Indicator used in calculation of BWT for T=1 protocol 
 
Change Pin Command code to the Smart Card 
 
Clear Card Command code to the Smart Card 
 
Cyclic Redundancy Check(CRC) type is used for EDC in Epilogue Field 
 
Credit Command code to the Smart Card 
 
DEFAULT Value of CWI Indicator used in calculation of CWT for T=1 protocol 
 
Debit Command code to the Smart Card 
 
Get Response Command code to the Smart Card 
 
PCB byte for IFS Response of T1 Protocol 
 
Inquire Account Command code to the Smart Card 
 
Longitudnal Redundancy Check(LRC) type is used for EDC in Epilogue Field 
 
Read Record Command code to the Smart Card 
 
PCB byte for Resync Request of T1 Protocol 
 
Revoke Command code to the Smart Card 
 
Select File Command code to the Smart Card 
 
Start Session Command code to the Smart Card 
 
Card is powered and ATR received 
 
Card present but not powered 
 
No Card Detected 
 
Submit Code Command to the Smart Card 
 
Returns '1' if T=0 protocol is supported & Returns 0 otherwise 
 
Returns '1' if T=1 protocol is supported & Returns 0 otherwise 
 
Returns '1' if TA1 present & Returns 0 otherwise 
 
Returns '1' if TA2 present & Returns 0 otherwise 
 
Returns '1' if TB1 present & Returns 0 otherwise 
 
Returns '1' if TB2 present & Returns 0 otherwise 
 
Returns '1' if TC1 present & Returns 0 otherwise 
 
Returns '1' if TC2 present & Returns 0 otherwise 
 
Returns '1' if TD1 present & Returns 0 otherwise 
 
Returns '1' if TD2 present & Returns 0 otherwise 
 
PCB byte for Wait Time Extension Response of T1 Protocol 
 
DEFAULT Value of WI Indicator used in calculation of WWT for T=0 protocol 
 
Write Record Command code to the Smart Card 
Structures
 
Name 
Description 
 
SmartCard APDU Command 7816-4 
 
SmartCard APDU Response structure 7816-4 
 
Prologue Field for T=1 Protocol 
Variables
 
Name 
Description 
 
Historical bytes sent by Smart Card 
 
Number of Historical bytes present 
 
length of ATR data sent by smart card 
 
ATR data sent by smartcard. 
 
Smart Card Error type is stored in this variable 
 
PPS Response Bytes 
 
Length of PPS Response 
 
TA1 determines the clock-rate conversion factor F & bit-rate-adjustment factor D 
 
TA2 determines whether the smart card will operate in specific mode or negotiable mode following the ATR 
 
TA3 conveys the Information Field Size Integer (IFSI) for the smart card. 
 
TB1 conveys information on the smart card's programming voltage requirements. 
 
TB2 conveys PI2, which determines the value of programming voltage required by the smart card. The value of PI1 in TB1 is superceded when TB2 is present 
 
TB3 indicates the value of the Character Waiting Time Integer (CWI) and Block Waiting Time Integer (BWI) used to compute the Character Waiting Time (CWT) and Block Waiting Time (BWT). 
 
TC1 determines the extra guard time to be added between consecutive characters sent to the smart card from the terminal. 
 
TC2 is specific to protocol type T=0. TC2 conveys work waiting-time integer (WI) that determines the maximum interval between the leading edge of the start bit of any character sent by the smart card and the leading edge of the start bit of the previous character sent either by the card or the reader 
 
When TC3 is present, it indicates the type of block-error detection to be used. When TC3 is not present, the default longitudinal redundancy check (LRC) is used. 
 
TD1 indicates if any further interface bytes are to be transmitted, and if so, which protocol will be used. 
 
The TD2 character has the same function as the TD1 character. 
 
TD3 indicates interface bytes similar to that of TD1 & TD2 
Microchip Smart Card Library 1.02.8 - [July 18, 2012]
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.