Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.

Commit 086074e

Browse files
committed
backported changes from official ataradov vcp repository
1 parent 0bb7b49 commit 086074e

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

example-apps/vcp/uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void UART_SERCOM_IRQ_HANDLER(void)
218218
}
219219
else
220220
{
221-
UART_SERCOM->USART.DATA.reg = uart_tx_fifo.data[uart_tx_fifo.rd];;
221+
UART_SERCOM->USART.DATA.reg = uart_tx_fifo.data[uart_tx_fifo.rd];
222222
uart_tx_fifo.rd = (uart_tx_fifo.rd + 1) % UART_BUF_SIZE;
223223
}
224224
}

example-apps/vcp/usb_descriptors.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,3 @@ const char *const usb_strings[] =
171171
[USB_STR_PRODUCT] = "Virtual COM-Port",
172172
[USB_STR_SERIAL_NUMBER] = usb_serial_number,
173173
};
174-
175-
alignas(4) uint8_t usb_string_descriptor_buffer[64];
176-

example-apps/vcp/usb_descriptors.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ extern const usb_configuration_hierarchy_t usb_configuration_hierarchy;
7272
extern const usb_string_descriptor_zero_t usb_string_descriptor_zero;
7373
extern const char *const usb_strings[];
7474
extern char usb_serial_number[16];
75-
extern uint8_t usb_string_descriptor_buffer[64];
7675

7776
#endif // _USB_DESCRIPTORS_H_
7877

example-apps/vcp/usb_std.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
/*- Includes ----------------------------------------------------------------*/
3030
#include <stdbool.h>
31+
#include <stdalign.h>
3132
#include <string.h>
3233
#include "utils.h"
3334
#include "usb.h"
@@ -100,20 +101,22 @@ bool usb_handle_standard_request(usb_request_t *request)
100101
else if (index < USB_STR_COUNT)
101102
{
102103
const char *str = usb_strings[index];
103-
int len;
104+
int len = strlen(str);
105+
int size = len*2 + 2;
106+
alignas(4) uint8_t buf[size];
104107

105-
for (len = 0; *str; len++, str++)
108+
buf[0] = size;
109+
buf[1] = USB_STRING_DESCRIPTOR;
110+
111+
for (int i = 0; i < len; i++)
106112
{
107-
usb_string_descriptor_buffer[2 + len*2] = *str;
108-
usb_string_descriptor_buffer[3 + len*2] = 0;
113+
buf[2 + i*2] = str[i];
114+
buf[3 + i*2] = 0;
109115
}
110116

111-
usb_string_descriptor_buffer[0] = len*2 + 2;
112-
usb_string_descriptor_buffer[1] = USB_STRING_DESCRIPTOR;
113-
114-
length = LIMIT(length, usb_string_descriptor_buffer[0]);
117+
length = LIMIT(length, size);
115118

116-
usb_control_send(usb_string_descriptor_buffer, length);
119+
usb_control_send(buf, length);
117120
}
118121
else
119122
{

0 commit comments

Comments
 (0)