diff --git a/tests/test/host/ehci/test_pipe_bulk_xfer.c b/tests/test/host/ehci/test_pipe_bulk_xfer.c index 71a833b46..6d3d0c4a7 100644 --- a/tests/test/host/ehci/test_pipe_bulk_xfer.c +++ b/tests/test/host/ehci/test_pipe_bulk_xfer.c @@ -202,7 +202,7 @@ void test_bulk_xfer_double(void) TEST_ASSERT_TRUE(p_tail->int_on_complete); } -void test_bulk_xfer_isr(void) +void test_bulk_xfer_complete_isr(void) { hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), false); hcd_pipe_xfer(pipe_hdl_bulk, data2, sizeof(data2), true); @@ -212,7 +212,7 @@ void test_bulk_xfer_isr(void) ehci_controller_run(hostid); - usbh_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC); + usbh_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC, BUS_EVENT_XFER_COMPLETE); //------------- Code Under Test -------------// hcd_isr(hostid); diff --git a/tests/test/host/ehci/test_pipe_control_xfer.c b/tests/test/host/ehci/test_pipe_control_xfer.c index 19d2b7e21..432f5956e 100644 --- a/tests/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/test/host/ehci/test_pipe_control_xfer.c @@ -235,7 +235,7 @@ void test_control_xfer_complete_isr(void) TEST_ASSERT_EQUAL_HEX(async_head, get_operational_register(hostid)->async_list_base); TEST_ASSERT_EQUAL_HEX((uint32_t) p_control_qhd, align32(async_head->next.address)); - usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0); + usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, BUS_EVENT_XFER_COMPLETE); //------------- Code Under TEST -------------// hcd_isr(hostid); diff --git a/tinyusb/class/hid_host.h b/tinyusb/class/hid_host.h index f85beef67..c0cb81702 100644 --- a/tinyusb/class/hid_host.h +++ b/tinyusb/class/hid_host.h @@ -89,7 +89,7 @@ tusb_error_t hidh_keyboard_install(uint8_t dev_addr, uint8_t const *descriptor) //--------------------------------------------------------------------+ void hidh_init(void) ATTR_WEAK; tusb_error_t hidh_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length) ATTR_WEAK ATTR_WARN_UNUSED_RESULT; -void hidh_isr(pipe_handle_t pipe_hdl) ATTR_WEAK; +void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event) ATTR_WEAK; void hidh_close(uint8_t dev_addr) ATTR_WEAK; #endif diff --git a/tinyusb/class/msc_host.h b/tinyusb/class/msc_host.h index 021d30412..f6222197d 100644 --- a/tinyusb/class/msc_host.h +++ b/tinyusb/class/msc_host.h @@ -70,7 +70,7 @@ void msch_init(void) ATTR_WEAK; tusb_error_t msch_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length) ATTR_WEAK ATTR_WARN_UNUSED_RESULT; -void msch_isr(pipe_handle_t pipe_hdl) ATTR_WEAK; +void msch_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event) ATTR_WEAK; void msch_close(uint8_t dev_addr) ATTR_WEAK; #endif diff --git a/tinyusb/core/tusb_types.h b/tinyusb/core/tusb_types.h index d9750c279..aff92aebb 100644 --- a/tinyusb/core/tusb_types.h +++ b/tinyusb/core/tusb_types.h @@ -164,6 +164,11 @@ enum tusb_device_state_{ TUSB_DEVICE_STATE_SAFE_REMOVE , }; +typedef enum { + BUS_EVENT_XFER_COMPLETE, + BUS_EVENT_XFER_ERROR +}tusb_bus_event_t; + #ifdef __cplusplus } #endif diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index e24548bc1..9d8bb16e7 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -224,7 +224,7 @@ void async_list_process_isr(ehci_qhd_t * const async_head, ehci_registers_t * co pipe_hdl.xfer_type = TUSB_XFER_BULK; pipe_hdl.index = qhd_get_index(p_qhd); } - usbh_isr( pipe_hdl, p_qhd->class_code); // call USBH call back + usbh_isr( pipe_hdl, p_qhd->class_code, BUS_EVENT_XFER_COMPLETE); // call USBH callback } p_qhd->p_qtd_list_head->used = 0; // free QTD diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h index 129a4640f..98b5e5c5c 100644 --- a/tinyusb/host/hcd.h +++ b/tinyusb/host/hcd.h @@ -66,11 +66,6 @@ typedef struct { uint8_t index; } pipe_handle_t; -typedef enum { - BUS_XFER_COMPLETE, - BUS_XFER_ERROR -}usb_bus_event_t; - //--------------------------------------------------------------------+ // USBH-HCD API //--------------------------------------------------------------------+ diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index f56291290..544c1a467 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -61,7 +61,7 @@ void tusb_tick_tock(void) #define ENUM_QUEUE_DEPTH 5 // TODO fix number of class driver -static class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER] = +static host_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER] = { [TUSB_CLASS_HID] = { .init = hidh_init, @@ -179,14 +179,14 @@ pipe_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl) // USBH-HCD ISR/Callback API //--------------------------------------------------------------------+ // interrupt caused by a TD (with IOC=1) in pipe of class class_code -void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code) +void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_bus_event_t event) { if (class_code == 0) // Control transfer { osal_semaphore_post( usbh_device_info_pool[ pipe_hdl.dev_addr ].sem_hdl ); }else if (usbh_class_drivers[class_code].isr) { - usbh_class_drivers[class_code].isr(pipe_hdl); + usbh_class_drivers[class_code].isr(pipe_hdl, event); }else { ASSERT(false, (void) 0); // something wrong, no one claims the isr's source diff --git a/tinyusb/host/usbh.h b/tinyusb/host/usbh.h index 1dae917f6..901a0f056 100644 --- a/tinyusb/host/usbh.h +++ b/tinyusb/host/usbh.h @@ -106,9 +106,9 @@ typedef uint8_t tusbh_device_status_t; typedef struct { void (* const init) (void); tusb_error_t (* const open_subtask)(uint8_t, uint8_t const *, uint16_t*); - void (* const isr) (pipe_handle_t); + void (* const isr) (pipe_handle_t, tusb_bus_event_t); void (* const close) (uint8_t); -} class_driver_t; +} host_class_driver_t; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h index bd0d09c55..d11b6e45f 100644 --- a/tinyusb/host/usbh_hcd.h +++ b/tinyusb/host/usbh_hcd.h @@ -101,7 +101,7 @@ typedef struct { // TODO internal structure, re-order members extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address -void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code); +void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_bus_event_t event); void usbh_device_plugged_isr(uint8_t hostid, tusb_speed_t speed); void usbh_device_unplugged_isr(uint8_t hostid);