Software

73S12xxF Software User Guide UG_12xxF_016
44 Rev. 1.50
requests and will return the configuration, endpoint, interface and string descriptors including the CCID
class descriptor, depending on the maximum length requested.
There are two possible configurations for the USB: self-powered and bus-powered. Each configuration
requires some power consumption management to effectively reduce the power according to the USB 2.0
Specification. As a result, the following must be implemented for each configuration:
For Self-Power: Cable attach/detach must be detectable to turn D+ on/off respectively. The CCID
USB sample code included as part of the release has implemented the use of USR7 with external
interrupt 0 (all internal to IC) so that a cable attach/detach event will be detected and serviced via the
INT0 interrupt service routine.
For Bus-Power: D+ must be kept high at all times via the PowerON(ENABLE_USB) API. When the
host puts the device in Suspend mode, the CCID USB sample code puts the device’s CPU to sleep
to conserve power. After Suspend mode, the host wakes up the device via a Reset or a Resume
signal.
This signal (D+ being pulled low for a period of time as described in the USB 2.0 Specification) will cause
interrupt 0 to occur which will wake up the device’s CPU. The interrupt is required because the USB clock is
turned off during sleep mode, so the D+ (Reset/Resume) signal would not wake up the CPU. Upon waking
up, the INT0 interrupt service routine will turn the USB clock back on to resume its function.
In order to configure the self-powered or bus-powered mode, modify the ATTRIBUTES variable, defined
in API_12.h, to its respective value before building the application. See the CCID USB source code
project for an example.
The USB initialization descriptors and relevant structures are described below. All the descriptors are
modifiable, but some values should not change. These are flagged as “Always”.
//
// USB API.
//
/*** the total size of the configuration descriptor ***/
#define CONFIG_DESC_TOTAL_SIZE 93
/*** define the number of core endpoints (including EP0) ***/
#define NUMBER_OF_EPS 4
/*** define the total possible number of interfaces for all configurations ***/
#define NUMBER_OF_INTERFACES 1
/*******************************************************
Descriptor types
*******************************************************/
#define DEVICE_DESCRIPTOR 1
#define CONFIGURATION_DESCRIPTOR 2
#define STRING_DESCRIPTOR 3
#define INTERFACE_DESCRIPTOR 4
#define EP_DESCRIPTOR 5
#define CCID_DESCRIPTOR 0x21
struct USB_Device_t
{
unsigned char Length; // Always 18.
unsigned char DescriptorType; // Always DEVICE_DESCRIPTOR = 1.
unsigned int USB_spec_rev; // 0x0002 (rev 2.0).
unsigned char DeviceClass; // Always 0.
unsigned char DeviceSubclass; // Always 0.
unsigned char DeviceProtocol; // Always 0.
unsigned char MaxPacketSize0; // Always 16.
unsigned int idVendor; //Always 0xc309