Information Technology Reference
In-Depth Information
function places the CSW in the IN endpoint's buffer and transfers owner-
ship of the buffer descriptor to the SIE.
void SendCSW(void)
{
// Wait until the CPU has ownership of the endpoint's buffer descriptor.
while (mMSDTxIsBusy())
{
// Service USB interrupts. See Microchip's Framework firmware for details.
USBDriverService();
}
// Set the IN endpoint's address registers to the CSW's address.
MSD_BD_IN.ADR = (byte*)&msd_csw;
// Set the IN endpoint's count to the CSW's size.
MSD_BD_IN.Cnt = MSD_CSW_SIZE;
// To enable sending the CSW, give ownership of the endpoint descriptor to the SIE.
mUSBBufferReady(MSD_BD_IN);
// Service USB interrupts.
USBDriverService();
// Prepare to receive another CBW.
// Set the OUT endpoint's count to the size of a CBW.
MSD_BD_OUT.Cnt = sizeof(msd_cbw);
// Set the OUT endpoint's buffer descriptor's address to the location that will store
// the received CBW.
MSD_BD_OUT.ADR = (byte*)&msd_cbw;
// The next bulk OUT data from the host should be a CBW.
MSD_State = MSD_WAIT;
}
Search WWH ::




Custom Search