mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-10 21:44:24 +00:00
Add optional hooks for DCD and HCD events
These are intended to allow bare metal platforms with one-shot scheduling capabilities to schedule the TinyUSB task handlers whenever they know there is work for them to do. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
parent
08f9ed67c9
commit
68894398af
@ -1079,6 +1079,7 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
||||||
{
|
{
|
||||||
|
bool send = false;
|
||||||
switch (event->event_id)
|
switch (event->event_id)
|
||||||
{
|
{
|
||||||
case DCD_EVENT_UNPLUGGED:
|
case DCD_EVENT_UNPLUGGED:
|
||||||
@ -1086,7 +1087,7 @@ TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
|||||||
_usbd_dev.addressed = 0;
|
_usbd_dev.addressed = 0;
|
||||||
_usbd_dev.cfg_num = 0;
|
_usbd_dev.cfg_num = 0;
|
||||||
_usbd_dev.suspended = 0;
|
_usbd_dev.suspended = 0;
|
||||||
osal_queue_send(_usbd_q, event, in_isr);
|
send = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DCD_EVENT_SUSPEND:
|
case DCD_EVENT_SUSPEND:
|
||||||
@ -1097,7 +1098,7 @@ TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
|||||||
if ( _usbd_dev.connected )
|
if ( _usbd_dev.connected )
|
||||||
{
|
{
|
||||||
_usbd_dev.suspended = 1;
|
_usbd_dev.suspended = 1;
|
||||||
osal_queue_send(_usbd_q, event, in_isr);
|
send = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1106,7 +1107,7 @@ TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
|||||||
if ( _usbd_dev.connected )
|
if ( _usbd_dev.connected )
|
||||||
{
|
{
|
||||||
_usbd_dev.suspended = 0;
|
_usbd_dev.suspended = 0;
|
||||||
osal_queue_send(_usbd_q, event, in_isr);
|
send = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1129,15 +1130,21 @@ TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
|||||||
|
|
||||||
dcd_event_t const event_resume = { .rhport = event->rhport, .event_id = DCD_EVENT_RESUME };
|
dcd_event_t const event_resume = { .rhport = event->rhport, .event_id = DCD_EVENT_RESUME };
|
||||||
osal_queue_send(_usbd_q, &event_resume, in_isr);
|
osal_queue_send(_usbd_q, &event_resume, in_isr);
|
||||||
|
CFG_TUD_EVENT_HOOK(&event_resume, in_isr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip osal queue for SOF in usbd task
|
// skip osal queue for SOF in usbd task
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
osal_queue_send(_usbd_q, event, in_isr);
|
send = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (send) {
|
||||||
|
osal_queue_send(_usbd_q, event, in_isr);
|
||||||
|
CFG_TUD_EVENT_HOOK(event, in_isr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -780,6 +780,7 @@ void usbh_defer_func(osal_task_func_t func, void *param, bool in_isr) {
|
|||||||
event.func_call.param = param;
|
event.func_call.param = param;
|
||||||
|
|
||||||
osal_queue_send(_usbh_q, &event, in_isr);
|
osal_queue_send(_usbh_q, &event, in_isr);
|
||||||
|
CFG_TUH_EVENT_HOOK(event, in_isr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@ -936,6 +937,7 @@ TU_ATTR_FAST_FUNC void hcd_event_handler(hcd_event_t const* event, bool in_isr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
osal_queue_send(_usbh_q, event, in_isr);
|
osal_queue_send(_usbh_q, event, in_isr);
|
||||||
|
CFG_TUH_EVENT_HOOK(event, in_isr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -485,6 +485,18 @@
|
|||||||
#define tuc_int_handler(_p)
|
#define tuc_int_handler(_p)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Optional event hook functions for platform integration (defaults)
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
#ifndef CFG_TUD_EVENT_HOOK
|
||||||
|
#define CFG_TUD_EVENT_HOOK(EVENT, IN_ISR)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CFG_TUH_EVENT_HOOK
|
||||||
|
#define CFG_TUH_EVENT_HOOK(EVENT, IN_ISR)
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Configuration Validation
|
// Configuration Validation
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user