4242//--------------------------------------------------------------------+
4343// Device Descriptors
4444//--------------------------------------------------------------------+
45- tusb_desc_device_t const desc_device =
46- {
45+ tusb_desc_device_t const desc_device = {
4746 .bLength = sizeof (tusb_desc_device_t ),
4847 .bDescriptorType = TUSB_DESC_DEVICE ,
4948 .bcdUSB = USB_BCD ,
@@ -68,16 +67,14 @@ tusb_desc_device_t const desc_device =
6867
6968// Invoked when received GET DEVICE DESCRIPTOR
7069// Application return pointer to descriptor
71- uint8_t const * tud_descriptor_device_cb (void )
72- {
70+ uint8_t const * tud_descriptor_device_cb (void ) {
7371 return (uint8_t const * ) & desc_device ;
7472}
7573
7674//--------------------------------------------------------------------+
7775// Configuration Descriptor
7876//--------------------------------------------------------------------+
79- enum
80- {
77+ enum {
8178 ITF_NUM_CDC_0 = 0 ,
8279 ITF_NUM_CDC_0_DATA ,
8380 ITF_NUM_CDC_1 ,
@@ -130,36 +127,32 @@ enum
130127 #define EPNUM_CDC_1_IN 0x84
131128#endif
132129
133- uint8_t const desc_fs_configuration [] =
134- {
130+ uint8_t const desc_fs_configuration [] = {
135131 // Config number, interface count, string index, total length, attribute, power in mA
136132 TUD_CONFIG_DESCRIPTOR (1 , ITF_NUM_TOTAL , 0 , CONFIG_TOTAL_LEN , 0x00 , 100 ),
137133
138134 // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
139- TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_0 , 4 , EPNUM_CDC_0_NOTIF , 8 , EPNUM_CDC_0_OUT , EPNUM_CDC_0_IN , 64 ),
135+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_0 , 4 , EPNUM_CDC_0_NOTIF , 16 , EPNUM_CDC_0_OUT , EPNUM_CDC_0_IN , 64 ),
140136
141137 // 2nd CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
142- TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_1 , 4 , EPNUM_CDC_1_NOTIF , 8 , EPNUM_CDC_1_OUT , EPNUM_CDC_1_IN , 64 ),
138+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_1 , 4 , EPNUM_CDC_1_NOTIF , 16 , EPNUM_CDC_1_OUT , EPNUM_CDC_1_IN , 64 ),
143139};
144140
145141#if TUD_OPT_HIGH_SPEED
146142// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
147-
148- uint8_t const desc_hs_configuration [] =
149- {
143+ uint8_t const desc_hs_configuration [] = {
150144 // Config number, interface count, string index, total length, attribute, power in mA
151145 TUD_CONFIG_DESCRIPTOR (1 , ITF_NUM_TOTAL , 0 , CONFIG_TOTAL_LEN , 0x00 , 100 ),
152146
153147 // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
154- TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_0 , 4 , EPNUM_CDC_0_NOTIF , 8 , EPNUM_CDC_0_OUT , EPNUM_CDC_0_IN , 512 ),
148+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_0 , 4 , EPNUM_CDC_0_NOTIF , 16 , EPNUM_CDC_0_OUT , EPNUM_CDC_0_IN , 512 ),
155149
156150 // 2nd CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
157- TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_1 , 4 , EPNUM_CDC_1_NOTIF , 8 , EPNUM_CDC_1_OUT , EPNUM_CDC_1_IN , 512 ),
151+ TUD_CDC_DESCRIPTOR (ITF_NUM_CDC_1 , 4 , EPNUM_CDC_1_NOTIF , 16 , EPNUM_CDC_1_OUT , EPNUM_CDC_1_IN , 512 ),
158152};
159153
160154// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
161- tusb_desc_device_qualifier_t const desc_device_qualifier =
162- {
155+ tusb_desc_device_qualifier_t const desc_device_qualifier = {
163156 .bLength = sizeof (tusb_desc_device_t ),
164157 .bDescriptorType = TUSB_DESC_DEVICE ,
165158 .bcdUSB = USB_BCD ,
@@ -177,34 +170,31 @@ tusb_desc_device_qualifier_t const desc_device_qualifier =
177170// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
178171// device_qualifier descriptor describes information about a high-speed capable device that would
179172// change if the device were operating at the other speed. If not highspeed capable stall this request.
180- uint8_t const * tud_descriptor_device_qualifier_cb (void )
181- {
182- return (uint8_t const * ) & desc_device_qualifier ;
173+ uint8_t const * tud_descriptor_device_qualifier_cb (void ) {
174+ return (uint8_t const * ) & desc_device_qualifier ;
183175}
184176
185177// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
186178// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
187179// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
188- uint8_t const * tud_descriptor_other_speed_configuration_cb (uint8_t index )
189- {
190- (void ) index ; // for multiple configurations
180+ uint8_t const * tud_descriptor_other_speed_configuration_cb (uint8_t index ) {
181+ (void ) index ;// for multiple configurations
191182
192183 // if link speed is high return fullspeed config, and vice versa
193- return (tud_speed_get () == TUSB_SPEED_HIGH ) ? desc_fs_configuration : desc_hs_configuration ;
184+ return (tud_speed_get () == TUSB_SPEED_HIGH ) ? desc_fs_configuration : desc_hs_configuration ;
194185}
195186
196- #endif // highspeed
187+ #endif // highspeed
197188
198189// Invoked when received GET CONFIGURATION DESCRIPTOR
199190// Application return pointer to descriptor
200191// Descriptor contents must exist long enough for transfer to complete
201- uint8_t const * tud_descriptor_configuration_cb (uint8_t index )
202- {
192+ uint8_t const * tud_descriptor_configuration_cb (uint8_t index ) {
203193 (void ) index ; // for multiple configurations
204194
205195#if TUD_OPT_HIGH_SPEED
206196 // Although we are highspeed, host may be fullspeed.
207- return (tud_speed_get () == TUSB_SPEED_HIGH ) ? desc_hs_configuration : desc_fs_configuration ;
197+ return (tud_speed_get () == TUSB_SPEED_HIGH ) ? desc_hs_configuration : desc_fs_configuration ;
208198#else
209199 return desc_fs_configuration ;
210200#endif
@@ -223,8 +213,7 @@ enum {
223213};
224214
225215// array of pointer to string descriptors
226- char const * string_desc_arr [] =
227- {
216+ char const * string_desc_arr [] = {
228217 (const char []) { 0x09 , 0x04 }, // 0: is supported language is English (0x0409)
229218 "TinyUSB" , // 1: Manufacturer
230219 "TinyUSB Device" , // 2: Product
@@ -254,14 +243,14 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
254243 // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
255244 // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
256245
257- if ( !(index < sizeof (string_desc_arr ) / sizeof (string_desc_arr [0 ])) ) return NULL ;
246+ if ( !(index < sizeof (string_desc_arr ) / sizeof (string_desc_arr [0 ])) ) { return NULL ; }
258247
259248 const char * str = string_desc_arr [index ];
260249
261250 // Cap at max char
262251 chr_count = strlen (str );
263252 size_t const max_count = sizeof (_desc_str ) / sizeof (_desc_str [0 ]) - 1 ; // -1 for string type
264- if ( chr_count > max_count ) chr_count = max_count ;
253+ if ( chr_count > max_count ) { chr_count = max_count ; }
265254
266255 // Convert ASCII string into UTF-16
267256 for ( size_t i = 0 ; i < chr_count ; i ++ ) {
@@ -272,6 +261,5 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
272261
273262 // first byte is length (including header), second byte is string type
274263 _desc_str [0 ] = (uint16_t ) ((TUSB_DESC_STRING << 8 ) | (2 * chr_count + 2 ));
275-
276264 return _desc_str ;
277265}
0 commit comments