AN2294 Freescale Semiconductor / Motorola, AN2294 Datasheet - Page 18

no-image

AN2294

Manufacturer Part Number
AN2294
Description
MC68SZ328 USB Configuration Setup Application Note
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Software Interface
3.3.2 Receiving Data
Customize the program to read USB_EPn_ISR (n=0-4) bit 1. After this bit is set, the end-of-transfer
interrupt enables. When set, it tells the device that the last packet of the transfer has been received. Read
the USB_EPn_FDAT register for the corresponding endpoint.
In special cases, such as the setup packet monitor shown in Code Example 6, USB_EPn_STATCR (SIP)
bit 8 and USB_EPn_ISR DEVREQ bit 1 are set. Clear corresponding EOF and DEVREQ interrupts. It is
important to clear the bit that caused the interrupt (by writing a 1 in the specific register) in the
USB_EPn_ISR register to clear that particular interrupt, otherwise interrupts will not clear automatically.
The UDC acknowledges to the host that the setup data is received, then the process of flushing the FIFOs
for next transfer takes place.
void Setup_Packet_Detect()
{
// Verify the Registers
//
//
//
// Clear DEVREQ and EOF if get it...
// Read the 8 byte Packet
void ACK_Detect()
{
//
// Clear EOF
// Flush the FIFO
18
1. HOST Sends a setup packet to the device.
2. Wait until setup packet received, SIP set
3. Wait until Device Request Received, DEVREQ set
3. Wait until Device Request Received, DEVREQ set
peek_USBD_ISR[0] = _reg_USBD_ISR;
peek_USBD_CTRL[0] = _reg_USBD_CTRL;
peek_EP0_STATCR[0] = _reg_USBD_EP0_STATCR;
peek_EP0_ISR[0] = _reg_USBD_EP0_ISR;
peek_EP0_FSTAT[0] = _reg_USBD_EP0_FSTAT;
_reg_USBD_MASK = (~0x000000FF);// clear mask
_reg_USBD_EP0_MASK = (~0x000001FF);
while (!(_reg_USBD_EP0_STATCR & BIT8));
while (!(_reg_USBD_EP0_ISR & DEVREQ_BIT));
_reg_USBD_EP0_ISR |= 0x00000003;
fifo_peek[0] = _reg_USBD_EP0_FDAT;
fifo_peek[1] = _reg_USBD_EP0_FDAT;
fifo_peek[2] = _reg_USBD_EP0_FDAT;
fifo_peek[3] = _reg_USBD_EP0_FDAT;
while (!(_reg_USBD_EP0_ISR & EOF_BIT));
_reg_USBD_EP0_ISR |= 0x00000001;
_reg_USBD_EP0_STATCR |= 0x00000002
.
.
.
Freescale Semiconductor, Inc.
For More Information On This Product,
Code Example 6. Receiving Packets
MC68SZ328 Application Note
Go to: www.freescale.com
MOTOROLA

Related parts for AN2294