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 | |
| parent | 4103cc374f8ee94a2d4d308cad5c1e24221b8ae7 (diff) | |
implement hidd_control_request including std & class specific to interface number.
refractor usbd_setup_received
Diffstat (limited to 'tinyusb/device')
| -rw-r--r-- | tinyusb/device/dcd.h | 2 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc175x_6x.c | 2 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 47 |
3 files changed, 32 insertions, 19 deletions
diff --git a/tinyusb/device/dcd.h b/tinyusb/device/dcd.h index 79f2e1fc8..01eae9413 100644 --- a/tinyusb/device/dcd.h +++ b/tinyusb/device/dcd.h @@ -63,6 +63,8 @@ void dcd_controller_connect(uint8_t coreid); void dcd_isr(uint8_t coreid); tusb_error_t dcd_pipe_control_write(uint8_t coreid, void const * buffer, uint16_t length); +tusb_error_t dcd_pipe_control_read(uint8_t coreid, void const * buffer, uint16_t length); + void dcd_pipe_control_write_zero_length(uint8_t coreid); tusb_error_t dcd_endpoint_configure(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc) ATTR_WARN_UNUSED_RESULT; void dcd_device_set_address(uint8_t coreid, uint8_t dev_addr); diff --git a/tinyusb/device/dcd_lpc175x_6x.c b/tinyusb/device/dcd_lpc175x_6x.c index 848e4d6fe..dc19bb54e 100644 --- a/tinyusb/device/dcd_lpc175x_6x.c +++ b/tinyusb/device/dcd_lpc175x_6x.c @@ -304,7 +304,7 @@ tusb_error_t dcd_pipe_control_write(uint8_t coreid, void const * buffer, uint16_ return TUSB_ERROR_NONE; } -tusb_error_t dcd_pipe_control_read(uint8_t coreid) +tusb_error_t dcd_pipe_control_read(uint8_t coreid, void const * buffer, uint16_t length) { return TUSB_ERROR_NONE; } 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); + } } //--------------------------------------------------------------------+ |
