summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2026-06-18 21:56:36 +0700
committerGitHub <[email protected]>2026-06-18 21:56:36 +0700
commit11b4cf61efb2d59ebf358c4afdd2dfd4c614276e (patch)
tree58bc5b6dff3ac8307564748a3a3eec7d2cb46fc6 /src
parent849c26c1b9bb9d76debc4acfad90583ea7edc4d8 (diff)
parent3710e6e5a580fadb53ec2e6cbf12dd6fb65c39c2 (diff)
Merge pull request #3618 from hathach/copilot/fix-audio-bitfield-order-issues
fix: BE bitfield guards for audio structs and endian-safe wValue/wIndex extraction in UAC2 examples
Diffstat (limited to 'src')
-rw-r--r--src/class/audio/audio.h32
1 files changed, 9 insertions, 23 deletions
diff --git a/src/class/audio/audio.h b/src/class/audio/audio.h
index cff38cc22..428391bb2 100644
--- a/src/class/audio/audio.h
+++ b/src/class/audio/audio.h
@@ -490,10 +490,19 @@ typedef struct TU_ATTR_PACKED {
uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_ENDPOINT.
uint8_t bEndpointAddress;///< The address of the endpoint on the USB device described by this descriptor.
struct TU_ATTR_PACKED {
+#if (TU_BITFIELD_ORDER == TU_BITFIELD_LE)
uint8_t xfer : 2; // Control, ISO, Bulk, Interrupt
uint8_t sync : 2; // None, Asynchronous, Adaptive, Synchronous
uint8_t usage : 2; // Data, Feedback, Implicit feedback
uint8_t : 2;
+#elif (TU_BITFIELD_ORDER == TU_BITFIELD_BE)
+ uint8_t : 2;
+ uint8_t usage : 2; // Data, Feedback, Implicit feedback
+ uint8_t sync : 2; // None, Asynchronous, Adaptive, Synchronous
+ uint8_t xfer : 2; // Control, ISO, Bulk, Interrupt
+#else
+ #error "Please define TU_BITFIELD_ORDER as TU_BITFIELD_LE or TU_BITFIELD_BE"
+#endif
} bmAttributes;
uint16_t wMaxPacketSize; ///< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected.
uint8_t bInterval; ///< Interval for polling endpoint for data transfers.
@@ -1177,29 +1186,6 @@ typedef struct TU_ATTR_PACKED {
uint16_t wLockDelay; ///< Indicates the time it takes this endpoint to reliably lock its internal clock recovery circuitry. Units used depend on the value of the bLockDelayUnits field.
} audio20_desc_cs_as_iso_data_ep_t;
-// 5.2.2 Control Request Layout
-typedef struct TU_ATTR_PACKED {
- union {
- struct TU_ATTR_PACKED {
- uint8_t recipient : 5;///< Recipient type tusb_request_recipient_t.
- uint8_t type : 2; ///< Request type tusb_request_type_t.
- uint8_t direction : 1;///< Direction type. tusb_dir_t
- } bmRequestType_bit;
-
- uint8_t bmRequestType;
- };
-
- uint8_t bRequest;///< Request type audio_cs_req_t
- uint8_t bChannelNumber;
- uint8_t bControlSelector;
- union {
- uint8_t bInterface;
- uint8_t bEndpoint;
- };
- uint8_t bEntityID;
- uint16_t wLength;
-} audio20_control_request_t;
-
//// 5.2.3 Control Request Parameter Block Layout
// 5.2.3.1 1-byte Control CUR Parameter Block