diff options
| author | Zixun LI <[email protected]> | 2025-11-14 14:52:43 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-14 14:52:43 +0100 |
| commit | fc5415bff6f177ad5f122f38dd937f577042bb32 (patch) | |
| tree | 8e640bde0d9616bd8e38804c5141fa0bc7a12496 /src/common | |
| parent | a3a5a41be8e22f529a8941c107ec32d48faa6ff2 (diff) | |
| parent | dc196b2b95f0ab3573cb10543e32a08810cefe3f (diff) | |
Merge pull request #3335 from ldube/master
Prevent tu_edpt_number() from returning an invalid endpoint number
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/tusb_types.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index a3a660d3b..73c816e3e 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -103,6 +103,7 @@ typedef enum { TUSB_DIR_OUT = 0, TUSB_DIR_IN = 1, + TUSB_EPNUM_MASK = 0x0F, TUSB_DIR_IN_MASK = 0x80 } tusb_dir_t; @@ -544,7 +545,7 @@ TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) { // Get Endpoint number from address TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_number(uint8_t addr) { - return (uint8_t) (addr & (~TUSB_DIR_IN_MASK)); + return (uint8_t) (addr & TUSB_EPNUM_MASK); } TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) { |
