summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-02-04 16:07:42 +0700
committerhathach <[email protected]>2013-02-04 16:07:42 +0700
commitd71e244dffc15cd3fbabbe6e710a7a20ea09c413 (patch)
treecec86a2520fbd271094f67cc86d2dd594844d2ba /tinyusb
parent0a13e37ba22c195b685cbcb61e51500f038a38c4 (diff)
add TUSB_CFG_HOST_ENUM_BUFFER_SIZE
add enum buffer getting serious with osal_freeRTOS
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/host/usbh.c38
-rw-r--r--tinyusb/host/usbh_hcd.h9
-rw-r--r--tinyusb/osal/osal.h8
-rw-r--r--tinyusb/osal/osal_none.h8
-rw-r--r--tinyusb/tusb_option.h5
5 files changed, 45 insertions, 23 deletions
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index 2d135d63f..38d96597d 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -74,10 +74,10 @@ tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device
OSAL_TASK_DEF(enum_task, usbh_enumeration_task, 128, OSAL_PRIO_HIGH);
#define ENUM_QUEUE_DEPTH 5
-OSAL_DEF_QUEUE(enum_queue, ENUM_QUEUE_DEPTH, uin32_t);
+OSAL_QUEUE_DEF(enum_queue, ENUM_QUEUE_DEPTH, uin32_t);
osal_queue_handle_t enum_queue_hdl;
usbh_device_addr0_t device_addr0 TUSB_CFG_ATTR_USBRAM;
-
+uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM;
void usbh_enumeration_task(void)
{
tusb_error_t error;
@@ -91,23 +91,29 @@ void usbh_enumeration_task(void)
{
TASK_ASSERT(device_addr0.enum_entry.connect_status == hcd_port_connect_status(device_addr0.enum_entry.core_id)); // there chances the event is out-dated
- tusb_std_request_t request_dev_desc =
+ device_addr0.speed = hcd_port_speed(device_addr0.enum_entry.core_id);
+ error = hcd_addr0_open(&device_addr0);
+ TASK_ASSERT_STATUS(error);
+
{
- .bmRequestType =
- {
- .direction = TUSB_DIR_DEV_TO_HOST,
- .type = TUSB_REQUEST_TYPE_STANDARD,
- .recipient = TUSB_REQUEST_RECIPIENT_DEVICE
- },
+ tusb_std_request_t request_device_desc =
+ {
+ .bmRequestType =
+ {
+ .direction = TUSB_DIR_DEV_TO_HOST,
+ .type = TUSB_REQUEST_TYPE_STANDARD,
+ .recipient = TUSB_REQUEST_RECIPIENT_DEVICE
+ },
+
+ .bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
+ .wValue = (TUSB_DESC_DEVICE << 8),
+ .wLength = 8
+ };
+ hcd_pipe_control_xfer(device_addr0.pipe_hdl, &request_device_desc, enum_data_buffer);
+// osal_sem_wait();
+ }
- .bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
- .wValue = (TUSB_DESC_DEVICE << 8),
- .wLength = 8
- };
- device_addr0.speed = hcd_port_speed(device_addr0.enum_entry.core_id);
- pipe_handle_t pipe_addr0 = hcd_addr0_open(&device_addr0);
-// hcd_pipe_control_xfer(pipe_addr0, &request_dev_desc, )
}else // device connect via a hub
{
ASSERT_MESSAGE("%s", "Hub is not supported yet");
diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h
index a861dbd6a..e30bf143b 100644
--- a/tinyusb/host/usbh_hcd.h
+++ b/tinyusb/host/usbh_hcd.h
@@ -59,6 +59,7 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "common/common.h"
+#include "osal/osal.h"
#include "hcd.h"
#include "usbh.h"
@@ -76,7 +77,9 @@ typedef struct {
usbh_enumerate_t enum_entry;
tusb_speed_t speed;
tusb_std_request_t request_packet; // needed to be on USB RAM
- uint8_t dev_desc[8];
+ pipe_handle_t pipe_hdl;
+ OSAL_SEM_DEF(semaphore);
+ osal_semaphore_handle_t sem_hdl;
} usbh_device_addr0_t;
typedef struct { // TODO internal structure, re-order members
@@ -106,9 +109,7 @@ typedef struct { // TODO internal structure, re-order members
//--------------------------------------------------------------------+
// ADDRESS 0 API
//--------------------------------------------------------------------+
-pipe_handle_t hcd_addr0_open(usbh_device_addr0_t *dev_addr0);
-tusb_error_t hcd_addr0_get_dev_desc(usbh_device_addr0_t *dev_addr0);
-tusb_error_t hcd_addr0_set_addr(usbh_device_addr0_t *dev_addr0, uint8_t new_addr);
+tusb_error_t hcd_addr0_open(usbh_device_addr0_t *dev_addr0) ATTR_WARN_UNUSED_RESULT;
#ifdef __cplusplus
}
diff --git a/tinyusb/osal/osal.h b/tinyusb/osal/osal.h
index 0f632f529..055f28d1a 100644
--- a/tinyusb/osal/osal.h
+++ b/tinyusb/osal/osal.h
@@ -94,8 +94,12 @@ typedef uint32_t osal_task_t;
tusb_error_t osal_task_create(osal_task_t *task);
//------------- Semaphore -------------//
-typedef uint32_t osal_semaphore_t;
+typedef volatile uint32_t osal_semaphore_t;
typedef void* osal_semaphore_handle_t;
+
+#define OSAL_SEM_DEF(name)\
+ osal_semaphore_t name
+
osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * const sem);
void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error);
tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl);
@@ -104,7 +108,7 @@ tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl);
typedef uint32_t osal_queue_t;
typedef void* osal_queue_handle_t;
-#define OSAL_DEF_QUEUE(name, queue_depth, type) \
+#define OSAL_QUEUE_DEF(name, queue_depth, type) \
osal_queue_t name
osal_queue_handle_t osal_queue_create (osal_queue_t *p_queue);
diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h
index 2056f5214..adcc22ed9 100644
--- a/tinyusb/osal/osal_none.h
+++ b/tinyusb/osal/osal_none.h
@@ -103,6 +103,12 @@ uint32_t osal_tick_get(void);
typedef volatile uint8_t osal_semaphore_t;
typedef osal_semaphore_t * osal_semaphore_handle_t;
+#define OSAL_SEM_DEF(name)\
+ osal_semaphore_t name
+
+#define OSAL_SEM_REF(name)\
+ &name
+
static inline osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * const p_sem) ATTR_ALWAYS_INLINE;
static inline osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * const p_sem)
{
@@ -145,7 +151,7 @@ typedef struct{
typedef osal_queue_t * osal_queue_handle_t;
// use to declare a queue, within the scope of tinyusb, should only use primitive type only
-#define OSAL_DEF_QUEUE(name, queue_depth, type)\
+#define OSAL_QUEUE_DEF(name, queue_depth, type)\
uint32_t name##_buffer[queue_depth];\
osal_queue_t name = {\
.buffer = name##_buffer,\
diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h
index cc12cc8eb..1dc042bca 100644
--- a/tinyusb/tusb_option.h
+++ b/tinyusb/tusb_option.h
@@ -114,6 +114,11 @@
#endif
#endif // end TUSB_CFG_HOST_HID_KEYBOARD
+ #ifndef TUSB_CFG_HOST_ENUM_BUFFER_SIZE
+ #define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256
+ #warning TUSB_CFG_HOST_ENUM_BUFFER_SIZE is not defined, default value is 256
+ #endif
+
#define HOST_CLASS_HID ( (defined TUSB_CFG_HOST_HID_KEYBOARD) )
#define HOST_EHCI
#endif // end TUSB_CFG_HOST