allow no mode compilation (no host/device enabled). Handy for project without usb to compile such as nrf52832

This commit is contained in:
hathach 2018-08-30 16:12:34 +07:00
parent e623fc656d
commit dce2296756
3 changed files with 15 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -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
//--------------------------------------------------------------------