replace dcd_bus_event() and dcd_setup_received() by dcd_event_handler()
This commit is contained in:
@@ -414,11 +414,15 @@ void USBD_IRQHandler(void)
|
||||
}
|
||||
}
|
||||
|
||||
dcd_event_t event = { .rhport = 0 };
|
||||
|
||||
/*------------- Interrupt Processing -------------*/
|
||||
if ( int_status & USBD_INTEN_USBRESET_Msk )
|
||||
{
|
||||
bus_reset();
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_RESET);
|
||||
|
||||
event.event_id = DCD_EVENT_BUS_RESET;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
|
||||
if ( int_status & EDPT_END_ALL_MASK )
|
||||
@@ -435,7 +439,10 @@ void USBD_IRQHandler(void)
|
||||
NRF_USBD->WINDEXL , NRF_USBD->WINDEXH , NRF_USBD->WLENGTHL, NRF_USBD->WLENGTHH
|
||||
};
|
||||
|
||||
dcd_setup_received(0, setup);
|
||||
event.event_id = DCD_EVENT_SETUP_RECEIVED;
|
||||
memcpy(&event.setup_received, setup, 8);
|
||||
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
|
||||
if ( int_status & USBD_INTEN_EP0DATADONE_Msk )
|
||||
@@ -556,7 +563,8 @@ void USBD_IRQHandler(void)
|
||||
// SOF interrupt
|
||||
if ( int_status & USBD_INTEN_SOF_Msk )
|
||||
{
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_SOF);
|
||||
event.event_id = DCD_EVENT_SOF;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -309,6 +309,8 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
|
||||
uint32_t const dev_cmd_stat = LPC_USB->DEVCMDSTAT;
|
||||
|
||||
dcd_event_t event = { .rhport = rhport };
|
||||
|
||||
//------------- Device Status -------------//
|
||||
if ( int_status & INT_MASK_DEVICE_STATUS )
|
||||
{
|
||||
@@ -316,14 +318,17 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
if ( dev_cmd_stat & CMDSTAT_RESET_CHANGE_MASK) // bus reset
|
||||
{
|
||||
bus_reset();
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_RESET);
|
||||
|
||||
event.event_id = DCD_EVENT_BUS_RESET;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
|
||||
if (dev_cmd_stat & CMDSTAT_CONNECT_CHANGE_MASK)
|
||||
{ // device disconnect
|
||||
if (dev_cmd_stat & CMDSTAT_DEVICE_ADDR_MASK)
|
||||
{ // debouncing as this can be set when device is powering
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_UNPLUGGED);
|
||||
event.event_id = DCD_EVENT_UNPLUGGED;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,13 +340,15 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
// Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
|
||||
if (dev_cmd_stat & CMDSTAT_DEVICE_ADDR_MASK)
|
||||
{
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_SUSPENDED);
|
||||
event.event_id = DCD_EVENT_SUSPENDED;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// else
|
||||
// { // resume signal
|
||||
// dcd_bus_event(0, USBD_BUS_EVENT_RESUME);
|
||||
// event.event_id = DCD_EVENT_RESUME;
|
||||
// dcd_event_handler(&event, true);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -350,7 +357,10 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
if ( BIT_TEST_(int_status, 0) && (dev_cmd_stat & CMDSTAT_SETUP_RECEIVED_MASK) )
|
||||
{ // received control request from host
|
||||
// copy setup request & acknowledge so that the next setup can be received by hw
|
||||
dcd_setup_received(rhport, (uint8_t*)&dcd_data.setup_request);
|
||||
event.event_id = DCD_EVENT_SETUP_RECEIVED;
|
||||
event.setup_received = dcd_data.setup_request;
|
||||
|
||||
dcd_event_handler(&event, true);
|
||||
|
||||
// NXP control flowchart clear Active & Stall on both Control IN/OUT endpoints
|
||||
dcd_data.qhd[0][0].stall = dcd_data.qhd[1][0].stall = 0;
|
||||
|
||||
@@ -182,15 +182,18 @@ static void endpoint_control_isr(void)
|
||||
uint32_t const endpoint_int_status = LPC_USB->USBEpIntSt & interrupt_enable;
|
||||
// LPC_USB->USBEpIntClr = endpoint_int_status; // acknowledge interrupt TODO cannot immediately acknowledge setup packet
|
||||
|
||||
dcd_event_t event = { .rhport = 0 };
|
||||
|
||||
//------------- Setup Recieved-------------//
|
||||
if ( (endpoint_int_status & BIT_(0)) &&
|
||||
(sie_read(SIE_CMDCODE_ENDPOINT_SELECT+0, 1) & SIE_SELECT_ENDPOINT_SETUP_RECEIVED_MASK) )
|
||||
{
|
||||
(void) sie_read(SIE_CMDCODE_ENDPOINT_SELECT_CLEAR_INTERRUPT+0, 1); // clear setup bit
|
||||
|
||||
tusb_control_request_t control_request;
|
||||
pipe_control_read(&control_request, 8); // TODO read before clear setup above
|
||||
dcd_setup_received(0, (uint8_t*) &control_request);
|
||||
event.event_id = DCD_EVENT_SETUP_RECEIVED;
|
||||
pipe_control_read(&event.setup_received, 8); // TODO read before clear setup above
|
||||
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
else if (endpoint_int_status & 0x03)
|
||||
{
|
||||
@@ -225,6 +228,8 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
uint32_t const device_int_status = LPC_USB->USBDevIntSt & device_int_enable;
|
||||
LPC_USB->USBDevIntClr = device_int_status;// Acknowledge handled interrupt
|
||||
|
||||
dcd_event_t event = { .rhport = rhport };
|
||||
|
||||
//------------- usb bus event -------------//
|
||||
if (device_int_status & DEV_INT_DEVICE_STATUS_MASK)
|
||||
{
|
||||
@@ -232,24 +237,30 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
if (dev_status_reg & SIE_DEV_STATUS_RESET_MASK)
|
||||
{
|
||||
bus_reset();
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_RESET);
|
||||
|
||||
event.event_id = DCD_EVENT_BUS_RESET;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
|
||||
if (dev_status_reg & SIE_DEV_STATUS_CONNECT_CHANGE_MASK)
|
||||
{ // device is disconnected, require using VBUS (P1_30)
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_UNPLUGGED);
|
||||
event.event_id = DCD_EVENT_UNPLUGGED;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
|
||||
if (dev_status_reg & SIE_DEV_STATUS_SUSPEND_CHANGE_MASK)
|
||||
{
|
||||
if (dev_status_reg & SIE_DEV_STATUS_SUSPEND_MASK)
|
||||
{
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_SUSPENDED);
|
||||
event.event_id = DCD_EVENT_SUSPENDED;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// dcd_bus_event(0, USBD_BUS_EVENT_RESUME);
|
||||
// else
|
||||
// { // resume signal
|
||||
// event.event_id = DCD_EVENT_RESUME;
|
||||
// dcd_event_handler(&event, true);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,10 +418,14 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
|
||||
if (int_status == 0) return;// disabled interrupt sources
|
||||
|
||||
dcd_event_t event = { .rhport = rhport };
|
||||
|
||||
if (int_status & INT_MASK_RESET)
|
||||
{
|
||||
bus_reset(rhport);
|
||||
dcd_bus_event(rhport, USBD_BUS_EVENT_RESET);
|
||||
|
||||
event.event_id = DCD_EVENT_BUS_RESET;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
|
||||
if (int_status & INT_MASK_SUSPEND)
|
||||
@@ -430,7 +434,8 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
{ // Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
|
||||
if ((lpc_usb->DEVICEADDR >> 25) & 0x0f)
|
||||
{
|
||||
dcd_bus_event(0, USBD_BUS_EVENT_SUSPENDED);
|
||||
event.event_id = DCD_EVENT_SUSPENDED;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,7 +445,8 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
// {
|
||||
// if ( !(lpc_usb->PORTSC1_D & PORTSC_CURRENT_CONNECT_STATUS_MASK) )
|
||||
// {
|
||||
// dcd_bus_event(0, USBD_BUS_EVENT_UNPLUGGED);
|
||||
// event.event_id = DCD_EVENT_UNPLUGGED;
|
||||
// dcd_event_handler(&event, true);
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -457,7 +463,10 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
// 23.10.10.2 Operational model for setup transfers
|
||||
lpc_usb->ENDPTSETUPSTAT = lpc_usb->ENDPTSETUPSTAT;// acknowledge
|
||||
|
||||
dcd_setup_received(rhport, (uint8_t*) &p_dcd->qhd[0].setup_request);
|
||||
event.event_id = DCD_EVENT_SETUP_RECEIVED;
|
||||
event.setup_received = p_dcd->qhd[0].setup_request;
|
||||
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
|
||||
//------------- Control Request Completed -------------//
|
||||
@@ -487,7 +496,8 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
|
||||
if (int_status & INT_MASK_SOF)
|
||||
{
|
||||
dcd_bus_event(rhport, USBD_BUS_EVENT_SOF);
|
||||
event.event_id = DCD_EVENT_SOF;
|
||||
dcd_event_handler(&event, true);
|
||||
}
|
||||
|
||||
if (int_status & INT_MASK_NAK) {}
|
||||
|
||||
Reference in New Issue
Block a user