/* USB Device Check Media Ready Parameters: None Return Value: TRUE - Success, FALSE - Error  */
BOOL USBD_MSC_CheckMedia(void)
/* USB Device Check Media Ready Parameters: None Return Value: TRUE - Success, FALSE - Error  */
BOOL USBD_MSC_CheckMedia(void)
{
    USBD_MSC_MediaReadyEx = USBD_MSC_MediaReady;
    if (!USBD_MSC_MediaReady) {
        if (USBD_MSC_CBW.dDataLength) {
            if ((USBD_MSC_CBW.bmFlags & 0x80) != 0) {
                USBD_MSC_SetStallEP(usbd_msc_ep_bulkin | 0x80);
            } else {
                if (USBD_MSC_CSW.dDataResidue != BulkLen) {
                    USBD_MSC_SetStallEP(usbd_msc_ep_bulkout);
                }
            }
        }
        USBD_MSC_CSW.bStatus = CSW_CMD_FAILED;
        USBD_MSC_SetCSW();
        return (__FALSE);
    }
    return (__TRUE);
}