diff options
author | barthess <barthess@yandex.ru> | 2016-10-28 14:25:08 +0300 |
---|---|---|
committer | barthess <barthess@yandex.ru> | 2016-10-28 14:25:08 +0300 |
commit | 92c371470649d58e1e76e6c255fe3c010fc8ef54 (patch) | |
tree | 3c4181aebf78313e43e5dbb8c2c5a8eacad0cbaa /os/hal | |
parent | b7cefd6fac81a164017c4f81b8b53584e104db0b (diff) | |
download | ChibiOS-Contrib-92c371470649d58e1e76e6c255fe3c010fc8ef54.tar.gz ChibiOS-Contrib-92c371470649d58e1e76e6c255fe3c010fc8ef54.tar.bz2 ChibiOS-Contrib-92c371470649d58e1e76e6c255fe3c010fc8ef54.zip |
USB_MSD. Added READ_FORMAT_CAPACITIES handler
Diffstat (limited to 'os/hal')
-rw-r--r-- | os/hal/src/hal_usb_msd.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/os/hal/src/hal_usb_msd.c b/os/hal/src/hal_usb_msd.c index 9c49192..068d698 100644 --- a/os/hal/src/hal_usb_msd.c +++ b/os/hal/src/hal_usb_msd.c @@ -262,22 +262,47 @@ bool msd_request_hook(USBDriver *usbp) { /* check that it is a HOST2DEV request */ if (((usbp->setup[0] & USB_RTYPE_DIR_MASK) != USB_RTYPE_DIR_HOST2DEV) || (MSD_SETUP_LENGTH(usbp->setup) != 0) || - (MSD_SETUP_VALUE(usbp->setup) != 0)) + (MSD_SETUP_VALUE(usbp->setup) != 0)) { return false; + } - /* reset all endpoints */ - /* TODO!*/ + /* + As required by the BOT specification, the Bulk-only mass storage reset request (classspecific + request) is implemented. This request is used to reset the mass storage device and + its associated interface. This class-specific request should prepare the device for the next + CBW from the host. + To generate the BOT Mass Storage Reset, the host must send a device request on the + default pipe of: + • bmRequestType: Class, interface, host to device + • bRequest field set to 255 (FFh) + • wValue field set to ‘0’ + • wIndex field set to the interface number + • wLength field set to ‘0’ + */ + chSysLockFromISR(); + + /* release and abandon current transmission */ + usbStallReceiveI(usbp, 1); + usbStallTransmitI(usbp, 1); /* The device shall NAK the status stage of the device request until * the Bulk-Only Mass Storage Reset is complete. - */ + * NAK EP1 in and out */ + usbp->otg->ie[1].DIEPCTL = DIEPCTL_SNAK; + usbp->otg->oe[1].DOEPCTL = DOEPCTL_SNAK; + + chSysUnlockFromISR(); + + /* response to this request using EP0 */ + usbSetupTransfer(usbp, 0, 0, NULL); return true; case MSD_GET_MAX_LUN: /* check that it is a DEV2HOST request */ if (((usbp->setup[0] & USB_RTYPE_DIR_MASK) != USB_RTYPE_DIR_DEV2HOST) || (MSD_SETUP_LENGTH(usbp->setup) != 1) || - (MSD_SETUP_VALUE(usbp->setup) != 0)) + (MSD_SETUP_VALUE(usbp->setup) != 0)) { return false; + } /* stall to indicate that we don't support LUN */ osalSysLockFromISR(); |