Information Technology Reference
In-Depth Information
// Set the buffer descriptor's count to the passed data size.
MSD_BD_IN.Cnt = dataSize;
// Give ownership of the buffer descriptor to the SIE.
mUSBBufferReady(MSD_BD_IN);
// Service USB interrupts.
USBDriverService();
}
Preparing to Send Data to the USB Host
The MSDDataIn function manages sending data in the data-transport
phase of a command. The function sets fields in the CSW to indicate how
many bytes in the transfer have been received and how many additional
bytes the device expects to receive.
byte *ptrNextData; // must be set to the location of the first byte to send
void MSDDataIn(void)
{
byte
i;
dword
size;
// Does bCSWStatus = no error AND is the total data to be sent >= the endpoint's size?
if ((msd_csw.bCSWStatus == 0x00) &&
(msd_csw.dCSWDataResidue >= MSD_IN_EP_SIZE))
{
// Send MSD_IN_EP_SIZE bytes of data on the bulk IN endpoint.
// The data begins at ptrNextData.
SendData (ptrNextData, MSD_IN_EP_SIZE);
// Subtract the sent bytes from dCBWDataTransferLength in the CBW.
gblCBW.dCBWDataTransferLength -= MSD_IN_EP_SIZE;
// Subtract the sent bytes from dCSWDataResidue in the CSW.
msd_csw.dCSWDataResidue -= MSD_IN_EP_SIZE;
Search WWH ::




Custom Search