Merge remote-tracking branch 'official/master'
This commit is contained in:
@@ -24,10 +24,6 @@
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
/** \ingroup group_usbd
|
||||
* \defgroup group_dcd Device Controller Driver (DCD)
|
||||
* @{ */
|
||||
|
||||
#ifndef _TUSB_DCD_H_
|
||||
#define _TUSB_DCD_H_
|
||||
|
||||
@@ -168,5 +164,3 @@ extern void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t x
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_DCD_H_ */
|
||||
|
||||
/// @}
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// Device Data
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invalid driver ID in itf2drv[] ep2drv[][] mapping
|
||||
enum { DRVID_INVALID = 0xFFu };
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct TU_ATTR_PACKED
|
||||
@@ -76,9 +80,6 @@ typedef struct
|
||||
|
||||
static usbd_device_t _usbd_dev;
|
||||
|
||||
// Invalid driver ID in itf2drv[] ep2drv[][] mapping
|
||||
enum { DRVID_INVALID = 0xFFu };
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Class Driver
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -253,6 +254,8 @@ static inline usbd_class_driver_t const * get_driver(uint8_t drvid)
|
||||
// DCD Event
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static bool _usbd_initialized = false;
|
||||
|
||||
// Event queue
|
||||
// OPT_MODE_DEVICE is used by OS NONE for mutex (disable usb isr)
|
||||
OSAL_QUEUE_DEF(OPT_MODE_DEVICE, _usbd_qdef, CFG_TUD_TASK_QUEUE_SZ, dcd_event_t);
|
||||
@@ -380,8 +383,16 @@ bool tud_connect(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD Task
|
||||
//--------------------------------------------------------------------+
|
||||
bool tud_init (void)
|
||||
bool tud_inited(void)
|
||||
{
|
||||
return _usbd_initialized;
|
||||
}
|
||||
|
||||
bool tud_init (uint8_t rhport)
|
||||
{
|
||||
// skip if already initialized
|
||||
if (_usbd_initialized) return _usbd_initialized;
|
||||
|
||||
TU_LOG2("USBD init\r\n");
|
||||
|
||||
tu_varclr(&_usbd_dev);
|
||||
@@ -411,8 +422,10 @@ bool tud_init (void)
|
||||
}
|
||||
|
||||
// Init device controller driver
|
||||
dcd_init(TUD_OPT_RHPORT);
|
||||
dcd_int_enable(TUD_OPT_RHPORT);
|
||||
dcd_init(rhport);
|
||||
dcd_int_enable(rhport);
|
||||
|
||||
_usbd_initialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1089,7 +1102,7 @@ void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Helper
|
||||
// USBD API For Class Driver
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Parse consecutive endpoint descriptors (IN & OUT)
|
||||
@@ -1183,7 +1196,6 @@ bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr)
|
||||
#if CFG_TUSB_OS != OPT_OS_NONE
|
||||
// pre-check to help reducing mutex lock
|
||||
TU_VERIFY((_usbd_dev.ep_status[epnum][dir].busy == 0) && (_usbd_dev.ep_status[epnum][dir].claimed == 0));
|
||||
|
||||
osal_mutex_lock(_usbd_mutex, OSAL_TIMEOUT_WAIT_FOREVER);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -41,7 +41,10 @@ extern "C" {
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Init device stack
|
||||
bool tud_init (void);
|
||||
bool tud_init (uint8_t rhport);
|
||||
|
||||
// Check if device stack is already initialized
|
||||
bool tud_inited(void);
|
||||
|
||||
// Task function should be called in main/rtos loop
|
||||
void tud_task (void);
|
||||
@@ -67,6 +70,7 @@ bool tud_mounted(void);
|
||||
bool tud_suspended(void);
|
||||
|
||||
// Check if device is ready to transfer
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline bool tud_ready(void)
|
||||
{
|
||||
return tud_mounted() && !tud_suspended();
|
||||
|
||||
@@ -47,7 +47,7 @@ typedef struct
|
||||
void (* reset ) (uint8_t rhport);
|
||||
uint16_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t max_len);
|
||||
bool (* control_xfer_cb ) (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void (* sof ) (uint8_t rhport); /* optional */
|
||||
} usbd_class_driver_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user