Przeglądaj źródła

[lpc176x][device] pass set configure control request

hathach 13 lat temu
rodzic
commit
17a27f7398

+ 1 - 0
tinyusb/device/dcd.h

@@ -66,6 +66,7 @@ tusb_error_t dcd_pipe_control_write(uint8_t coreid, void const * buffer, uint16_
 void dcd_pipe_control_write_zero_length(uint8_t coreid);
 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;
 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);
 void dcd_device_set_address(uint8_t coreid, uint8_t dev_addr);
+void dcd_device_set_configuration(uint8_t coreid, uint8_t config_num);
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
  }
  }

+ 6 - 0
tinyusb/device/dcd_lpc175x_6x.c

@@ -242,6 +242,12 @@ void dcd_device_set_address(uint8_t coreid, uint8_t dev_addr)
   sie_command_write(SIE_CMDCODE_SET_ADDRESS, 1, 0x80 | dev_addr); // 7th bit is : device_enable
   sie_command_write(SIE_CMDCODE_SET_ADDRESS, 1, 0x80 | dev_addr); // 7th bit is : device_enable
 }
 }
 
 
+void dcd_device_set_configuration(uint8_t coreid, uint8_t config_num)
+{
+  (void) config_num; // supress compiler's warnings
+  sie_command_write(SIE_CMDCODE_CONFIGURE_DEVICE, 1, 1);
+}
+
 tusb_error_t dcd_pipe_control_write(uint8_t coreid, void const * buffer, uint16_t length)
 tusb_error_t dcd_pipe_control_write(uint8_t coreid, void const * buffer, uint16_t length)
 {
 {
   (void) coreid; // suppress compiler warning
   (void) coreid; // suppress compiler warning

+ 8 - 0
tinyusb/device/usbd.c

@@ -114,6 +114,7 @@ void std_get_descriptor(uint8_t coreid)
     break;
     break;
 
 
     default:
     default:
+//      ASSERT(false, (void) 0); // descriptors that is not supported yet
     return;
     return;
   }
   }
 }
 }
@@ -131,6 +132,13 @@ void usbd_setup_received(uint8_t coreid)
       p_device->address = (uint8_t) p_device->setup_packet.wValue;
       p_device->address = (uint8_t) p_device->setup_packet.wValue;
       dcd_device_set_address(coreid, p_device->address);
       dcd_device_set_address(coreid, p_device->address);
       dcd_pipe_control_write_zero_length(coreid);
       dcd_pipe_control_write_zero_length(coreid);
+      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;
     break;
 
 
     default:
     default: