add new tusb_int_handler(rhport, in_isr) as common irq handler

update tusb_init() to take rhport and role, defined as macro with optional argument for backward compatible
This commit is contained in:
hathach
2024-10-10 16:22:12 +07:00
parent ffdf81f53a
commit 57aac432b5
59 changed files with 192 additions and 286 deletions

View File

@@ -149,12 +149,9 @@ extern void hcd_int_handler(uint8_t rhport, bool in_isr);
#endif
// Interrupt handler alias to HCD with in_isr as optional parameter
// - tuh_int_handler(rhport) --> hcd_int_handler(rhport, true)
// - tuh_int_handler(rhport, in_isr) --> hcd_int_handler(rhport, in_isr)
// Note: this is similar to TU_VERIFY(), _GET_3RD_ARG() is defined in tusb_verify.h
#define _tuh_int_handler_1arg(_rhport) hcd_int_handler(_rhport, true)
#define _tuh_int_hanlder_2arg(_rhport, _in_isr) hcd_int_handler(_rhport, _in_isr)
#define tuh_int_handler(...) _GET_3RD_ARG(__VA_ARGS__, _tuh_int_hanlder_2arg, _tuh_int_handler_1arg, _dummy)(__VA_ARGS__)
#define tuh_int_handler(...) TU_GET_3RD_ARG(__VA_ARGS__, _tuh_int_hanlder_2arg, _tuh_int_handler_1arg, _dummy)(__VA_ARGS__)
// Check if roothub port is initialized and active as a host
bool tuh_rhport_is_active(uint8_t rhport);