Skip to content

Commit

Permalink
Unmount after USB reset
Browse files Browse the repository at this point in the history
  • Loading branch information
RockyZeroFour committed Feb 21, 2024
1 parent e825b7f commit c652452
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/common/tusb_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@
#define TU_ATTR_BIT_FIELD_ORDER_BEGIN
#define TU_ATTR_BIT_FIELD_ORDER_END

#if __GNUC__ < 5
#define TU_ATTR_FALLTHROUGH do {} while (0) /* fallthrough */
#else
#if __has_attribute(__fallthrough__)
#define TU_ATTR_FALLTHROUGH __attribute__((fallthrough))
#else
#define TU_ATTR_FALLTHROUGH do {} while (0) /* fallthrough */
#endif
#endif

// Endian conversion use well-known host to network (big endian) naming
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define TU_BYTE_ORDER TU_LITTLE_ENDIAN
Expand Down
3 changes: 2 additions & 1 deletion src/device/usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
TU_LOG2(": %s Speed\r\n", tu_str_speed[event.bus_reset.speed]);
usbd_reset(event.rhport);
_usbd_dev.speed = event.bus_reset.speed;
break;
TU_ATTR_FALLTHROUGH;

case DCD_EVENT_UNPLUGGED:
TU_LOG2("\r\n");
Expand Down Expand Up @@ -1082,6 +1082,7 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
{
switch (event->event_id)
{
case DCD_EVENT_BUS_RESET:
case DCD_EVENT_UNPLUGGED:
_usbd_dev.connected = 0;
_usbd_dev.addressed = 0;
Expand Down

0 comments on commit c652452

Please sign in to comment.