Skip to content

Commit fc5415b

Browse files
authored
Merge pull request #3335 from ldube/master
Prevent tu_edpt_number() from returning an invalid endpoint number
2 parents a3a5a41 + dc196b2 commit fc5415b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/common/tusb_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ typedef enum {
103103
TUSB_DIR_OUT = 0,
104104
TUSB_DIR_IN = 1,
105105

106+
TUSB_EPNUM_MASK = 0x0F,
106107
TUSB_DIR_IN_MASK = 0x80
107108
} tusb_dir_t;
108109

@@ -544,7 +545,7 @@ TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) {
544545

545546
// Get Endpoint number from address
546547
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_number(uint8_t addr) {
547-
return (uint8_t) (addr & (~TUSB_DIR_IN_MASK));
548+
return (uint8_t) (addr & TUSB_EPNUM_MASK);
548549
}
549550

550551
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) {

0 commit comments

Comments
 (0)