Skip to content

Commit 1662a21

Browse files
committed
USB string descriptors: no tailing zero (rusefi#9684)
* USB CFG: no tailing zero in string descriptors * USB CFG: just code style
1 parent 287793b commit 1662a21

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

  • firmware/hw_layer/ports/stm32/serial_over_usb

firmware/hw_layer/ports/stm32/serial_over_usb/usbcfg.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static const uint8_t vcom_string1[] = {
236236
static const uint8_t vcom_string2[] = {
237237
USB_DESC_BYTE(USB_DESCRIPTOR_B_LENGTH), /* bLength. */
238238
USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */
239-
USB_DESCRIPTOR_STRING_CONTENT, 0
239+
USB_DESCRIPTOR_STRING_CONTENT
240240
};
241241

242242
/*
@@ -253,38 +253,35 @@ static const uint8_t vcom_string3[] = {
253253
BOARD_SERIAL[ 8], 0, BOARD_SERIAL[ 9], 0, BOARD_SERIAL[10], 0, BOARD_SERIAL[11], 0,
254254
BOARD_SERIAL[12], 0, BOARD_SERIAL[13], 0, BOARD_SERIAL[14], 0, BOARD_SERIAL[15], 0,
255255
BOARD_SERIAL[16], 0, BOARD_SERIAL[17], 0, BOARD_SERIAL[18], 0, BOARD_SERIAL[19], 0,
256-
BOARD_SERIAL[20], 0, BOARD_SERIAL[21], 0, BOARD_SERIAL[22], 0, BOARD_SERIAL[23], 0,
257-
0
256+
BOARD_SERIAL[20], 0, BOARD_SERIAL[21], 0, BOARD_SERIAL[22], 0, BOARD_SERIAL[23], 0
258257
};
259258
#else
260259
static uint8_t vcom_string3[] = {
261260
USB_DESC_BYTE(50), /* bLength. */
262261
USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */
263262
'0', 0, '1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0,
264263
'8', 0, '9', 0, 'A', 0, 'B', 0, 'C', 0, 'D', 0, 'E', 0, 'F', 0,
265-
'0', 0, '1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0,
266-
0
264+
'0', 0, '1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0
267265
};
268266
#endif
269267

270268
/* "RusEFI MSD" */
271-
static uint8_t msd_string4[] = {
269+
static const uint8_t msd_string4[] = {
272270
USB_DESC_BYTE(10 * 2 + 2), /* bLength. */
273271
USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */
274272
'r', 0, 'u', 0, 's', 0, 'E', 0, 'F', 0, 'I', 0, ' ', 0, 'M', 0,
275-
'S', 0, 'D', 0,
276-
0
273+
'S', 0, 'D', 0
277274
};
278275

279276
/*
280277
* Strings wrappers array.
281278
*/
282279
static const USBDescriptor vcom_strings[] = {
283-
{sizeof vcom_string0, vcom_string0},
284-
{sizeof vcom_string1, vcom_string1},
285-
{sizeof vcom_string2, vcom_string2},
286-
{sizeof vcom_string3, vcom_string3},
287-
{sizeof msd_string4, msd_string4}
280+
{ sizeof(vcom_string0), vcom_string0 },
281+
{ sizeof(vcom_string1), vcom_string1 },
282+
{ sizeof(vcom_string2), vcom_string2 },
283+
{ sizeof(vcom_string3), vcom_string3 },
284+
{ sizeof(msd_string4), msd_string4 }
288285
};
289286

290287
#ifndef BOARD_SERIAL
@@ -487,10 +484,10 @@ static bool hybridRequestHook(USBDriver *usbp) {
487484
* USB driver configuration.
488485
*/
489486
const USBConfig usbcfg = {
490-
usb_event,
491-
get_descriptor,
492-
hybridRequestHook,
493-
sof_handler
487+
.event_cb = usb_event,
488+
.get_descriptor_cb = get_descriptor,
489+
.requests_hook_cb = hybridRequestHook,
490+
.sof_cb = sof_handler
494491
};
495492

496493
/*

0 commit comments

Comments
 (0)