diff options
author | Stefan Kerkmann <karlk90@pm.me> | 2023-10-27 18:44:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-27 18:44:58 +0200 |
commit | 5856d5e13b1f59187f1a73d1bda8075cba7daaa8 (patch) | |
tree | 3914fbaf702c268ea1348b3bb3c8269f4983cdde /tmk_core/protocol/usb_types.h | |
parent | 64d1ce751fa455a9918e7b93a18dde9479beba2f (diff) |
[Maintenance] USB HID control packet as struct (#21688)
* ChibiOS: USB HID control request as dedicated struct
Instead of accessing the raw USB setup packet and documenting the values
as the corresponding USB HID control request fields we introduce a
struct that allows direct access to the fields. This is safer and self
documenting.
* Rename usb_request.h to usb_types.h
In the future all shared USB data types can live in this file.
Diffstat (limited to 'tmk_core/protocol/usb_types.h')
-rw-r--r-- | tmk_core/protocol/usb_types.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tmk_core/protocol/usb_types.h b/tmk_core/protocol/usb_types.h new file mode 100644 index 0000000000..019775a1c4 --- /dev/null +++ b/tmk_core/protocol/usb_types.h @@ -0,0 +1,23 @@ +// Copyright 2023 Stefan Kerkmann +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "util.h" + +/** + * @brief Common USB 2.0 control request structure + */ +typedef struct { + uint8_t bmRequestType; // [0] (Bitmask) + uint8_t bRequest; // [1] + union { + struct { + uint8_t lbyte; // [2] (LSB) + uint8_t hbyte; // [3] (MSB) + }; + uint16_t word; // [2,3] (LSB,MSB) + } wValue; + uint16_t wIndex; // [4,5] (LSB,MSB) + uint16_t wLength; // [6,7] (LSB,MSB) +} PACKED usb_control_request_t; |