SLAU533D September 2013 – April 2017
The first item in the main loop is a call to USBMSC_poll().
__disable_interrupt();
if ((USBMSC_poll() == kUSBMSC_okToSleep) && !charLeftToSend &&
!bButton1Pressed && !bButton2Pressed)
{
__bis_SR_register(LPM0_bits + GIE);
}
__enable_interrupt();
Notice all of the code surrounding USBMSC_poll(); this is discussed in Section 3.5.5.
Every USB application with an MSC interface must call this function regularly to check for any SCSI commands received from the host. The USB MSC interface is essentially a carrier for the same SCSI commands used with many non-USB storage devices that are commonly used with computers. In other words, the interface is essentially "SCSI-over-USB".
USBMSC_poll() automatically handles all SCSI commands except READ and WRITE. These two require media access. The developer might choose among a wide variety of media types, and there are many different file system "middleware" offerings on the market. To preserve these options for the developer, the MSC API lets the application access the media. mscProcessBuffer() is the function that serves this function for the software demo; it receives a block buffer from the API and exchanges data between this buffer and the media (see Section 3.5.7 for more information).
Most MSC applications need this exact same block within the main loop, except that the checking of the charLeftToSend and button-pressed flags are specific to this demo application.