Пример #1
0
static bool_t usbRequestsHook(USBDriver *usbp)
{
  // Composite Interface Number
#if HAL_USE_MSD
  if (usbp->setup[4] == 4)
    return msdRequestsHook(usbp);
#endif
  return sduRequestsHook(usbp);
}
Пример #2
0
/*
 * Handling messages not implemented in the default handler nor in the
 * SerialUSB handler.
 */
static bool requests_hook(USBDriver *usbp) {

  if (((usbp->setup[0] & USB_RTYPE_RECIPIENT_MASK) == USB_RTYPE_RECIPIENT_INTERFACE) &&
      (usbp->setup[1] == USB_REQ_SET_INTERFACE)) {
    usbSetupTransfer(usbp, NULL, 0, NULL);
    return true;
  }
  return sduRequestsHook(usbp);
}
Пример #3
0
bool_t msdCdcRequestsHook(USBDriver *usbp) {
    bool_t r;
    r = msdRequestsHook(usbp);
    if( r ) {
        return(r);
    }

    r = sduRequestsHook(usbp);

    return(r);
}
Пример #4
0
bool usb_setup_hook(USBDriver *usbp) {
  /* Override GET_DESCRIPTOR requests to return data from program memory */
  if ((usbp->setup[0] & (USB_RTYPE_RECIPIENT_MASK | USB_RTYPE_TYPE_MASK)) ==
      (USB_RTYPE_RECIPIENT_DEVICE | USB_RTYPE_TYPE_STD) &&
      usbp->setup[1] == USB_REQ_GET_DESCRIPTOR) {
    const uint8_t dtype = usbp->setup[3];
    const uint8_t dindex = usbp->setup[2];
    const AVR_USB_TX_BUF_ADDRESS_SPACE uint8_t *ddata = NULL;
    size_t dsize = 0;
    switch (dtype) {
      case USB_DESCRIPTOR_DEVICE:
        dsize = sizeof(vcom_device_descriptor_data);
        ddata = vcom_device_descriptor_data;
        break;
      case USB_DESCRIPTOR_CONFIGURATION:
        dsize = sizeof(vcom_configuration_descriptor_data);
        ddata = vcom_configuration_descriptor_data;
        break;
      case USB_DESCRIPTOR_STRING:
        if (dindex == 0) {
          dsize = sizeof(vcom_string0);
          ddata = vcom_string0;
        } else if (dindex == 1) {
          dsize = sizeof(vcom_string1);
          ddata = vcom_string1;
        } else if (dindex == 2) {
          dsize = sizeof(vcom_string2);
          ddata = vcom_string2;
        } else if (dindex == 3) {
          dsize = sizeof(vcom_string3);
          ddata = vcom_string3;
        }
        break;
    }
    if (ddata == NULL) {
      return false;
    }

    usbSetupTransfer(usbp, ddata, dsize, NULL);
    return true;
  }
  return sduRequestsHook(usbp);
}