summaryrefslogtreecommitdiff
path: root/src/common/tusb_types.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-07-02 18:18:52 +0700
committerhathach <[email protected]>2025-07-02 18:18:52 +0700
commitcf3966efd9fc552d641ea1e76e5aaad3ace3afd2 (patch)
treed59add439dcbfcd6e2cd9fec9aaecc413e5b5509 /src/common/tusb_types.h
parentf10467e711017fb05a6e0ee496e451e2e8834549 (diff)
parent963971c6aa14411f0cc6f0c4f727d199c738e2a5 (diff)
Merge branch 'master' into fork/HiFiPhile/dcd_notif
Diffstat (limited to 'src/common/tusb_types.h')
-rw-r--r--src/common/tusb_types.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h
index 9e4d9380c..ec7aad796 100644
--- a/src/common/tusb_types.h
+++ b/src/common/tusb_types.h
@@ -278,10 +278,13 @@ typedef enum {
XFER_RESULT_INVALID
} xfer_result_t;
+#define tusb_xfer_result_t xfer_result_t
+
// TODO remove
enum {
DESC_OFFSET_LEN = 0,
- DESC_OFFSET_TYPE = 1
+ DESC_OFFSET_TYPE = 1,
+ DESC_OFFSET_SUBTYPE = 2
};
enum {
@@ -302,9 +305,9 @@ typedef enum {
enum {
CONTROL_STAGE_IDLE = 0,
- CONTROL_STAGE_SETUP,
- CONTROL_STAGE_DATA,
- CONTROL_STAGE_ACK
+ CONTROL_STAGE_SETUP, // 1
+ CONTROL_STAGE_DATA, // 2
+ CONTROL_STAGE_ACK // 3
};
enum {
@@ -344,7 +347,6 @@ typedef struct TU_ATTR_PACKED {
uint8_t iManufacturer ; ///< Index of string descriptor describing manufacturer.
uint8_t iProduct ; ///< Index of string descriptor describing product.
uint8_t iSerialNumber ; ///< Index of string descriptor describing the device's serial number.
-
uint8_t bNumConfigurations ; ///< Number of possible configurations.
} tusb_desc_device_t;
@@ -462,7 +464,7 @@ TU_VERIFY_STATIC( sizeof(tusb_desc_interface_assoc_t) == 8, "size is not correct
typedef struct TU_ATTR_PACKED {
uint8_t bLength ; ///< Size of this descriptor in bytes
uint8_t bDescriptorType ; ///< Descriptor Type
- uint16_t unicode_string[];
+ uint16_t utf16le[];
} tusb_desc_string_t;
// USB Binary Device Object Store (BOS)
@@ -570,16 +572,27 @@ TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* des
return desc8 + desc8[DESC_OFFSET_LEN];
}
+// get descriptor length
+TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_len(void const* desc) {
+ return ((uint8_t const*) desc)[DESC_OFFSET_LEN];
+}
+
// get descriptor type
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_type(void const* desc) {
return ((uint8_t const*) desc)[DESC_OFFSET_TYPE];
}
-// get descriptor length
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_len(void const* desc) {
- return ((uint8_t const*) desc)[DESC_OFFSET_LEN];
+// get descriptor subtype
+TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_subtype(void const* desc) {
+ return ((uint8_t const*) desc)[DESC_OFFSET_SUBTYPE];
}
+TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_is_valid(void const* desc, uint8_t const* desc_end) {
+ const uint8_t* desc8 = (uint8_t const*) desc;
+ return (desc8 < desc_end) && (tu_desc_next(desc) <= desc_end);
+}
+
+
// find descriptor that match byte1 (type)
uint8_t const * tu_desc_find(uint8_t const* desc, uint8_t const* end, uint8_t byte1);