summaryrefslogtreecommitdiff
path: root/src/device/usbd_control.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-04-28 22:08:28 +0700
committerhathach <[email protected]>2026-04-28 22:08:28 +0700
commit7d556a3ae108fcc43515e1ef2c5ea613ec324551 (patch)
tree5e02238c6b8cad4880b2ba2a9fa9983bc79e4a6e /src/device/usbd_control.c
parentd3107be360b45c4b8dbc223dcc5e5f57b582c5ff (diff)
parent4a4420cd070f4460f6f5ed3c17011d78c325d7c0 (diff)
Merge branch 'master' into fork/kira-live/master
# Conflicts: # src/device/usbd_control.c
Diffstat (limited to 'src/device/usbd_control.c')
-rw-r--r--src/device/usbd_control.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c
index b5dae7d59..58b78ff53 100644
--- a/src/device/usbd_control.c
+++ b/src/device/usbd_control.c
@@ -44,10 +44,6 @@ TU_ATTR_WEAK void dcd_edpt0_status_complete(uint8_t rhport, const tusb_control_r
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
-enum {
- EDPT_CTRL_OUT = 0x00,
- EDPT_CTRL_IN = 0x80
-};
typedef struct {
tusb_control_request_t request;
@@ -75,8 +71,8 @@ uint8_t* usbd_get_ctrl_buf(void) {
// Per USB 2.0 ยง9.3.1, when wLength == 0 the Direction bit is ignored and the Status stage
// is always IN. Otherwise the Status stage is opposite to the Data stage direction.
TU_ATTR_ALWAYS_INLINE static inline uint8_t status_stage_ep(const tusb_control_request_t* request) {
- if (request->wLength == 0) return EDPT_CTRL_IN;
- return request->bmRequestType_bit.direction ? EDPT_CTRL_OUT : EDPT_CTRL_IN;
+ if (request->wLength == 0) return TU_EP0_IN;
+ return request->bmRequestType_bit.direction ? TU_EP0_OUT : TU_EP0_IN;
}
// Queue ZLP status transaction
@@ -99,10 +95,10 @@ bool tud_control_status(uint8_t rhport, const tusb_control_request_t* request) {
// This function can also transfer an zero-length packet
static bool data_stage_xact(uint8_t rhport) {
const uint16_t xact_len = tu_min16(_ctrl_xfer.data_len - _ctrl_xfer.total_xferred, CFG_TUD_ENDPOINT0_BUFSIZE);
- uint8_t ep_addr = EDPT_CTRL_OUT;
+ uint8_t ep_addr = TU_EP0_OUT;
if (_ctrl_xfer.request.bmRequestType_bit.direction == TUSB_DIR_IN) {
- ep_addr = EDPT_CTRL_IN;
+ ep_addr = TU_EP0_IN;
if (0u != xact_len && _ctrl_xfer.buffer != _ctrl_epbuf.buf) {
TU_VERIFY(0 == tu_memcpy_s(_ctrl_epbuf.buf, CFG_TUD_ENDPOINT0_BUFSIZE, _ctrl_xfer.buffer, xact_len));
}
@@ -209,8 +205,8 @@ bool usbd_control_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result,
TU_ASSERT(status_stage_xact(rhport, &_ctrl_xfer.request));
} else {
// Stall both IN and OUT control endpoint
- dcd_edpt_stall(rhport, EDPT_CTRL_OUT);
- dcd_edpt_stall(rhport, EDPT_CTRL_IN);
+ dcd_edpt_stall(rhport, TU_EP0_OUT);
+ dcd_edpt_stall(rhport, TU_EP0_IN);
}
} else {
// More data to transfer