diff options
| author | hathach <[email protected]> | 2018-12-05 17:30:04 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-12-05 17:30:04 +0700 |
| commit | d887829b4c088e14d8e528b3afb6f5fc894c49d9 (patch) | |
| tree | 9fbd20356baf7d86625b4d12ecba2d119b452f29 /src | |
| parent | 3dc0653d702e5e6b50e6a256d613ab7323561d94 (diff) | |
change usbd_init() return to bool for simplicity
Diffstat (limited to 'src')
| -rw-r--r-- | src/device/usbd.c | 8 | ||||
| -rw-r--r-- | src/device/usbd_pvt.h | 4 | ||||
| -rw-r--r-- | src/host/usbh.h | 3 | ||||
| -rw-r--r-- | src/tusb.c | 8 | ||||
| -rw-r--r-- | src/tusb.h | 10 |
5 files changed, 14 insertions, 19 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index 206b663c0..78eebf76b 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -189,11 +189,11 @@ bool tud_mounted(void) //--------------------------------------------------------------------+
// USBD Task
//--------------------------------------------------------------------+
-tusb_error_t usbd_init (void)
+bool usbd_init (void)
{
// Init device queue & task
_usbd_q = osal_queue_create(&_usbd_qdef);
- TU_VERIFY(_usbd_q, TUSB_ERROR_OSAL_QUEUE_FAILED);
+ TU_ASSERT(_usbd_q != NULL);
osal_task_create(&_usbd_task_def);
@@ -201,10 +201,10 @@ tusb_error_t usbd_init (void) for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++) usbd_class_drivers[i].init();
// Init device controller driver
- dcd_init(TUD_OPT_RHPORT);
+ TU_ASSERT(dcd_init(TUD_OPT_RHPORT));
dcd_int_enable(TUD_OPT_RHPORT);
- return TUSB_ERROR_NONE;
+ return true;
}
static void usbd_reset(uint8_t rhport)
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index 30f010887..cbe5017bb 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -51,8 +51,8 @@ extern tud_desc_set_t const* usbd_desc_set; //--------------------------------------------------------------------+ // INTERNAL API for stack management //--------------------------------------------------------------------+ -tusb_error_t usbd_init (void); -void usbd_task (void* param); +bool usbd_init (void); +void usbd_task (void* param); // Carry out Data and Status stage of control transfer diff --git a/src/host/usbh.h b/src/host/usbh.h index 22fdef162..56efb6ff7 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -97,14 +97,11 @@ ATTR_WEAK void tuh_device_mount_failed_cb(tusb_error_t error, tusb_desc_devic //--------------------------------------------------------------------+ #ifdef _TINY_USB_SOURCE_FILE_ - void usbh_enumeration_task(void* param); tusb_error_t usbh_init(void); tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength, uint8_t* data); - - #endif #ifdef __cplusplus diff --git a/src/tusb.c b/src/tusb.c index 81c4907fb..fe4dbb2c1 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -47,17 +47,17 @@ static bool _initialized = false;
-tusb_error_t tusb_init(void)
+bool tusb_init(void)
{
// skip if already initialized
- if (_initialized) return TUSB_ERROR_NONE;
+ if (_initialized) return true;
#if MODE_HOST_SUPPORTED
- TU_ASSERT_ERR( usbh_init() ); // host stack init
+ TU_VERIFY( usbh_init() == TUSB_ERROR_NONE ); // init host stack
#endif
#if TUSB_OPT_DEVICE_ENABLED
- TU_ASSERT_ERR ( usbd_init() ); // device stack init
+ TU_VERIFY ( usbd_init() ); // init device stack
#endif
_initialized = true;
diff --git a/src/tusb.h b/src/tusb.h index c0246ccc8..4f8918ce5 100644 --- a/src/tusb.h +++ b/src/tusb.h @@ -101,16 +101,14 @@ /** \ingroup group_application_api
* @{ */
-/** \brief Initialize the usb stack
- * \return Error Code of the \ref TUSB_ERROR enum
- * \note Function will initialize the stack according to configuration in the configure file (tusb_config.h)
- */
-tusb_error_t tusb_init(void);
+// Initialize device/host stack according to tusb_config.h
+// return true if success
+bool tusb_init(void);
#if CFG_TUSB_OS == OPT_OS_NONE
/** \brief Run all tinyusb's internal tasks (e.g host task, device task).
* \note This function is only required when using no RTOS (\ref CFG_TUSB_OS == OPT_OS_NONE). All the stack functions
- * & callback are invoked within this function, so it should be called periodically within the mainloop
+ * & callback are invoked within this function. This should be called periodically within the mainloop
*
@code
int main(void)
|
