Skip to content

Commit 548f88d

Browse files
pi-anldpgeorge
authored andcommitted
shared/tinyusb: Wake main task if needed at end of USB ISR.
Signed-off-by: Andrew Leech <[email protected]>
1 parent 11bc7d0 commit 548f88d

File tree

6 files changed

+22
-1
lines changed

6 files changed

+22
-1
lines changed

ports/mimxrt/mphalport.h

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ __attribute__((always_inline)) static inline uint32_t disable_irq(void) {
109109

110110
void mp_hal_set_interrupt_char(int c);
111111

112+
static inline void mp_hal_wake_main_task_from_isr(void) {
113+
// Defined for tinyusb support, nothing needs to be done here.
114+
}
115+
112116
static inline mp_uint_t mp_hal_ticks_ms(void) {
113117
return ticks_ms32();
114118
}

ports/nrf/mphalport.h

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ void mp_hal_set_interrupt_char(int c); // -1 to disable
5353
int mp_hal_stdin_rx_chr(void);
5454
void mp_hal_stdout_tx_str(const char *str);
5555

56+
static inline void mp_hal_wake_main_task_from_isr(void) {
57+
// Defined for tinyusb support, nothing needs to be done here.
58+
}
59+
5660
void mp_hal_delay_ms(mp_uint_t ms);
5761
void mp_hal_delay_us(mp_uint_t us);
5862

ports/renesas-ra/mphalport.h

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ static inline int mp_hal_status_to_neg_errno(HAL_StatusTypeDef status) {
5252
NORETURN void mp_hal_raise(HAL_StatusTypeDef status);
5353
void mp_hal_set_interrupt_char(int c); // -1 to disable
5454

55+
static inline void mp_hal_wake_main_task_from_isr(void) {
56+
// Defined for tinyusb support, nothing needs to be done here.
57+
}
58+
5559
// timing functions
5660

5761
#include "irq.h"

ports/rp2/mphalport.h

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ void mp_thread_end_atomic_section(uint32_t);
7777
void mp_hal_set_interrupt_char(int c);
7878
void mp_hal_time_ns_set_from_rtc(void);
7979

80+
static inline void mp_hal_wake_main_task_from_isr(void) {
81+
// Defined for tinyusb support, nothing needs to be done here.
82+
}
83+
8084
static inline void mp_hal_delay_us_fast(mp_uint_t us) {
8185
busy_wait_us(us);
8286
}

ports/samd/mphalport.h

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ uint64_t mp_hal_ticks_us_64(void);
5050

5151
void mp_hal_set_interrupt_char(int c);
5252

53+
static inline void mp_hal_wake_main_task_from_isr(void) {
54+
// Defined for tinyusb support, nothing needs to be done here.
55+
}
56+
5357
__attribute__((always_inline)) static inline void enable_irq(uint32_t state) {
5458
__set_PRIMASK(state);
5559
}

shared/tinyusb/mp_usbd.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#include "py/mpconfig.h"
27+
#include "py/mphal.h"
2828

2929
#if MICROPY_HW_ENABLE_USBDEV
3030

@@ -55,6 +55,7 @@ extern void __real_dcd_event_handler(dcd_event_t const *event, bool in_isr);
5555
TU_ATTR_FAST_FUNC void __wrap_dcd_event_handler(dcd_event_t const *event, bool in_isr) {
5656
__real_dcd_event_handler(event, in_isr);
5757
mp_usbd_schedule_task();
58+
mp_hal_wake_main_task_from_isr();
5859
}
5960

6061
TU_ATTR_FAST_FUNC void mp_usbd_schedule_task(void) {

0 commit comments

Comments
 (0)