mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-21 21:41:09 +00:00
added Suspend and Resume event for nrf5x port
also rename DCD_EVENT_SUSPENDED to DCD_EVENT_SUSPEND
This commit is contained in:
parent
8fb9fbb0b1
commit
0bdd4bd550
@ -265,6 +265,7 @@ void hidd_init(void)
|
|||||||
|
|
||||||
void hidd_reset(uint8_t rhport)
|
void hidd_reset(uint8_t rhport)
|
||||||
{
|
{
|
||||||
|
(void) rhport;
|
||||||
tu_memclr(_hidd_itf, sizeof(_hidd_itf));
|
tu_memclr(_hidd_itf, sizeof(_hidd_itf));
|
||||||
|
|
||||||
#if CFG_TUD_HID_KEYBOARD
|
#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)
|
// 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)
|
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 );
|
hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) p_request->wIndex );
|
||||||
TU_ASSERT(p_hid);
|
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)
|
bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes)
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
|
(void) rhport;
|
||||||
|
(void) ep_addr;
|
||||||
|
(void) event;
|
||||||
|
(void) xferred_bytes;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ typedef enum
|
|||||||
DCD_EVENT_BUS_RESET = 1,
|
DCD_EVENT_BUS_RESET = 1,
|
||||||
DCD_EVENT_UNPLUGGED,
|
DCD_EVENT_UNPLUGGED,
|
||||||
DCD_EVENT_SOF,
|
DCD_EVENT_SOF,
|
||||||
DCD_EVENT_SUSPENDED,
|
DCD_EVENT_SUSPEND,
|
||||||
DCD_EVENT_RESUME,
|
DCD_EVENT_RESUME,
|
||||||
|
|
||||||
DCD_EVENT_SETUP_RECEIVED,
|
DCD_EVENT_SETUP_RECEIVED,
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
// Device Data
|
// Device Data
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
typedef struct {
|
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 itf2drv[16]; // map interface number to driver (0xff is invalid)
|
||||||
uint8_t ep2drv[8][2]; // map endpoint 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
|
// nothing to do now
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DCD_EVENT_SUSPENDED:
|
case DCD_EVENT_SUSPEND:
|
||||||
// TODO support suspended
|
// TODO support suspended
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -207,6 +207,13 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
|||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) config_num;
|
(void) config_num;
|
||||||
// Nothing to do
|
// 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 )
|
if ( int_status & USBD_INTEN_USBRESET_Msk )
|
||||||
{
|
{
|
||||||
bus_reset();
|
bus_reset();
|
||||||
dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET, true);
|
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 )
|
if ( int_status & EDPT_END_ALL_MASK )
|
||||||
{
|
{
|
||||||
// DMA complete move data from SRAM -> Endpoint
|
// 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
|
#endif
|
||||||
|
@ -212,8 +212,8 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
|||||||
|
|
||||||
nrf_usbd_isosplit_set(USBD_ISOSPLIT_SPLIT_HalfIN);
|
nrf_usbd_isosplit_set(USBD_ISOSPLIT_SPLIT_HalfIN);
|
||||||
|
|
||||||
// Enable interrupt. SOF is used as CDC auto flush
|
// Enable interrupt
|
||||||
NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_USBEVENT_Msk | USBD_INTEN_EPDATA_Msk |
|
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;
|
USBD_INTEN_EP0SETUP_Msk | USBD_INTEN_EP0DATADONE_Msk | USBD_INTEN_ENDEPIN0_Msk | USBD_INTEN_ENDEPOUT0_Msk;
|
||||||
|
|
||||||
// Enable interrupt, priorities should be set by application
|
// Enable interrupt, priorities should be set by application
|
||||||
|
@ -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.
|
// 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)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,7 @@ static void bus_event_isr(uint8_t rhport)
|
|||||||
{
|
{
|
||||||
if (dev_status & SIE_DEV_STATUS_SUSPEND_MASK)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -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.
|
// Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
|
||||||
if ((lpc_usb->DEVICEADDR >> 25) & 0x0f)
|
if ((lpc_usb->DEVICEADDR >> 25) & 0x0f)
|
||||||
{
|
{
|
||||||
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPENDED, true);
|
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user