You've already forked dspico-usb-examples
mirror of
https://github.com/LNH-team/dspico-usb-examples.git
synced 2026-01-09 16:27:56 -08:00
Initial commit
This commit is contained in:
25
platform/UsbStringDescriptor.h
Normal file
25
platform/UsbStringDescriptor.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "tusb.h"
|
||||
|
||||
template<std::size_t N>
|
||||
struct UsbStringDescriptor
|
||||
{
|
||||
u8 length = 2 * N;
|
||||
u8 descriptorType = TUSB_DESC_STRING;
|
||||
char16_t string[N - 1];
|
||||
|
||||
explicit constexpr UsbStringDescriptor(const char16_t(&str)[N])
|
||||
{
|
||||
for (size_t i = 0; i < N - 1; i++)
|
||||
{
|
||||
string[i] = str[i];
|
||||
}
|
||||
}
|
||||
|
||||
explicit constexpr UsbStringDescriptor(u16 languageId)
|
||||
{
|
||||
string[0] = languageId;
|
||||
}
|
||||
};
|
||||
|
||||
#define USB_STRING_DESCRIPTOR(str) ({ static const UsbStringDescriptor descriptor(str); (const u16*)&descriptor; })
|
||||
Reference in New Issue
Block a user