diff options
| author | hathach <[email protected]> | 2018-08-30 16:12:34 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-08-30 16:12:34 +0700 |
| commit | dce2296756c44b6c49e7681401f48472ba6d213d (patch) | |
| tree | 8db356a9a70d050904e4fd1f051185c6326ce84e /src | |
| parent | e623fc656d4973ca32b8c9547409e65e12ad9b4c (diff) | |
allow no mode compilation (no host/device enabled). Handy for project without usb to compile such as nrf52832
Diffstat (limited to 'src')
| -rw-r--r-- | src/device/usbd_auto_desc.c | 8 | ||||
| -rw-r--r-- | src/tusb.c | 13 | ||||
| -rw-r--r-- | src/tusb_option.h | 25 |
3 files changed, 15 insertions, 31 deletions
diff --git a/src/device/usbd_auto_desc.c b/src/device/usbd_auto_desc.c index 22c66a38a..2d54a934d 100644 --- a/src/device/usbd_auto_desc.c +++ b/src/device/usbd_auto_desc.c @@ -38,13 +38,10 @@ #include "tusb_option.h" -#if TUSB_OPT_DEVICE_ENABLED - +#if TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DESC_AUTO #include "tusb.h" -#if CFG_TUD_DESC_AUTO - //--------------------------------------------------------------------+ // Auto Description Default Configure & Validation //--------------------------------------------------------------------+ @@ -634,6 +631,3 @@ tud_desc_set_t const _usbd_auto_desc_set = }; #endif - - -#endif diff --git a/src/tusb.c b/src/tusb.c index b064d03f9..e9db184f2 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -36,6 +36,10 @@ */
/**************************************************************************/
+#include "tusb_option.h"
+
+#if TUSB_OPT_HOST_ENABLED || TUSB_OPT_DEVICE_ENABLED
+
#define _TINY_USB_SOURCE_FILE_
#include "tusb.h"
@@ -82,10 +86,7 @@ void tusb_task(void) /* Debug
*------------------------------------------------------------------*/
#if CFG_TUSB_DEBUG
-
-char const* const tusb_strerr[TUSB_ERROR_COUNT] =
-{
- ERROR_TABLE(ERROR_STRING)
-};
-
+char const* const tusb_strerr[TUSB_ERROR_COUNT] = { ERROR_TABLE(ERROR_STRING) };
#endif
+
+#endif // host or device enabled
diff --git a/src/tusb_option.h b/src/tusb_option.h index efb180c3a..22b78453c 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -100,17 +100,16 @@ ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) ? 1 : 0) + \
((CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST) ? 1 : 0))
-#define CONTROLLER_DEVICE_NUMBER (\
- ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) ? 1 : 0) + \
- ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) ? 1 : 0))
+#define MODE_HOST_SUPPORTED (CONTROLLER_HOST_NUMBER > 0)
-#define MODE_HOST_SUPPORTED (CONTROLLER_HOST_NUMBER > 0)
-#define TUSB_OPT_DEVICE_ENABLED (CONTROLLER_DEVICE_NUMBER > 0)
+#define TUH_OPT_RHPORT ( (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) ? 0 : ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST) ? 1 : -1) )
+#define TUSB_OPT_HOST_ENABLED ( TUH_OPT_RHPORT >= 0 )
-#define TUD_OPT_RHPORT ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) ? 0 : ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) ? 1 : -1))
+#define TUD_OPT_RHPORT ( (CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) ? 0 : ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) ? 1 : -1) )
+#define TUSB_OPT_DEVICE_ENABLED ( TUD_OPT_RHPORT >= 0 )
-#if !MODE_HOST_SUPPORTED && !TUSB_OPT_DEVICE_ENABLED
- #error please configure at least 1 CFG_TUSB_CONTROLLER_N_MODE to OPT_MODE_HOST and/or OPT_MODE_DEVICE
+#if ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST)) || ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE))
+ #error "tinyusb does not support same modes on more than 1 roothub port"
#endif
//--------------------------------------------------------------------+
@@ -136,16 +135,6 @@ #define CFG_TUSB_OS OPT_OS_NONE
#endif
-
-#ifndef tu_malloc
-#include <stdlib.h>
-#define tu_malloc malloc
-#endif
-
-#ifndef tu_free
-#define tu_free free
-#endif
-
//--------------------------------------------------------------------
// DEVICE OPTIONS
//--------------------------------------------------------------------
|
