Browse Source

house keeping
add some more logic for enum task

hathach 13 years ago
parent
commit
a25da9d3ee

+ 1 - 1
tests/test/host/test_usbd_host.c

@@ -129,7 +129,7 @@ usbh_enumerate_t enum_connect =
 void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error, int num_call)
 void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error, int num_call)
 {
 {
   TEST_ASSERT_EQUAL_PTR(enum_queue_hdl, queue_hdl);
   TEST_ASSERT_EQUAL_PTR(enum_queue_hdl, queue_hdl);
-  memcpy(p_data, &enum_connect, 4);
+  (*p_data) = ( *((uint32_t*) &enum_connect) );
   (*p_error) = TUSB_ERROR_NONE;
   (*p_error) = TUSB_ERROR_NONE;
 }
 }
 
 

+ 3 - 2
tinyusb/common/assertion.h

@@ -70,7 +70,8 @@ extern "C"
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 #define ASSERT_FILENAME  __FILE__
 #define ASSERT_FILENAME  __FILE__
 #define ASSERT_FUNCTION  __PRETTY_FUNCTION__
 #define ASSERT_FUNCTION  __PRETTY_FUNCTION__
-#define ASSERT_STATEMENT _PRINTF("assert at %s: %s :%d :\n", ASSERT_FILENAME, ASSERT_FUNCTION, __LINE__)
+#define ASSERT_STATEMENT(format, ...)\
+    _PRINTF("Assert at %s: %s:%d: " format "\n", ASSERT_FILENAME, ASSERT_FUNCTION, __LINE__, __VA_ARGS__)
 
 
 #ifndef _TEST_ASSERT_
 #ifndef _TEST_ASSERT_
   #define ASSERT_ERROR_HANDLE(x)  return (x)
   #define ASSERT_ERROR_HANDLE(x)  return (x)
@@ -82,7 +83,7 @@ extern "C"
   do{\
   do{\
     setup_statement;\
     setup_statement;\
 	  if (!(condition)) {\
 	  if (!(condition)) {\
-	    _PRINTF("Assert at %s: %s:%d: " format "\n", ASSERT_FILENAME, ASSERT_FUNCTION, __LINE__, __VA_ARGS__);\
+	    ASSERT_STATEMENT(format, __VA_ARGS__);\
 	    ASSERT_ERROR_HANDLE(error);\
 	    ASSERT_ERROR_HANDLE(error);\
 	  }\
 	  }\
 	}while(0)
 	}while(0)

+ 11 - 9
tinyusb/host/hcd.h

@@ -60,18 +60,13 @@
 
 
 typedef uint32_t pipe_handle_t;
 typedef uint32_t pipe_handle_t;
 
 
-/** \brief Initialize HCD
-*
-* \param[in]  para1
-* \param[out] para2
-* \return Error Code of the \ref TUSB_ERROR enum
-* \note
-*/
 
 
 tusb_error_t hcd_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT;
 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;
+//--------------------------------------------------------------------+
+// PIPE API
+//--------------------------------------------------------------------+
+//pipe_handle_t hcd_pipe_control_open(core_id, speed, hub_addr, hub_port, dev_addr, max_packet_size);
 
 
 #if 0
 #if 0
 //tusb_error_t hcd_pipe_open(
 //tusb_error_t hcd_pipe_open(
@@ -83,6 +78,13 @@ tusb_error_t hcd_pipe_transfer()ATTR_WARN_UNUSED_RESULT;
 tusb_error_t hcd_pipe_cancel()ATTR_WARN_UNUSED_RESULT;
 tusb_error_t hcd_pipe_cancel()ATTR_WARN_UNUSED_RESULT;
 #endif
 #endif
 
 
+//--------------------------------------------------------------------+
+// PORT API
+//--------------------------------------------------------------------+
+/// return the current connect status of roothub port
+bool hcd_port_connect_status(uint8_t core_id) ATTR_WARN_UNUSED_RESULT;
+tusb_speed_t hcd_port_speed_get(uint8_t core_id) ATTR_WARN_UNUSED_RESULT;
+
 #ifdef __cplusplus
 #ifdef __cplusplus
  }
  }
 #endif
 #endif

+ 21 - 1
tinyusb/host/usbd_host.c

@@ -78,11 +78,31 @@ osal_queue_handle_t enum_queue_hdl;
 
 
 void usbh_enumeration_task(void)
 void usbh_enumeration_task(void)
 {
 {
+  usbh_enumerate_t enum_item;
+  tusb_error_t error;
+
   OSAL_TASK_LOOP
   OSAL_TASK_LOOP
   {
   {
     OSAL_TASK_LOOP_BEGIN
     OSAL_TASK_LOOP_BEGIN
 
 
-//    osal_queue_receive(enumeration_queue_hdl, )
+    osal_queue_receive(enum_queue_hdl, (uint32_t*)&enum_item, OSAL_TIMEOUT_NORMAL, &error);
+    if (error != TUSB_ERROR_NONE)
+    {
+      ASSERT_STATEMENT("%s", TUSB_ErrorStr[error]);
+    }
+    else
+    {
+      if (enum_item.hub_address == 0) // direct connection
+      {
+        if ( enum_item.connect_status == hcd_port_connect_status(enum_item.core_id) ) // there chances the event is out-dated
+        {
+
+        }
+      }else // device connect via a hub
+      {
+        ASSERT_STATEMENT("%s", "Hub is not supported yet");
+      }
+    }
 
 
     OSAL_TASK_LOOP_END
     OSAL_TASK_LOOP_END
   }
   }

+ 1 - 1
tinyusb/host/usbd_host.h

@@ -136,7 +136,7 @@ typedef enum {
 
 
 typedef uint32_t tusb_handle_device_t;
 typedef uint32_t tusb_handle_device_t;
 
 
-typedef struct {
+typedef struct ATTR_ALIGNED(4){
   uint8_t core_id;
   uint8_t core_id;
   uint8_t hub_address;
   uint8_t hub_address;
   uint8_t hub_port;
   uint8_t hub_port;