Skip to content

Commit a7d7f1a

Browse files
committed
usb changed class code to enum
1 parent b830bfe commit a7d7f1a

File tree

8 files changed

+43
-10
lines changed

8 files changed

+43
-10
lines changed

klib/usb/cdc/descriptor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace klib::usb::cdc {
9393
uint8_t bmCapabilities;
9494

9595
// interface number of the data class interface. (optionally
96-
// used for call management)7
96+
// used for call management)
9797
uint8_t bDataInterface;
9898
};
9999

klib/usb/descriptor.hpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,39 @@ namespace klib::usb::descriptor {
1414
*
1515
*/
1616

17+
/**
18+
* @brief Defined class codes following the USB definitions
19+
* https://www.usb.org/defined-class-codes
20+
*
21+
*/
22+
enum class class_type: uint8_t {
23+
use_class_info = 0x00,
24+
audio = 0x01,
25+
communication_and_cdc = 0x02,
26+
hid = 0x03,
27+
physical = 0x04,
28+
image = 0x06,
29+
printer = 0x07,
30+
mass_storage = 0x08,
31+
hub = 0x09,
32+
cdc_Data = 0x0a,
33+
smart_card = 0x0b,
34+
content_security = 0x0d,
35+
video = 0x0e,
36+
personal_healthcare = 0x0f,
37+
audio_video_devices = 0x10,
38+
billboard_device = 0x11,
39+
type_c_bridge = 0x12,
40+
bulk_display = 0x13,
41+
mctp_over_usb = 0x14,
42+
i3c = 0x3c,
43+
diagnostic_device = 0xdc,
44+
wireless_controller = 0xe0,
45+
miscellaneous = 0xef,
46+
application_specific = 0xfe,
47+
vendor_specific = 0xff,
48+
};
49+
1750
/**
1851
* Descriptor types from the usb 2.0 specification
1952
*
@@ -91,7 +124,7 @@ namespace klib::usb::descriptor {
91124
uint16_t bcdUSB;
92125

93126
// class code
94-
uint8_t bDeviceClass;
127+
class_type bDeviceClass;
95128

96129
// subclass code
97130
uint8_t bDeviceSubClass;
@@ -300,7 +333,7 @@ namespace klib::usb::descriptor {
300333
uint16_t bcdUSB;
301334

302335
// class code
303-
uint8_t bDeviceClass;
336+
class_type bDeviceClass;
304337

305338
// subclass code
306339
uint8_t bDeviceSubClass;

klib/usb/device/bulk.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace klib::usb::device {
5858
// device descriptor for the hid keyboard
5959
const __attribute__((aligned(4))) static inline descriptor::device device = {
6060
.bcdUSB = static_cast<uint16_t>(setup::usb_version::usb_v1_1),
61-
.bDeviceClass = 0xff,
61+
.bDeviceClass = descriptor::class_type::vendor_specific,
6262
.bDeviceSubClass = 0x00,
6363
.bDeviceProtocol = 0x00,
6464
.bMaxPacketSize = 0x40,

klib/usb/device/dfu.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace klib::usb::device {
6565
// device descriptor for the hid keyboard
6666
const __attribute__((aligned(4))) static inline descriptor::device device = {
6767
.bcdUSB = static_cast<uint16_t>(setup::usb_version::usb_v1_1),
68-
.bDeviceClass = 0x00,
68+
.bDeviceClass = descriptor::class_type::use_class_info,
6969
.bDeviceSubClass = 0x00,
7070
.bDeviceProtocol = 0x00,
7171
.bMaxPacketSize = 0x40,

klib/usb/device/keyboard.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace klib::usb::device {
7777
// device descriptor for the hid keyboard
7878
const __attribute__((aligned(4))) static inline descriptor::device device = {
7979
.bcdUSB = static_cast<uint16_t>(setup::usb_version::usb_v1_1),
80-
.bDeviceClass = 0x00,
80+
.bDeviceClass = descriptor::class_type::use_class_info,
8181
.bDeviceSubClass = 0x00,
8282
.bDeviceProtocol = 0x00,
8383
.bMaxPacketSize = 0x40,

klib/usb/device/mass_storage.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace klib::usb::device {
5757
// device descriptor for the mass storage class
5858
const __attribute__((aligned(4))) static inline descriptor::device device = {
5959
.bcdUSB = static_cast<uint16_t>(setup::usb_version::usb_v2_0),
60-
.bDeviceClass = 0x00,
60+
.bDeviceClass = descriptor::class_type::use_class_info,
6161
.bDeviceSubClass = 0x00,
6262
.bDeviceProtocol = 0x00,
6363
.bMaxPacketSize = 0x40,
@@ -106,7 +106,7 @@ namespace klib::usb::device {
106106
// device qualifier
107107
const __attribute__((aligned(4))) static inline descriptor::qualifier qualifier = {
108108
.bcdUSB = static_cast<uint16_t>(setup::usb_version::usb_v2_0),
109-
.bDeviceClass = 0x00,
109+
.bDeviceClass = descriptor::class_type::use_class_info,
110110
.bDeviceSubClass = 0x00,
111111
.bDeviceProtocol = 0x00,
112112
.bMaxPacketSize0 = 0x40,

klib/usb/device/mouse.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace klib::usb::device {
7777
// device descriptor for the hid keyboard
7878
const __attribute__((aligned(4))) static inline descriptor::device device = {
7979
.bcdUSB = static_cast<uint16_t>(setup::usb_version::usb_v1_1),
80-
.bDeviceClass = 0x00,
80+
.bDeviceClass = descriptor::class_type::use_class_info,
8181
.bDeviceSubClass = 0x00,
8282
.bDeviceProtocol = 0x00,
8383
.bMaxPacketSize = 0x40,

klib/usb/device/serial.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace klib::usb::device {
8585
// device descriptor for the hid keyboard
8686
const __attribute__((aligned(4))) static inline descriptor::device device = {
8787
.bcdUSB = static_cast<uint16_t>(setup::usb_version::usb_v2_0),
88-
.bDeviceClass = 0x02,
88+
.bDeviceClass = descriptor::class_type::communication_and_cdc,
8989
.bDeviceSubClass = 0x02,
9090
.bDeviceProtocol = 0x00,
9191
.bMaxPacketSize = 0x40,

0 commit comments

Comments
 (0)