AN1527 STMICROELECTRONICS [STMicroelectronics], AN1527 Datasheet

no-image

AN1527

Manufacturer Part Number
AN1527
Description
DEVELOPING A USB SMARTCARD READER WITH ST7SCR
Manufacturer
STMICROELECTRONICS [STMicroelectronics]
Datasheet
INTRODUCTION
This document describes a firmware implementation developed by STMicroelectronics for a
USB Smart Card Reader. This firmware is for the ST7SCR microcontroller and can be used
with the associated Smart Card Reader board available from STMicroelectronics.
It is divided into 4 parts:
– Universal Serial Bus (USB) management: This is the USB library which manages the USB
– Chip Card Interface Device (CCID) implementation: This contains high level functions for us-
– Interface Device (IFD) implementation: This contains high level functions for ISO 7816 spec-
– 7816 UART Smartcard Interface (CRD) management: This contains low level functions for
The main loop polls USB transactions (functions in Ccid_usb.c) using a state machine
process:
– USB_Polling() function from library for USB low level and endpoint 0 management.
– Receive USB Bulk-out message (CCID part).
– Execute the function corresponding to the Bulk-out message (IFD part).
– Send USB interrupt in message (CCID part) if necessary.
– Send USB Bulk-in response (CCID part).
The Bulk-out/in messages are managed by a state machine. When the Bulk-out message re-
ception is completed, the message function is executed and returns only after the completion
of the action to be done in the IFD part. As this may take several 10 ms (e.g. ATR reading), the
response is sent to the host by Bulk-in message. The Bulk-in/out messages are received in
several transactions with a single transaction at every main loop if the USB endpoint is avail-
able.
If there are any interrupt messages, they are sent just before the Bulk-in message is sent.
Specific CCID class requests are managed by the setup management function in the USB li-
brary (USER_USB_setup() function).
AN1527/0702
hardware.
ing the USB in compliance with CCID specifications (messages for Bulk-in, Bulk-out, inter-
rupt and class requests)
ification implementation and the smartcard-specific command interpreter.
the hardware management of the 7816 UART Smartcard Interface (CRD).
SMARTCARD READER WITH ST7SCR
APPLICATION NOTE
by Microcontroller Division Applications
DEVELOPING A USB
AN1527
1/14
1

Related parts for AN1527

AN1527 Summary of contents

Page 1

... If there are any interrupt messages, they are sent just before the Bulk-in message is sent. Specific CCID class requests are managed by the setup management function in the USB li- brary (USER_USB_setup() function). AN1527/0702 APPLICATION NOTE DEVELOPING A USB SMARTCARD READER WITH ST7SCR by Microcontroller Division Applications AN1527 1/14 1 ...

Page 2

DEVELOPING A USB SMARTCARD READER WITH ST7SCR 1 CCID IMPLEMENTATION 1.1 GENERALITIES The Chip Card Interface Device (CCID) firmware implementation conforms to the “Universal Serial Bus Device Class Specification for USB Chip/Smart Card Interface Devices” revision 1.0. It contains two ...

Page 3

To finish the main loop, the CCID_BulkInMessage() function sends the Bulk-in message as an answer to the previous Bulk-out message. The message is sent in a process that requires sev- eral Bulk-in transactions (same concept as for the Bulk-out process). ...

Page 4

DEVELOPING A USB SMARTCARD READER WITH ST7SCR void CcidClassRequestAbort(void) This function is called from the USER_USB_Setup() function to process an Abort request. unsigned char PC_to_RDR_IccPowerOn(void) This function verifies the PC_TO_RDR_ICCPOWERON command format and calls the IFD_IccPowerOn() function (from Interface Device ...

Page 5

PC_to_RDR_Escape(void) This function verifies the PC_T O_RD R_ESCAPE com mand format and calls the IFD_Escape() function (from the Interface Device level). This PC_to_RDR function returns an error code (from IFD_Escape(), for example). unsigned char PC_to_RDR_IccClock(void) This function verifies ...

Page 6

DEVELOPING A USB SMARTCARD READER WITH ST7SCR 2 IFD IMPLEMENTATION The Interface Device (IFD) implementation firmware contains one file: – Ifd_protocol.c: This is the ISO 7816 implementation for Protocol types T=0 and T=1 and for character, TPDU and short APDU ...

Page 7

ISO 7816 UART LIBRARY (CRD) 3.1 GENERAL INTRODUCTION The aim of this library is to provide the user with a set of functions for using the Smartcard In- terface (ISO7816-3 UART Interface) to directly access the hardware and to ...

Page 8

DEVELOPING A USB SMARTCARD READER WITH ST7SCR unsigned char CRD_VccOn(unsigned char Voltage) This function switches ON the V three possible voltage values: – CRD_Voltage18V (for 1.8 volts) – CRD_Voltage3V (for 3.0 volts) – CRD_Voltage5V (for 5.0 volts) This function returns ...

Page 9

CRD_GetConvention(void) This function returns the convention currently in use in the CRD. There are two conventions: – CRD_DirectConv – CRD_InverseConv unsigned char CRD_GetClockStatus(void) This function returns the status of the CRD clock signal. There are three possible states ...

Page 10

DEVELOPING A USB SMARTCARD READER WITH ST7SCR void CRD_StartWaitingTime(void) This function starts the Waiting Timer. The bWaitingTimeFlag software flag is set by an inter- rupt when the count is finished. For more information, please refer to the crd.h file. This ...

Page 11

CRD_EndTransmit(void) This function finishes the transmission by disabling the interrupt. This function returns the re- maining number of bytes to be transmitted. 3.3 INTERRUPT FUNCTIONS The following two functions are executed when an interrupt occurs: void INT_UART(void) This ...

Page 12

DEVELOPING A USB SMARTCARD READER WITH ST7SCR – Slot_No_Error – SlotError_HW_Error – SlotError_ICC_Mute Note: At the end of this function, the CRD is in Manual mode. void ICC_ResetAsync(void) This function executes a warm reset sequence in compliance with ISO 7816 ...

Page 13

CommandSize is the size of the buffer in bytes. – ProtocolType is 0 (for T= (for T=1). This variable is used to set a flag tested in the interrupt process at transmission and reception levels. This function ...

Page 14

DEVELOPING A USB SMARTCARD READER WITH ST7SCR “THE PRESENT NOTE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE ...

Related keywords