allow tusb_init() to call multiple times
enhance nrf5x
This commit is contained in:
@@ -41,8 +41,14 @@
|
||||
#include "tusb.h"
|
||||
#include "device/usbd_pvt.h"
|
||||
|
||||
static bool _initialized = false;
|
||||
|
||||
|
||||
tusb_error_t tusb_init(void)
|
||||
{
|
||||
// skip if already initialized
|
||||
if (_initialized) return TUSB_ERROR_NONE;
|
||||
|
||||
VERIFY( tusb_hal_init(), TUSB_ERROR_FAILED ) ; // hardware init
|
||||
|
||||
#if MODE_HOST_SUPPORTED
|
||||
@@ -53,6 +59,8 @@ tusb_error_t tusb_init(void)
|
||||
TU_ASSERT_ERR ( usbd_init() ); // device stack init
|
||||
#endif
|
||||
|
||||
_initialized = true;
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user