diff options
| author | hathach <[email protected]> | 2018-07-05 00:23:47 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-07-05 00:23:47 +0700 |
| commit | 40de723d417e253e3346b58cd2ce8b5dbf60d0ac (patch) | |
| tree | ec70e81df9043057f9bf581e17b230c13fb37d1f /src/tusb.c | |
| parent | fc139b009f4c49d4fdbf1b80097c94c8dabb1ee1 (diff) | |
allow tusb_init() to call multiple times
enhance nrf5x
Diffstat (limited to 'src/tusb.c')
| -rw-r--r-- | src/tusb.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/tusb.c b/src/tusb.c index dd3be72e4..fde29c24f 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -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;
}
|
