1.According to the USB Specification, The Host has to poll the Bus(means sending IN tokens) for interrupt IN end points.How this task is achieved in the HOST Implementation with out effecting the other devices running in the system?
Refer to usbhhid.c, which drives the interrupt IN endpoint.
C:\ti\AM335X_StarterWare_02_00_01_01\usblib\host\usbhhid.c
1. HIDDriverOpen() assigns callback routine (HIDIntINCallback()) to the interrupt IN pipe using USBHCDPipeAllocSize().
2. The stack calls HIDIntINCallback() with USB_EVENT_SCHEDULER
- This routine starts "polling" IN at the target endpoint using USBHCDPipeSchedule()
3. When the device returns a packet at the IN endpoint, HIDIntINCallback() is called by the stack with USB_EVENT_RX_AVAILABLE.
- This routine passes USB_EVENT_RX_AVAILABLE event to the callback of the upper layer.
- The upper layer callback reads out the packet using USBHHIDGetReport(), in which the packet is actually read out by USBHCDPipeReadNonBlocking()
How this state of the End point is maintained in the HOST PC for polling?
For a "polling" bulk IN EP, you may apply the same code pattern as above "polling" interrupt EP
3.Can anyone please elaborate the ZLP?
For bulk IN/OUT transfer of your case,
On the bus, long Transfer is split into Transactions of wMaxPacketSize of the endpoint. At the end of Transfer, the last short Transactions, less than wMaxPacketSize, is sent by the sender. And then, the receiver knows the end of Transfer.
When the Transfer size is just a multiple of wMaxPacketSize, ZLP (Zero-Length Packet/ transaction) is sent to indicate the termination of a transfer, explicitly.
(Unfortunately, PC host often doesn’t follow this principle)
In this stack, to send ZLP, your host code calls USBEndpointDataSend(), without putting any data to the FIFO.
Tsuneo