summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-03-29 01:34:53 +0700
committerhathach <[email protected]>2019-03-29 01:34:53 +0700
commit0bdd4bd55002c4563154214a4d57581433cae668 (patch)
tree7425d94bf510cc944f93fa21959abb344d4f505f /src
parent8fb9fbb0b19de3422645e65fbd422c86cb548c62 (diff)
added Suspend and Resume event for nrf5x port
also rename DCD_EVENT_SUSPENDED to DCD_EVENT_SUSPEND
Diffstat (limited to 'src')
-rw-r--r--src/class/hid/hid_device.c7
-rw-r--r--src/device/dcd.h2
-rw-r--r--src/device/usbd.c4
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c36
-rw-r--r--src/portable/nordic/nrf5x/hal_nrf5x.c4
-rw-r--r--src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c2
-rw-r--r--src/portable/nxp/lpc17_40/dcd_lpc17_40.c2
-rw-r--r--src/portable/nxp/lpc18_43/dcd_lpc18_43.c2
8 files changed, 44 insertions, 15 deletions
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c
index 3a20a9cc8..765ee042e 100644
--- a/src/class/hid/hid_device.c
+++ b/src/class/hid/hid_device.c
@@ -265,6 +265,7 @@ void hidd_init(void)
void hidd_reset(uint8_t rhport)
{
+ (void) rhport;
tu_memclr(_hidd_itf, sizeof(_hidd_itf));
#if CFG_TUD_HID_KEYBOARD
@@ -447,6 +448,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
// return false to stall control endpoint (e.g Host send non-sense DATA)
bool hidd_control_request_complete(uint8_t rhport, tusb_control_request_t const * p_request)
{
+ (void) rhport;
hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) p_request->wIndex );
TU_ASSERT(p_hid);
@@ -469,6 +471,11 @@ bool hidd_control_request_complete(uint8_t rhport, tusb_control_request_t const
bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes)
{
// nothing to do
+ (void) rhport;
+ (void) ep_addr;
+ (void) event;
+ (void) xferred_bytes;
+
return true;
}
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 186c4af0c..9abebc2af 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -42,7 +42,7 @@ typedef enum
DCD_EVENT_BUS_RESET = 1,
DCD_EVENT_UNPLUGGED,
DCD_EVENT_SOF,
- DCD_EVENT_SUSPENDED,
+ DCD_EVENT_SUSPEND,
DCD_EVENT_RESUME,
DCD_EVENT_SETUP_RECEIVED,
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 58c0d3c4d..933e0f846 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -40,7 +40,7 @@
// Device Data
//--------------------------------------------------------------------+
typedef struct {
- volatile uint8_t config_num;
+ volatile uint8_t config_num; // 0 is non-configure ~ disconnect
uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid)
uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid )
@@ -555,7 +555,7 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
// nothing to do now
break;
- case DCD_EVENT_SUSPENDED:
+ case DCD_EVENT_SUSPEND:
// TODO support suspended
break;
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index 3c2b6d45b..928ef6713 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -207,6 +207,13 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
(void) rhport;
(void) config_num;
// Nothing to do
+
+ // Clear current pending
+ NRF_USBD->EVENTCAUSE |= NRF_USBD->EVENTCAUSE;
+ NRF_USBD->EVENTS_USBEVENT = 0;
+
+ // Enable usb event for suspend and resume
+ NRF_USBD->INTENSET = USBD_INTEN_USBEVENT_Msk;
}
//--------------------------------------------------------------------+
@@ -358,13 +365,34 @@ void USBD_IRQHandler(void)
}
}
- /*------------- Interrupt Processing -------------*/
if ( int_status & USBD_INTEN_USBRESET_Msk )
{
bus_reset();
dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET, true);
}
+ if ( int_status & USBD_INTEN_SOF_Msk )
+ {
+ dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
+ }
+
+ if ( int_status & USBD_INTEN_USBEVENT_Msk )
+ {
+ uint32_t const evt_cause = NRF_USBD->EVENTCAUSE;
+
+ if ( evt_cause & USBD_EVENTCAUSE_SUSPEND_Msk )
+ {
+ dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
+ }
+
+ if ( evt_cause & USBD_EVENTCAUSE_RESUME_Msk )
+ {
+ dcd_event_bus_signal(0, DCD_EVENT_RESUME , true);
+ }
+
+ NRF_USBD->EVENTCAUSE = evt_cause; // clear interrupt
+ }
+
if ( int_status & EDPT_END_ALL_MASK )
{
// DMA complete move data from SRAM -> Endpoint
@@ -502,12 +530,6 @@ void USBD_IRQHandler(void)
}
}
}
-
- // SOF interrupt
- if ( int_status & USBD_INTEN_SOF_Msk )
- {
- dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
- }
}
#endif
diff --git a/src/portable/nordic/nrf5x/hal_nrf5x.c b/src/portable/nordic/nrf5x/hal_nrf5x.c
index 8477a56cd..730b580b4 100644
--- a/src/portable/nordic/nrf5x/hal_nrf5x.c
+++ b/src/portable/nordic/nrf5x/hal_nrf5x.c
@@ -212,8 +212,8 @@ void tusb_hal_nrf_power_event (uint32_t event)
nrf_usbd_isosplit_set(USBD_ISOSPLIT_SPLIT_HalfIN);
- // Enable interrupt. SOF is used as CDC auto flush
- NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_USBEVENT_Msk | USBD_INTEN_EPDATA_Msk |
+ // Enable interrupt
+ NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_EPDATA_Msk |
USBD_INTEN_EP0SETUP_Msk | USBD_INTEN_EP0DATADONE_Msk | USBD_INTEN_ENDEPIN0_Msk | USBD_INTEN_ENDEPOUT0_Msk;
// Enable interrupt, priorities should be set by application
diff --git a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c
index 65b345957..0b0c10bc3 100644
--- a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c
+++ b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c
@@ -339,7 +339,7 @@ void USB_IRQHandler(void)
// 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_event_bus_signal(0, DCD_EVENT_SUSPENDED, true);
+ dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
}
}
}
diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
index f18a91b1c..ea95918ae 100644
--- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
@@ -481,7 +481,7 @@ static void bus_event_isr(uint8_t rhport)
{
if (dev_status & SIE_DEV_STATUS_SUSPEND_MASK)
{
- dcd_event_bus_signal(rhport, DCD_EVENT_SUSPENDED, true);
+ dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
}
else
{
diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
index a92a1c7b1..9be1af679 100644
--- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
+++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
@@ -303,7 +303,7 @@ 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_event_bus_signal(rhport, DCD_EVENT_SUSPENDED, true);
+ dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
}
}
}