summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-09-05 15:45:03 +0700
committerhathach <[email protected]>2020-09-05 15:46:50 +0700
commitb8b95e84944b4c07cc9c9f4a7e4d53e6256b42f0 (patch)
tree15762a43bbc74bc5b28e22a1a027f7b7a7b6712d /src/host
parent90c8c14652ec81b34c9f2fa6ce69fa25d74a5bbf (diff)
add in_isr to all hcd event functions
Diffstat (limited to 'src/host')
-rw-r--r--src/host/ehci/ehci.c8
-rw-r--r--src/host/hcd.h30
-rw-r--r--src/host/hub.c2
-rw-r--r--src/host/ohci/ohci.c6
-rw-r--r--src/host/usbh.c14
5 files changed, 31 insertions, 29 deletions
diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c
index 295da4566..c2d5ebf7b 100644
--- a/src/host/ehci/ehci.c
+++ b/src/host/ehci/ehci.c
@@ -489,10 +489,10 @@ static void port_connect_status_change_isr(uint8_t hostid)
if (ehci_data.regs->portsc_bm.current_connect_status)
{
hcd_port_reset(hostid);
- hcd_event_device_attach(hostid);
+ hcd_event_device_attach(hostid, true);
}else // device unplugged
{
- hcd_event_device_remove(hostid);
+ hcd_event_device_remove(hostid, true);
}
}
@@ -512,7 +512,7 @@ static void qhd_xfer_complete_isr(ehci_qhd_t * p_qhd)
{
// end of request
// call USBH callback
- hcd_event_xfer_complete(p_qhd->dev_addr, tu_edpt_addr(p_qhd->ep_number, p_qhd->pid == EHCI_PID_IN ? 1 : 0), XFER_RESULT_SUCCESS, p_qhd->total_xferred_bytes);
+ hcd_event_xfer_complete(p_qhd->dev_addr, tu_edpt_addr(p_qhd->ep_number, p_qhd->pid == EHCI_PID_IN ? 1 : 0), p_qhd->total_xferred_bytes, XFER_RESULT_SUCCESS, true);
p_qhd->total_xferred_bytes = 0;
}
}
@@ -599,7 +599,7 @@ static void qhd_xfer_error_isr(ehci_qhd_t * p_qhd)
}
// call USBH callback
- hcd_event_xfer_complete(p_qhd->dev_addr, tu_edpt_addr(p_qhd->ep_number, p_qhd->pid == EHCI_PID_IN ? 1 : 0), error_event, p_qhd->total_xferred_bytes);
+ hcd_event_xfer_complete(p_qhd->dev_addr, tu_edpt_addr(p_qhd->ep_number, p_qhd->pid == EHCI_PID_IN ? 1 : 0), p_qhd->total_xferred_bytes, error_event, true);
p_qhd->total_xferred_bytes = 0;
}
diff --git a/src/host/hcd.h b/src/host/hcd.h
index da530421d..eebf2c801 100644
--- a/src/host/hcd.h
+++ b/src/host/hcd.h
@@ -110,20 +110,6 @@ tusb_speed_t hcd_port_speed_get(uint8_t hostid);
void hcd_device_close(uint8_t rhport, uint8_t dev_addr);
//--------------------------------------------------------------------+
-// Event function
-//--------------------------------------------------------------------+
-void hcd_event_handler(hcd_event_t const* event, bool in_isr);
-
-// Helper to send device attach event
-void hcd_event_device_attach(uint8_t rhport);
-
-// Helper to send device removal event
-void hcd_event_device_remove(uint8_t rhport);
-
-// Helper to send USB transfer event
-void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
-
-//--------------------------------------------------------------------+
// Endpoints API
//--------------------------------------------------------------------+
bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]);
@@ -145,6 +131,22 @@ bool hcd_pipe_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t buffer[], uint16_t
// tusb_error_t hcd_pipe_cancel();
+//--------------------------------------------------------------------+
+// Event API (implemented by stack)
+//--------------------------------------------------------------------+
+
+// Called by HCD to notify stack
+extern void hcd_event_handler(hcd_event_t const* event, bool in_isr);
+
+// Helper to send device attach event
+extern void hcd_event_device_attach(uint8_t rhport, bool in_isr);
+
+// Helper to send device removal event
+extern void hcd_event_device_remove(uint8_t rhport, bool in_isr);
+
+// Helper to send USB transfer event
+extern void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t xferred_bytes, xfer_result_t result, bool in_isr);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/host/hub.c b/src/host/hub.c
index 4fb28b72f..f88056c92 100644
--- a/src/host/hub.c
+++ b/src/host/hub.c
@@ -223,7 +223,7 @@ void hub_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_
event.attach.hub_port = port;
hcd_event_handler(&event, true);
- break; // handle one port at a time, next port if any will be handled in the next cycle
+ break; // TODO handle one port at a time, next port if any will be handled in the next cycle
}
}
// NOTE: next status transfer is queued by usbh.c after handling this request
diff --git a/src/host/ohci/ohci.c b/src/host/ohci/ohci.c
index 114f52e7d..87da374d5 100644
--- a/src/host/ohci/ohci.c
+++ b/src/host/ohci/ohci.c
@@ -599,7 +599,7 @@ static void done_queue_isr(uint8_t hostid)
hcd_event_xfer_complete(p_ed->dev_addr,
tu_edpt_addr(p_ed->ep_number, p_ed->pid == OHCI_PID_IN),
- event, xferred_bytes);
+ xferred_bytes, event, true);
}
td_head = (ohci_td_item_t*) td_head->next;
@@ -632,10 +632,10 @@ void hcd_int_handler(uint8_t hostid)
{
// TODO reset port immediately, without this controller will got 2-3 (debouncing connection status change)
OHCI_REG->rhport_status[0] = OHCI_RHPORT_PORT_RESET_STATUS_MASK;
- hcd_event_device_attach(0);
+ hcd_event_device_attach(hostid, true);
}else
{
- hcd_event_device_remove(0);
+ hcd_event_device_remove(hostid, true);
}
}
diff --git a/src/host/usbh.c b/src/host/usbh.c
index da163f9e4..6304b6b48 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -268,7 +268,7 @@ void hcd_event_handler(hcd_event_t const* event, bool in_isr)
}
// interrupt caused by a TD (with IOC=1) in pipe of class class_code
-void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint8_t result, uint32_t xferred_bytes)
+void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t xferred_bytes, xfer_result_t result, bool in_isr)
{
usbh_device_t* dev = &_usbh_devices[ dev_addr ];
@@ -276,7 +276,7 @@ void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint8_t result,
{
dev->control.pipe_status = result;
// usbh_devices[ pipe_hdl.dev_addr ].control.xferred_bytes = xferred_bytes; not yet neccessary
- osal_semaphore_post( dev->control.sem_hdl, true );
+ osal_semaphore_post( dev->control.sem_hdl, true ); // FIXME post within ISR
}
else
{
@@ -293,11 +293,11 @@ void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint8_t result,
}
};
- hcd_event_handler(&event, true);
+ hcd_event_handler(&event, in_isr);
}
}
-void hcd_event_device_attach(uint8_t rhport)
+void hcd_event_device_attach(uint8_t rhport, bool in_isr)
{
hcd_event_t event =
{
@@ -308,10 +308,10 @@ void hcd_event_device_attach(uint8_t rhport)
event.attach.hub_addr = 0;
event.attach.hub_port = 0;
- hcd_event_handler(&event, true);
+ hcd_event_handler(&event, in_isr);
}
-void hcd_event_device_remove(uint8_t hostid)
+void hcd_event_device_remove(uint8_t hostid, bool in_isr)
{
hcd_event_t event =
{
@@ -322,7 +322,7 @@ void hcd_event_device_remove(uint8_t hostid)
event.attach.hub_addr = 0;
event.attach.hub_port = 0;
- hcd_event_handler(&event, true);
+ hcd_event_handler(&event, in_isr);
}