Change USB strings handling code
This commit add an extra field to the _usbd_device, that allows to keep track of the number of USB strings which allows simplify boundaries checking code in usb_standard_get_descriptor. This commit also changes the index base for strings in usb_standard_get_descriptor which allows to get rid of necessity to have a dummy one-character string in a strings array.
This commit is contained in:
@@ -45,12 +45,14 @@ u8 usbd_control_buffer[128] __attribute__((weak));
|
||||
*/
|
||||
int usbd_init(const usbd_driver *driver,
|
||||
const struct usb_device_descriptor *dev,
|
||||
const struct usb_config_descriptor *conf, const char **strings)
|
||||
const struct usb_config_descriptor *conf,
|
||||
const char **strings, int num_strings)
|
||||
{
|
||||
_usbd_device.driver = driver;
|
||||
_usbd_device.desc = dev;
|
||||
_usbd_device.config = conf;
|
||||
_usbd_device.strings = strings;
|
||||
_usbd_device.num_strings = num_strings;
|
||||
_usbd_device.ctrl_buf = usbd_control_buffer;
|
||||
_usbd_device.ctrl_buf_len = sizeof(usbd_control_buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user