summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-02-08 12:12:10 +0700
committerhathach <[email protected]>2013-02-08 12:12:10 +0700
commit489b98cb933e1f4b164bf1172a405d22528d2b8b (patch)
treec39a7143190459979f398b13bf1a7426accf0258 /tinyusb
parentef0e105da669c7a3d8ae781dac11a37d52c63fa0 (diff)
add TUSB_CFG_HOST_CONTROLLER_START_INDEX
update usbh_init and test code for TUSB_CFG_HOST_CONTROLLER_START_INDEX clean up some
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/hal/hal.h7
-rw-r--r--tinyusb/host/usbh.c59
-rw-r--r--tinyusb/osal/osal_freeRTOS.h8
-rw-r--r--tinyusb/tusb_option.h4
4 files changed, 43 insertions, 35 deletions
diff --git a/tinyusb/hal/hal.h b/tinyusb/hal/hal.h
index 7bc038877..c2b60a77a 100644
--- a/tinyusb/hal/hal.h
+++ b/tinyusb/hal/hal.h
@@ -51,10 +51,6 @@
#ifndef _TUSB_HAL_H_
#define _TUSB_HAL_H_
-#ifdef __cplusplus
- extern "C" {
-#endif
-
#include "tusb_option.h"
#include "common/compiler/compiler.h"
@@ -72,6 +68,9 @@
#include "hal_lpc43xx.h"
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
/** \brief USB hardware init
*
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index b9dc8a2ae..00574d52f 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -51,15 +51,25 @@
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
+#define ENUM_QUEUE_DEPTH 5
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
-static inline uint8_t get_new_address(void) ATTR_ALWAYS_INLINE;
-
STATIC_ usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address
+//------------- Enumeration Task Data -------------//
+OSAL_TASK_DEF(enum_task, usbh_enumeration_task, 128, OSAL_PRIO_HIGH);
+OSAL_QUEUE_DEF(enum_queue, ENUM_QUEUE_DEPTH, uin32_t);
+osal_queue_handle_t enum_queue_hdl;
+STATIC_ uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM;
+
+//------------- Reporter Task Data -------------//
+
+//------------- Helper Function Prototypes -------------//
+static inline uint8_t get_new_address(void) ATTR_ALWAYS_INLINE;
+
//--------------------------------------------------------------------+
// PUBLIC API (Parameter Verification is required)
//--------------------------------------------------------------------+
@@ -70,22 +80,36 @@ tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device
}
//--------------------------------------------------------------------+
-// ENUMERATION TASK & ITS DATA
+// CLASS-USBD API (don't require to verify parameters)
//--------------------------------------------------------------------+
-OSAL_TASK_DEF(enum_task, usbh_enumeration_task, 128, OSAL_PRIO_HIGH);
+tusb_error_t usbh_init(void)
+{
+ uint32_t i;
-#define ENUM_QUEUE_DEPTH 5
-OSAL_QUEUE_DEF(enum_queue, ENUM_QUEUE_DEPTH, uin32_t);
-osal_queue_handle_t enum_queue_hdl;
-STATIC_ uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM;
+ memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
+ for(i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
+ {
+ ASSERT_STATUS( hcd_init(TUSB_CFG_HOST_CONTROLLER_START_INDEX+i) );
+ }
+ ASSERT_STATUS( osal_task_create(&enum_task) );
+ enum_queue_hdl = osal_queue_create(&enum_queue);
+ ASSERT_PTR(enum_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
+
+ return TUSB_ERROR_NONE;
+}
+
+//--------------------------------------------------------------------+
+// ENUMERATION TASK
+//--------------------------------------------------------------------+
void usbh_enumeration_task(void)
{
tusb_error_t error;
usbh_enumerate_t enum_entry;
tusb_std_request_t request_packet;
+ // for OSAL_NONE local variable wont retain value after blocking service sem_wait/queue_recv
static uint8_t new_addr;
static uint8_t configure_selected = 1;
@@ -201,26 +225,7 @@ void usbh_enumeration_task(void)
//--------------------------------------------------------------------+
-//--------------------------------------------------------------------+
-// CLASS-USBD API (don't require to verify parameters)
-//--------------------------------------------------------------------+
-tusb_error_t usbh_init(void)
-{
- uint32_t i;
- memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
-
- for(i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++)
- {
- ASSERT_STATUS( hcd_init(i) );
- }
-
- ASSERT_STATUS( osal_task_create(&enum_task) );
- enum_queue_hdl = osal_queue_create(&enum_queue);
- ASSERT_PTR(enum_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
-
- return TUSB_ERROR_NONE;
-}
#endif
//--------------------------------------------------------------------+
diff --git a/tinyusb/osal/osal_freeRTOS.h b/tinyusb/osal/osal_freeRTOS.h
index ed167e688..887727bb0 100644
--- a/tinyusb/osal/osal_freeRTOS.h
+++ b/tinyusb/osal/osal_freeRTOS.h
@@ -51,10 +51,6 @@
#ifndef _TUSB_OSAL_FREERTOS_H_
#define _TUSB_OSAL_FREERTOS_H_
-#ifdef __cplusplus
- extern "C" {
-#endif
-
#include "osal_common.h"
//------------- FreeRTOS Headers -------------//
@@ -62,6 +58,10 @@
#include "semphr.h"
#include "queue.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
//--------------------------------------------------------------------+
// TICK API
//--------------------------------------------------------------------+
diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h
index 1dc042bca..d2001eae3 100644
--- a/tinyusb/tusb_option.h
+++ b/tinyusb/tusb_option.h
@@ -98,6 +98,10 @@
#warning TUSB_CFG_HOST_CONTROLLER_NUM is not defined, default value is 1
#endif
+ #ifndef TUSB_CFG_HOST_CONTROLLER_START_INDEX
+ #error TUSB_CFG_HOST_CONTROLLER_START_INDEX is not defined
+ #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