The current release of smart card library supports PIC18, PIC24F, dsPIC33F, PIC24H & PIC32MX microcontrollers.The smart card library provides the API necessary to communicate with the ISO7816-3/4 compliant Smartcard. The sequence of the API calls is as given below. SClib.h contains all the API's that are required by the main application to communicate with the smart card. The current release of smart card library supports both T=0 and T=1 protocol.
...
//Initialize smart card stack
...
// Wait untill the card is inserted in the slot
while( !SC_CardPresent() )
...
//After detecting the card, turn on the power to the card and process Answer-to-Reset
if( !SC_PowerOnATR() )
...
//Do protocol & parameter selection.Configure the desired baud rate
if( !SC_DoPPS(ppsString) )
...
//Execute Card Commands
//If T=1 card is inserted in the slot, execute T=1 commands
if(SC_T1ProtocolType())
{
if( !SC_TransactT1( &prologueField,apduData,&cardResponse ) )
}
//If T=0 card is inserted in the slot, execute T=0 commands
else if(SC_T0ProtocolType())
{
if( !SC_TransactT0( &cardCommand, &cardResponse, apduData ) )
}
...
...
// Shut Down the Card when there is nothing to do with it
SC_Shutdown();
...
Note :
1)For T=1 protocol "prologueField" buffer should contain the prologue field(NAD,PCB,LENGTH) that needs to be sent to Smart Card.Once the transaction is completed between the card & the micro, response from the card is stored in "cardResponse" buffer."apduData" points to the data buffer of the command as well as data response from the card.
2)For T=0 protocol "cardCommand" buffer should contain the command that needs to be sent to the Smart Card. Once the transaction is completed between the card & the micro, response from the card is stored in "cardResponse" buffer. "apduData" points to the data buffer of command as well as data response from the card.