summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-04 17:07:14 +0700
committerhathach <[email protected]>2013-03-04 17:07:14 +0700
commite1033b9b3c10a75fece0c2c398f5ed3f4b08d174 (patch)
tree46187ad8c70499817072700c268a5632ad5bf46c /tinyusb
parent94c004724ccbe2b74af74fc1753184f6b3ccb9cf (diff)
replace TUSB_CFG_HOST by MODE_HOST_SUPPORTED
move stuffs around
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/class/hid_host.c2
-rw-r--r--tinyusb/host/ehci/ehci.c2
-rw-r--r--tinyusb/host/hcd.c2
-rw-r--r--tinyusb/host/usbh.c2
-rw-r--r--tinyusb/mcu_capacity.h11
-rw-r--r--tinyusb/tusb.c2
-rw-r--r--tinyusb/tusb.h8
-rw-r--r--tinyusb/tusb_option.h31
8 files changed, 33 insertions, 27 deletions
diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c
index 56f8cf56b..fb4f4d230 100644
--- a/tinyusb/class/hid_host.c
+++ b/tinyusb/class/hid_host.c
@@ -37,7 +37,7 @@
#include "tusb_option.h"
-#if defined TUSB_CFG_HOST && defined HOST_CLASS_HID
+#if (MODE_HOST_SUPPORTED && defined HOST_CLASS_HID)
#define _TINY_USB_SOURCE_FILE_
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index 4c55065cc..c3fda3f3d 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -37,7 +37,7 @@
#include "common/common.h"
-#if defined TUSB_CFG_HOST && (MCU == MCU_LPC43XX || MCU == MCU_LPC18XX)
+#if MODE_HOST_SUPPORTED && (MCU == MCU_LPC43XX || MCU == MCU_LPC18XX)
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
diff --git a/tinyusb/host/hcd.c b/tinyusb/host/hcd.c
index ad72d49c1..e81809c87 100644
--- a/tinyusb/host/hcd.c
+++ b/tinyusb/host/hcd.c
@@ -37,7 +37,7 @@
#include "hcd.h"
-#ifdef TUSB_CFG_HOST
+#if MODE_HOST_SUPPORTED
#endif
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index 4a63727b1..08adecf15 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -37,7 +37,7 @@
#include "common/common.h"
-#ifdef TUSB_CFG_HOST
+#if MODE_HOST_SUPPORTED
#define _TINY_USB_SOURCE_FILE_
diff --git a/tinyusb/mcu_capacity.h b/tinyusb/mcu_capacity.h
index b851ca44a..8e05edcaf 100644
--- a/tinyusb/mcu_capacity.h
+++ b/tinyusb/mcu_capacity.h
@@ -78,17 +78,6 @@
#define CAP_MODE_HOST
#endif
-#define CONTROLLER_HOST_NUMBER (\
- (TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_HOST) ? 1 : 0\
- +(TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST) ? 1 : 0)
-
-#define CONTROLLER_DEVICE_NUMBER (\
- (TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_DEVICE) ? 1 : 0\
- +(TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_DEVICE) ? 1 : 0)
-
-#define MODE_HOST (CONTROLLER_HOST_NUMBER > 0)
-#define MODE_DEVICE (CONTROLLER_DEVICE_NUMBER > 0)
-
//--------------------------------------------------------------------+
// Validation
//--------------------------------------------------------------------+
diff --git a/tinyusb/tusb.c b/tinyusb/tusb.c
index b45c7b601..49f8ef253 100644
--- a/tinyusb/tusb.c
+++ b/tinyusb/tusb.c
@@ -43,7 +43,7 @@ tusb_error_t tusb_init(void)
{
ASSERT_STATUS( hal_init() ) ; // hardware init
-#ifdef TUSB_CFG_HOST
+#if MODE_HOST_SUPPORTED
ASSERT_STATUS( usbh_init() ); // host stack init
#endif
diff --git a/tinyusb/tusb.h b/tinyusb/tusb.h
index 1129fec6a..8bc4d7af4 100644
--- a/tinyusb/tusb.h
+++ b/tinyusb/tusb.h
@@ -52,7 +52,7 @@
#include "hal/hal.h"
#include "osal/osal.h"
-#ifdef TUSB_CFG_HOST
+#if MODE_HOST_SUPPORTED
#include "host/usbh.h"
#ifdef HOST_CLASS_HID
@@ -60,7 +60,7 @@
#endif
#endif
-#ifdef TUSB_CFG_DEVICE
+#if MODE_DEVICE_SUPPORTED
#include "device/dcd.h"
#if DEVICE_CLASS_HID
@@ -72,9 +72,7 @@
#endif
#endif
-#if !(defined TUSB_CFG_HOST) && !(defined TUSB_CFG_DEVICE)
- #error please enable either TUSB_CFG_HOST or TUSB_CFG_DEVICE
-#endif
+
tusb_error_t tusb_init(void);
diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h
index 3b1830419..274e4e0f9 100644
--- a/tinyusb/tusb_option.h
+++ b/tinyusb/tusb_option.h
@@ -64,11 +64,30 @@
#include "mcu_capacity.h"
//--------------------------------------------------------------------+
+// CONTROLLER
+//--------------------------------------------------------------------+
+#define TUSB_MODE_HOST 0x02
+#define TUSB_MODE_DEVICE 0x01
+#define TUSB_MODE_NONE 0x00
+
+#define CONTROLLER_HOST_NUMBER (\
+ ((TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_HOST) ? 1 : 0) + \
+ ((TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST) ? 1 : 0))
+
+#define CONTROLLER_DEVICE_NUMBER (\
+ ((TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_DEVICE) ? 1 : 0) + \
+ ((TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_DEVICE) ? 1 : 0))
+
+#define MODE_HOST_SUPPORTED (CONTROLLER_HOST_NUMBER > 0)
+#define MODE_DEVICE_SUPPORTED (CONTROLLER_DEVICE_NUMBER > 0)
+
+#if !MODE_HOST_SUPPORTED && !MODE_DEVICE_SUPPORTED
+ #error please configure at least 1 TUSB_CFG_CONTROLLERn_MODE to TUSB_MODE_HOST and/or TUSB_MODE_DEVICE
+#endif
+
+//--------------------------------------------------------------------+
// COMMON OPTIONS
//--------------------------------------------------------------------+
-#define TUSB_MODE_HOST BIN8(10)
-#define TUSB_MODE_DEVICE BIN8(01)
-#define TUSB_MODE_NONE BIN8(00)
/// 0: no debug information 3: most debug information provided
#ifndef TUSB_CFG_DEBUG
@@ -97,9 +116,7 @@
//--------------------------------------------------------------------+
// HOST OPTIONS
//--------------------------------------------------------------------+
-#ifdef TUSB_CFG_HOST
- //------------- Controller -------------//
-
+#if MODE_HOST_SUPPORTED
#ifndef TUSB_CFG_HOST_CONTROLLER_START_INDEX
#error TUSB_CFG_HOST_CONTROLLER_START_INDEX is not defined
#endif
@@ -162,6 +179,8 @@
#define CDC_NOTIFICATION_EP_MAXPACKETSIZE 8
#define CDC_DATA_EP_MAXPACKET_SIZE 16
+
+
#ifdef __cplusplus
}
#endif