diff options
| author | hathach <[email protected]> | 2013-06-14 18:22:40 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-06-14 18:22:40 +0700 |
| commit | 40b65b265c4a8d2de06b9164829169d629dbd847 (patch) | |
| tree | 7b08fbfce9afbd5f9e99b68cd479b8e867a3b048 /tinyusb/device/usbd.c | |
| parent | 4103cc374f8ee94a2d4d308cad5c1e24221b8ae7 (diff) | |
implement hidd_control_request including std & class specific to interface number.
refractor usbd_setup_received
Diffstat (limited to 'tinyusb/device/usbd.c')
| -rw-r--r-- | tinyusb/device/usbd.c | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index 473148041..252363527 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -97,7 +97,7 @@ void std_get_descriptor(uint8_t coreid) uint16_t const requested_length = min16_of(usbd_devices[coreid].setup_packet.wLength, sizeof(app_tusb_desc_configuration)-1); ASSERT(requested_length <= TUSB_CFG_DEVICE_CONTROL_PACKET_SIZE, (void)0 ); // multiple packets requires a task a-like - dcd_pipe_control_write(coreid, ((uint8_t*)&app_tusb_desc_configuration), + dcd_pipe_control_write(coreid, &app_tusb_desc_configuration, requested_length); } break; @@ -122,29 +122,40 @@ void std_get_descriptor(uint8_t coreid) void usbd_setup_received(uint8_t coreid) { usbd_device_info_t *p_device = &usbd_devices[coreid]; - switch ( p_device->setup_packet.bRequest) + + // check device configured TODO + if ( p_device->setup_packet.bmRequestType.recipient == TUSB_REQUEST_RECIPIENT_INTERFACE) { - case TUSB_REQUEST_GET_DESCRIPTOR: - std_get_descriptor(coreid); - break; + // TODO detect which class + hidd_control_request(coreid, &p_device->setup_packet); + }else + { + switch ( p_device->setup_packet.bRequest ) + { + case TUSB_REQUEST_GET_DESCRIPTOR: + std_get_descriptor(coreid); + break; - case TUSB_REQUEST_SET_ADDRESS: - p_device->address = (uint8_t) p_device->setup_packet.wValue; - dcd_device_set_address(coreid, p_device->address); - dcd_pipe_control_write_zero_length(coreid); - usbd_devices[coreid].state = TUSB_DEVICE_STATE_ADDRESSED; - break; + case TUSB_REQUEST_SET_ADDRESS: + p_device->address = (uint8_t) p_device->setup_packet.wValue; + dcd_device_set_address(coreid, p_device->address); + usbd_devices[coreid].state = TUSB_DEVICE_STATE_ADDRESSED; + break; - case TUSB_REQUEST_SET_CONFIGURATION: - dcd_device_set_configuration(coreid, (uint8_t) p_device->setup_packet.wValue); - dcd_pipe_control_write_zero_length(coreid); - usbd_devices[coreid].state = TUSB_DEVICE_STATE_CONFIGURED; - break; + case TUSB_REQUEST_SET_CONFIGURATION: + dcd_device_set_configuration(coreid, (uint8_t) p_device->setup_packet.wValue); + usbd_devices[coreid].state = TUSB_DEVICE_STATE_CONFIGURED; + break; - default: - return; + default: + return; + } } + if (p_device->setup_packet.bmRequestType.direction == TUSB_DIR_HOST_TO_DEV) + { + dcd_pipe_control_write_zero_length(coreid); + } } //--------------------------------------------------------------------+ |
