summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-02-01 10:33:43 +0700
committerhathach <[email protected]>2013-02-01 10:33:43 +0700
commit9e3785e7e1bd5bac3c8e24477edbde12cc09dd4b (patch)
treec2233323659aeda002dbbcb6e910b669f1147aac /tinyusb
parent1b963f6a7117d754c47e860159ac0aa90d1db6dc (diff)
add std=gnu99 for test build
add hcd_init to usbh_init and update test code add TUSB_CFG_OS_TICK_PER_SECOND define for TUSB_OS_NONE change osal_semaphore_wait and osal_queue_receive API to have timeout effectively
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/common/errors.h1
-rw-r--r--tinyusb/host/hcd.c1
-rw-r--r--tinyusb/host/hcd.h5
-rw-r--r--tinyusb/host/usbd_host.c40
-rw-r--r--tinyusb/host/usbd_host.h1
-rw-r--r--tinyusb/osal/osal.h9
-rw-r--r--tinyusb/osal/osal_none.h2
-rw-r--r--tinyusb/tusb_option.h73
8 files changed, 83 insertions, 49 deletions
diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h
index 7af82920e..f885362e7 100644
--- a/tinyusb/common/errors.h
+++ b/tinyusb/common/errors.h
@@ -65,6 +65,7 @@
ENTRY(TUSB_ERROR_DEVICE_NOT_READY)\
ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\
ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\
+ ENTRY(TUSB_ERROR_HCD_FAILED)\
ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\
ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\
ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\
diff --git a/tinyusb/host/hcd.c b/tinyusb/host/hcd.c
index 2c085566e..6960d2cfa 100644
--- a/tinyusb/host/hcd.c
+++ b/tinyusb/host/hcd.c
@@ -41,7 +41,6 @@
tusb_error_t hcd_init(uint8_t coreid)
{
-
return TUSB_ERROR_NONE;
}
diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h
index 9ea26bdda..ed68171b7 100644
--- a/tinyusb/host/hcd.h
+++ b/tinyusb/host/hcd.h
@@ -60,7 +60,6 @@
typedef uint32_t pipe_handle_t;
-#if 0
/** \brief Initialize HCD
*
* \param[in] para1
@@ -71,6 +70,10 @@ typedef uint32_t pipe_handle_t;
tusb_error_t hcd_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT;
+/// return the current connect status of roothub port
+bool hcd_port_connect_status(uint8_t hostid) ATTR_WARN_UNUSED_RESULT;
+
+#if 0
//tusb_error_t hcd_pipe_open(
// uint8_t hostid, uint8_t device_address,
//
diff --git a/tinyusb/host/usbd_host.c b/tinyusb/host/usbd_host.c
index c3489525d..3c8c9ce83 100644
--- a/tinyusb/host/usbd_host.c
+++ b/tinyusb/host/usbd_host.c
@@ -58,12 +58,6 @@
//--------------------------------------------------------------------+
STATIC_ usbh_device_info_t device_info_pool[TUSB_CFG_HOST_DEVICE_MAX];
-OSAL_TASK_DEF(enumeration_task, usbh_enumerate_task, 128, OSAL_PRIO_HIGH);
-
-#define ENUM_QUEUE_DEPTH 5
-OSAL_DEF_QUEUE(enumeration_queue, ENUM_QUEUE_DEPTH, uin32_t);
-osal_queue_handle_t enumeration_queue_hdl;
-
//--------------------------------------------------------------------+
// PUBLIC API (Parameter Verification is required)
//--------------------------------------------------------------------+
@@ -74,22 +68,44 @@ tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device
}
//--------------------------------------------------------------------+
+// ENUMERATION TASK & ITS DATA
+//--------------------------------------------------------------------+
+OSAL_TASK_DEF(enumeration_task, usbh_enumerate_task, 128, OSAL_PRIO_HIGH);
+
+#define ENUM_QUEUE_DEPTH 5
+OSAL_DEF_QUEUE(enumeration_queue, ENUM_QUEUE_DEPTH, uin32_t);
+osal_queue_handle_t enumeration_queue_hdl;
+
+void usbh_enumerate_task(void)
+{
+ OSAL_TASK_LOOP
+ {
+ OSAL_TASK_LOOP_BEGIN
+
+
+
+ OSAL_TASK_LOOP_END
+ }
+}
+
+//--------------------------------------------------------------------+
// CLASS-USBD API (don't require to verify parameters)
//--------------------------------------------------------------------+
tusb_error_t usbh_init(void)
{
+ uint32_t i;
+
memset(device_info_pool, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
+ for(i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
+ {
+ ASSERT_STATUS( hcd_init(i) );
+ }
+
ASSERT_STATUS( osal_task_create(&enumeration_task) );
enumeration_queue_hdl = osal_queue_create(&enumeration_queue);
ASSERT_PTR(enumeration_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
return TUSB_ERROR_NONE;
}
-
-void usbh_enumerate_task(void)
-{
-
-}
-
#endif
diff --git a/tinyusb/host/usbd_host.h b/tinyusb/host/usbd_host.h
index d218fbd15..54d58ab81 100644
--- a/tinyusb/host/usbd_host.h
+++ b/tinyusb/host/usbd_host.h
@@ -140,6 +140,7 @@ typedef struct {
uint8_t core_id;
uint8_t hub_address;
uint8_t hub_port;
+ uint8_t connect_status;
} usbh_enumerate_t;
//--------------------------------------------------------------------+
diff --git a/tinyusb/osal/osal.h b/tinyusb/osal/osal.h
index 0dfb73686..0c99e497f 100644
--- a/tinyusb/osal/osal.h
+++ b/tinyusb/osal/osal.h
@@ -76,6 +76,9 @@
typedef uint32_t osal_timeout_t;
+//------------- Tick -------------//
+uint32_t osal_tick_get(void);
+
//------------- Task -------------//
typedef uint32_t osal_task_t;
#define OSAL_TASK_DEF(name, code, stack_depth, prio) \
@@ -91,7 +94,7 @@ tusb_error_t osal_task_create(osal_task_t *task);
typedef uint32_t osal_semaphore_t;
typedef void* osal_semaphore_handle_t;
osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * const sem);
-tusb_error_t osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, osal_timeout_t msec);
+void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, osal_timeout_t msec, tusb_error_t *p_error);
tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl);
//------------- Queue -------------//
@@ -101,7 +104,9 @@ typedef void* osal_queue_handle_t;
#define OSAL_DEF_QUEUE(name, queue_depth, type) \
osal_queue_t name
-osal_queue_handle_t osal_queue_create(osal_queue_t *queue);
+osal_queue_handle_t osal_queue_create (osal_queue_t *p_queue);
+void osal_queue_receive (osal_queue_handle_t const queue_hdl, uint32_t *p_data, osal_timeout_t msec, tusb_error_t *p_error);
+tusb_error_t osal_queue_send (osal_queue_handle_t const queue_hdl, uint32_t data);
#endif
diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h
index 6833ada24..84373b6de 100644
--- a/tinyusb/osal/osal_none.h
+++ b/tinyusb/osal/osal_none.h
@@ -106,7 +106,7 @@ static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const se
return TUSB_ERROR_NONE;
}
-#define osal_semaphore_wait(sem_hdl, msec) \
+#define osal_semaphore_wait(sem_hdl, msec, p_error) \
do {\
state = __LINE__; case __LINE__:\
if( (*sem_hdl) == 0 ) \
diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h
index 04316ac9c..79c957051 100644
--- a/tinyusb/tusb_option.h
+++ b/tinyusb/tusb_option.h
@@ -62,61 +62,70 @@
/// define this symbol will make tinyusb look for external configure file
#include "tusb_config.h"
+//--------------------------------------------------------------------+
+// COMMON OPTIONS
+//--------------------------------------------------------------------+
/// 0: no debug information 3: most debug information provided
#ifndef TUSB_CFG_DEBUG
#define TUSB_CFG_DEBUG 3
#warning TUSB_CFG_DEBUG is not defined, default value is 3
#endif
-/// Enable Host Support
-#ifdef TUSB_CFG_HOST
-
-#ifndef TUSB_CFG_HOST_CONTROLLER_NUM
- #define TUSB_CFG_HOST_CONTROLLER_NUM 1
- #warning TUSB_CFG_HOST_CONTROLLER_NUM is not defined, default value is 1
+/// USB RAM Section Placement, MCU's usb controller often has limited access to specific RAM region. This will be used to declare internal variables as follow:
+/// uint8_t tinyusb_data[10] TUSB_CFG_ATTR_USBRAM;
+/// if your mcu's usb controller has no such limit, define TUSB_CFG_ATTR_USBRAM as empty macro.
+#ifndef TUSB_CFG_ATTR_USBRAM
+ #error TUSB_CFG_ATTR_USBRAM is not defined, please help me know how to place data in accessible RAM for usb controller
#endif
-#ifndef TUSB_CFG_HOST_DEVICE_MAX
- #define TUSB_CFG_HOST_DEVICE_MAX 1
- #warning TUSB_CFG_HOST_DEVICE_MAX is not defined, default value is 1
-#endif
+//--------------------------------------------------------------------+
+// HOST OPTIONS
+//--------------------------------------------------------------------+
+#ifdef TUSB_CFG_HOST
+ #ifndef TUSB_CFG_HOST_CONTROLLER_NUM
+ #define TUSB_CFG_HOST_CONTROLLER_NUM 1
+ #warning TUSB_CFG_HOST_CONTROLLER_NUM is not defined, default value is 1
+ #endif
-#if TUSB_CFG_HOST_HID_KEYBOARD
- #if !defined(TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE)
- #define TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE 64
- #warning TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE is not defined, default value is 64
- #elif TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE < 8
- #error no endpoint size is allowed to be less than 8
+ #ifndef TUSB_CFG_HOST_DEVICE_MAX
+ #define TUSB_CFG_HOST_DEVICE_MAX 1
+ #warning TUSB_CFG_HOST_DEVICE_MAX is not defined, default value is 1
#endif
- #if !defined(TUSB_CFG_HOST_HID_KEYBOARD_NO_INSTANCES_PER_DEVICE)
- #define TUSB_CFG_HOST_HID_KEYBOARD_NO_INSTANCES_PER_DEVICE 1
+ #if TUSB_CFG_HOST_HID_KEYBOARD
+ #if !defined(TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE)
+ #define TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE 64
+ #warning TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE is not defined, default value is 64
+ #endif
+
+ #if !defined(TUSB_CFG_HOST_HID_KEYBOARD_NO_INSTANCES_PER_DEVICE)
+ #define TUSB_CFG_HOST_HID_KEYBOARD_NO_INSTANCES_PER_DEVICE 1
+ #endif
+ #endif // end TUSB_CFG_HOST_HID_KEYBOARD
+
+ #if TUSB_CFG_OS == TUSB_OS_NONE
+ #ifndef TUSB_CFG_OS_TICK_PER_SECOND
+ #error TUSB_CFG_OS_TICK_PER_SECOND is required to use with OS_NONE
+ #endif
#endif
-#endif
-#endif
+ #define HOST_CLASS_HID ( (defined TUSB_CFG_HOST_HID_KEYBOARD) )
+ #define HOST_EHCI
+#endif // end TUSB_CFG_HOST
#ifndef TUSB_CFG_CONFIGURATION_MAX
#define TUSB_CFG_CONFIGURATION_MAX 1
#warning TUSB_CFG_CONFIGURATION_MAX is not defined, default value is 1
#endif
-/// Enable Device Support
+//--------------------------------------------------------------------+
+// DEVICE OPTIONS
+//--------------------------------------------------------------------+
//#define TUSB_CFG_DEVICE
-/// USB RAM Section Placement, MCU's usb controller often has limited access to specific RAM region. This will be used to declare internal variables as follow:
-/// uint8_t tinyusb_data[10] TUSB_CFG_ATTR_USBRAM;
-/// if your mcu's usb controller has no such limit, define TUSB_CFG_ATTR_USBRAM as empty macro.
-#ifndef TUSB_CFG_ATTR_USBRAM
- #error TUSB_CFG_ATTR_USBRAM is not defined, please help me know how to place data in accessible RAM for usb controller
-#endif
-
#define DEVICE_CLASS_HID ( (defined TUSB_CFG_DEVICE_HID_KEYBOARD) || (defined TUSB_CFG_DEVICE_HID_MOUSE) )
-#define HOST_CLASS_HID ( (defined TUSB_CFG_HOST_HID_KEYBOARD) )
-
-#define HOST_EHCI
-// TODO APP
+// TODO Device APP
#define USB_MAX_IF_NUM 8
#define USB_MAX_EP_NUM 5