Interconnectivity
Page 9 of 22
Firmware Programming Guide for PDIUSBD12
Philips Semiconductors - Asia Product Innovation Centre
Visit
http://www.flexiusb.com
The ISR communicates with the foreground Main Loop through event flags "EPPFLAGS" and data buffers
"CONTROL_XFER".
typedef union _epp_flags
{
struct _flags
{
unsigned char timer : 1;
unsigned char bus_reset : 1;
unsigned char suspend : 1;
unsigned char setup_packet : 1;
unsigned char remote_wakeup : 1;
unsigned char in_isr
: 1;
unsigned char control_state
: 2;
unsigned char configuration
: 1;
unsigned char verbose
: 1;
unsigned char ep1_rxdone
: 1;
unsigned char setup_dma
: 1;
unsigned char dma_state : 2;
} bits;
unsigned short value;
} EPPFLAGS;
typedef struct _device_request
{
unsigned char bmRequestType;
unsigned char bRequest;
unsigned short wValue;
unsigned short wIndex;
unsigned short wLength;
} DEVICE_REQUEST;
typedef struct _control_xfer
{
DEVICE_REQUEST DeviceRequest;
unsigned short wLength;
unsigned short wCount;
unsigned char * pData;
unsigned char dataBuffer[MAX_CONTROLDATA_SIZE];
} CONTROL_XFER;
The task splitting between Main Loop and ISR is that ISR collects data from D12 and Main Loop will process
the data. The ISR will only inform Main Loop that data is ready for processing when it has collected enough
data. For example, in the case of setup packet with OUT data phase, the ISR will store both setup packet and
OUT data to buffer "CONTROL_XFER" before it signals "setup_packet" flag to Main Loop. This will reduce
unnecessary Main Loop servicing time and also simply Main Loop programming.
5.1 Bus Reset and Suspend Change
Bus reset and suspend does not require special processing within ISR. ISR either sets the bus_reset flag or
suspends the bit in EPPFLAGS and exit.