mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-24 09:02:37 +00:00
added dcd_remote_wakeup() stub for all ports
This commit is contained in:
parent
cabf6abb4f
commit
b28cc6ddb1
@ -76,6 +76,9 @@ If your peripheral automatically changes address during enumeration (like the nr
|
|||||||
##### dcd_set_config
|
##### dcd_set_config
|
||||||
Called when the device received SET_CONFIG request, you can leave this empty if your peripheral does not require any specific action.
|
Called when the device received SET_CONFIG request, you can leave this empty if your peripheral does not require any specific action.
|
||||||
|
|
||||||
|
##### dcd_remote_wakeup
|
||||||
|
Called to remote wake up host when suspended (e.g hid keyboard)
|
||||||
|
|
||||||
#### Special events
|
#### Special events
|
||||||
You must let TinyUSB know when certain events occur so that it can continue its work. There are a few methods you can call to queue events for TinyUSB to process.
|
You must let TinyUSB know when certain events occur so that it can continue its work. There are a few methods you can call to queue events for TinyUSB to process.
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ void tud_set_self_powered(bool self_powered)
|
|||||||
bool tud_remote_wakeup(void)
|
bool tud_remote_wakeup(void)
|
||||||
{
|
{
|
||||||
// only wake up host if this feature is enabled
|
// only wake up host if this feature is enabled
|
||||||
if (_usbd_dev.remote_wakeup_en ) dcd_remote_wakeup(TUD_OPT_RHPORT);
|
if (_usbd_dev.suspended && _usbd_dev.remote_wakeup_en ) dcd_remote_wakeup(TUD_OPT_RHPORT);
|
||||||
|
|
||||||
return _usbd_dev.remote_wakeup_en;
|
return _usbd_dev.remote_wakeup_en;
|
||||||
}
|
}
|
||||||
|
@ -59,12 +59,19 @@ extern tud_desc_set_t tud_desc_set;
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Application API
|
// Application API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tud_mounted(void);
|
|
||||||
|
// Task function should be called in main/rtos loop
|
||||||
void tud_task (void);
|
void tud_task (void);
|
||||||
|
|
||||||
bool tud_remote_wakeup(void);
|
// Check if device is connected and configured
|
||||||
|
bool tud_mounted(void);
|
||||||
|
|
||||||
|
// Tell stack that device is self or bus powered (default = bus)
|
||||||
void tud_set_self_powered(bool self_powered);
|
void tud_set_self_powered(bool self_powered);
|
||||||
|
|
||||||
|
// Remote wake up host, only if suspended and enabled by host
|
||||||
|
bool tud_remote_wakeup(void);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Application Callbacks (WEAK is optional)
|
// Application Callbacks (WEAK is optional)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -110,6 +110,18 @@ 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
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Enable suspend to detect disconnection
|
||||||
|
// TODO need to distinguish Suspend vs Disconnect
|
||||||
|
USB->DEVICE.INTFLAG.reg = USB_DEVICE_INTENCLR_SUSPEND;
|
||||||
|
USB->DEVICE.INTENSET.reg |= USB_DEVICE_INTENSET_SUSPEND;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void dcd_remote_wakeup(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
@ -290,13 +302,14 @@ void maybe_transfer_complete(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USB_Handler(void) {
|
void USB_Handler(void)
|
||||||
uint32_t int_status = USB->DEVICE.INTFLAG.reg;
|
{
|
||||||
|
uint32_t int_status = USB->DEVICE.INTFLAG.reg & USB->DEVICE.INTENSET.reg;
|
||||||
|
|
||||||
/*------------- Interrupt Processing -------------*/
|
/*------------- Interrupt Processing -------------*/
|
||||||
if ( int_status & USB_DEVICE_INTFLAG_EORST )
|
if ( int_status & USB_DEVICE_INTFLAG_EORST )
|
||||||
{
|
{
|
||||||
USB->DEVICE.INTFLAG.reg = USB_DEVICE_INTENCLR_EORST;
|
USB->DEVICE.INTFLAG.reg = USB_DEVICE_INTFLAG_EORST;
|
||||||
bus_reset();
|
bus_reset();
|
||||||
dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET, true);
|
dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET, true);
|
||||||
}
|
}
|
||||||
@ -307,6 +320,21 @@ void USB_Handler(void) {
|
|||||||
dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
|
dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if ( int_status & USB_DEVICE_INTFLAG_SUSPEND )
|
||||||
|
{
|
||||||
|
USB->DEVICE.INTFLAG.reg = USB_DEVICE_INTFLAG_SUSPEND;
|
||||||
|
|
||||||
|
// disable interrupt to prevent it continue to trigger
|
||||||
|
USB->DEVICE.INTENCLR.reg = USB_DEVICE_INTENCLR_SUSPEND;
|
||||||
|
|
||||||
|
// TODO need to distinguish Suspend vs Disconnect
|
||||||
|
// reset address to 0, force host to re-enumerate after resume
|
||||||
|
USB->DEVICE.DADD.reg = 0;
|
||||||
|
dcd_event_bus_signal(0, DCD_EVENT_UNPLUGGED, true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Setup packet received.
|
// Setup packet received.
|
||||||
maybe_handle_setup_packet();
|
maybe_handle_setup_packet();
|
||||||
|
|
||||||
|
@ -117,6 +117,11 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
|||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcd_remote_wakeup(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* DCD Endpoint port
|
/* DCD Endpoint port
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
@ -216,6 +216,11 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
|||||||
NRF_USBD->INTENSET = USBD_INTEN_USBEVENT_Msk;
|
NRF_USBD->INTENSET = USBD_INTEN_USBEVENT_Msk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcd_remote_wakeup(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Endpoint API
|
// Endpoint API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -126,33 +126,6 @@ static inline uint8_t ep_addr2id(uint8_t endpoint_addr)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// CONTROLLER API
|
// CONTROLLER API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void dcd_int_enable(uint8_t rhport)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
NVIC_EnableIRQ(USB0_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dcd_int_disable(uint8_t rhport)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
NVIC_DisableIRQ(USB0_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dcd_set_config(uint8_t rhport, uint8_t config_num)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
(void) config_num;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
|
||||||
{
|
|
||||||
// Response with status first before changing device address
|
|
||||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
|
||||||
|
|
||||||
LPC_USB->DEVCMDSTAT &= ~CMDSTAT_DEVICE_ADDR_MASK;
|
|
||||||
LPC_USB->DEVCMDSTAT |= dev_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport)
|
void dcd_init(uint8_t rhport)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
@ -165,9 +138,41 @@ void dcd_init(uint8_t rhport)
|
|||||||
LPC_USB->DEVCMDSTAT |= CMDSTAT_DEVICE_ENABLE_MASK | CMDSTAT_DEVICE_CONNECT_MASK |
|
LPC_USB->DEVCMDSTAT |= CMDSTAT_DEVICE_ENABLE_MASK | CMDSTAT_DEVICE_CONNECT_MASK |
|
||||||
CMDSTAT_RESET_CHANGE_MASK | CMDSTAT_CONNECT_CHANGE_MASK | CMDSTAT_SUSPEND_CHANGE_MASK;
|
CMDSTAT_RESET_CHANGE_MASK | CMDSTAT_CONNECT_CHANGE_MASK | CMDSTAT_SUSPEND_CHANGE_MASK;
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ(USB0_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
NVIC_EnableIRQ(USB0_IRQn);
|
NVIC_EnableIRQ(USB0_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcd_int_disable(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
NVIC_DisableIRQ(USB0_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||||
|
{
|
||||||
|
// Response with status first before changing device address
|
||||||
|
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||||
|
|
||||||
|
LPC_USB->DEVCMDSTAT &= ~CMDSTAT_DEVICE_ADDR_MASK;
|
||||||
|
LPC_USB->DEVCMDSTAT |= dev_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dcd_set_config(uint8_t rhport, uint8_t config_num)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
(void) config_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dcd_remote_wakeup(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// DCD Endpoint Port
|
// DCD Endpoint Port
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -185,7 +185,6 @@ void dcd_init(uint8_t rhport)
|
|||||||
|
|
||||||
// USB IRQ priority should be set by application previously
|
// USB IRQ priority should be set by application previously
|
||||||
NVIC_ClearPendingIRQ(USB_IRQn);
|
NVIC_ClearPendingIRQ(USB_IRQn);
|
||||||
NVIC_EnableIRQ(USB_IRQn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
@ -215,6 +214,11 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num)
|
|||||||
sie_write(SIE_CMDCODE_CONFIGURE_DEVICE, 1, 1);
|
sie_write(SIE_CMDCODE_CONFIGURE_DEVICE, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcd_remote_wakeup(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// CONTROL HELPER
|
// CONTROL HELPER
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -161,6 +161,11 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num)
|
|||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcd_remote_wakeup(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HELPER
|
// HELPER
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -55,6 +55,14 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
|||||||
void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void dcd_remote_wakeup(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Endpoint API
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
|
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -194,6 +194,11 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
|||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcd_remote_wakeup(uint8_t rhport)
|
||||||
|
{
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* DCD Endpoint port
|
/* DCD Endpoint port
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user