diff options
| author | hathach <[email protected]> | 2021-05-02 01:46:22 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-05-18 12:58:24 +0700 |
| commit | 2666e1efec20d78f8f74c23cdbb7977737b8d956 (patch) | |
| tree | 6ab8a02da835daf4065260513992c9ac342fa64a /src/host | |
| parent | 68fa17e17ca900ec2800c55c9345a2a0fed3fca9 (diff) | |
add tuh_inited() and tud_inited()
Diffstat (limited to 'src/host')
| -rw-r--r-- | src/host/usbh.c | 14 | ||||
| -rw-r--r-- | src/host/usbh.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c index 86da97bb8..411945fdb 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -121,6 +121,8 @@ enum { CONFIG_NUM = 1 }; // default to use configuration 1 // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ +static bool _initialized = false; + // including zero-address CFG_TUSB_MEM_SECTION usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1]; @@ -170,8 +172,19 @@ void osal_task_delay(uint32_t msec) //--------------------------------------------------------------------+ // CLASS-USBD API (don't require to verify parameters) //--------------------------------------------------------------------+ + +bool tuh_inited(void) +{ + return _initialized; +} + bool tuh_init(void) { + // skip if already initialized + if (_initialized) return _initialized; + + TU_LOG2("USBH init\r\n"); + tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1)); //------------- Enumeration & Reporter Task init -------------// @@ -202,6 +215,7 @@ bool tuh_init(void) TU_ASSERT(hcd_init(TUH_OPT_RHPORT)); hcd_int_enable(TUH_OPT_RHPORT); + _initialized = true; return true; } diff --git a/src/host/usbh.h b/src/host/usbh.h index a05010b36..732a4b66e 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -78,6 +78,9 @@ typedef bool (*tuh_control_complete_cb_t)(uint8_t dev_addr, tusb_control_request // Init host stack bool tuh_init(void); +// Check if host stack is already initialized +bool tuh_inited(void); + // Task function should be called in main/rtos loop void tuh_task(void); |
