summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-05-04 14:11:58 +0700
committerhathach <[email protected]>2020-05-04 14:11:58 +0700
commit905a80d1b2de5e8ad67b3687ffd0543d90ac904e (patch)
tree3ca3f3c316c2d4c239d6cce651dfe6746d5cbc79 /src
parent4a3a44834048006b05d82d32e1f69be856554d4d (diff)
temporarily remove osal_task_delay() from osal
- add hcd_uframe_number() API, update EHCI to return uframe number - get host running on ea4357
Diffstat (limited to 'src')
-rw-r--r--src/host/ehci/ehci.c13
-rw-r--r--src/host/ehci/ehci.h6
-rw-r--r--src/host/hcd.h9
-rw-r--r--src/host/usbh.c9
-rw-r--r--src/osal/osal.h2
-rw-r--r--src/osal/osal_none.h16
6 files changed, 43 insertions, 12 deletions
diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c
index bbad072bf..048affb1e 100644
--- a/src/host/ehci/ehci.c
+++ b/src/host/ehci/ehci.c
@@ -108,6 +108,12 @@ bool hcd_init(void)
return ehci_init(TUH_OPT_RHPORT);
}
+uint32_t hcd_uframe_number(uint8_t rhport)
+{
+ (void) rhport;
+ return ehci_data.uframe_number + ehci_data.regs->frame_index;
+}
+
void hcd_port_reset(uint8_t rhport)
{
(void) rhport;
@@ -192,7 +198,7 @@ static bool ehci_init(uint8_t rhport)
regs->status = EHCI_INT_MASK_ALL; // 2. clear all status
regs->inten = EHCI_INT_MASK_ERROR | EHCI_INT_MASK_PORT_CHANGE | EHCI_INT_MASK_ASYNC_ADVANCE |
- EHCI_INT_MASK_NXP_PERIODIC | EHCI_INT_MASK_NXP_ASYNC ;
+ EHCI_INT_MASK_NXP_PERIODIC | EHCI_INT_MASK_NXP_ASYNC | EHCI_INT_MASK_FRAMELIST_ROLLOVER;
//------------- Asynchronous List -------------//
ehci_qhd_t * const async_head = qhd_async_head(rhport);
@@ -636,6 +642,11 @@ void hcd_isr(uint8_t rhport)
if (int_status == 0) return;
+ if (int_status & EHCI_INT_MASK_FRAMELIST_ROLLOVER)
+ {
+ ehci_data.uframe_number += (EHCI_FRAMELIST_SIZE << 3);
+ }
+
if (int_status & EHCI_INT_MASK_PORT_CHANGE)
{
uint32_t port_status = regs->portsc & EHCI_PORTSC_MASK_ALL;
diff --git a/src/host/ehci/ehci.h b/src/host/ehci/ehci.h
index ce2f56771..f11c4536a 100644
--- a/src/host/ehci/ehci.h
+++ b/src/host/ehci/ehci.h
@@ -54,8 +54,8 @@
//--------------------------------------------------------------------+
// EHCI CONFIGURATION & CONSTANTS
//--------------------------------------------------------------------+
-#define EHCI_CFG_FRAMELIST_SIZE_BITS 7 /// Framelist Size (NXP specific) (0:1024) - (1:512) - (2:256) - (3:128) - (4:64) - (5:32) - (6:16) - (7:8)
-#define EHCI_FRAMELIST_SIZE (1024 >> EHCI_CFG_FRAMELIST_SIZE_BITS)
+#define EHCI_CFG_FRAMELIST_SIZE_BITS 7 /// Framelist Size (NXP specific) (0:1024) - (1:512) - (2:256) - (3:128) - (4:64) - (5:32) - (6:16) - (7:8)
+#define EHCI_FRAMELIST_SIZE (1024 >> EHCI_CFG_FRAMELIST_SIZE_BITS)
// TODO merge OHCI with EHCI
enum {
@@ -445,6 +445,8 @@ typedef struct
ehci_qtd_t qtd_pool[HCD_MAX_XFER] TU_ATTR_ALIGNED(32);
ehci_registers_t* regs;
+
+ volatile uint32_t uframe_number;
}ehci_data_t;
#ifdef __cplusplus
diff --git a/src/host/hcd.h b/src/host/hcd.h
index a39e7fe16..d9307ca09 100644
--- a/src/host/hcd.h
+++ b/src/host/hcd.h
@@ -91,6 +91,15 @@ void hcd_isr(uint8_t hostid);
void hcd_int_enable (uint8_t rhport);
void hcd_int_disable(uint8_t rhport);
+// Get micro frame number (125 us)
+uint32_t hcd_uframe_number(uint8_t rhport);
+
+// Get frame number (1ms)
+static inline uint32_t hcd_frame_number(uint8_t rhport)
+{
+ return hcd_uframe_number(rhport) >> 3;
+}
+
// PORT API
/// return the current connect status of roothub port
bool hcd_port_connect_status(uint8_t hostid);
diff --git a/src/host/usbh.c b/src/host/usbh.c
index f1b88259c..7171f6bab 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -127,6 +127,15 @@ tusb_device_state_t tuh_device_get_state (uint8_t const dev_addr)
return (tusb_device_state_t) _usbh_devices[dev_addr].state;
}
+
+static inline void osal_task_delay(uint32_t msec)
+{
+ (void) msec;
+
+ uint32_t start = hcd_frame_number(TUH_OPT_RHPORT);
+ while ( ( hcd_frame_number(TUH_OPT_RHPORT) - start ) < msec ) {}
+}
+
//--------------------------------------------------------------------+
// CLASS-USBD API (don't require to verify parameters)
//--------------------------------------------------------------------+
diff --git a/src/osal/osal.h b/src/osal/osal.h
index 0421b3294..02dcf5367 100644
--- a/src/osal/osal.h
+++ b/src/osal/osal.h
@@ -62,7 +62,7 @@ typedef void (*osal_task_func_t)( void * );
//--------------------------------------------------------------------+
// OSAL Porting API
//--------------------------------------------------------------------+
-static inline void osal_task_delay(uint32_t msec);
+//static inline void osal_task_delay(uint32_t msec);
//------------- Semaphore -------------//
static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef);
diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h
index b27e628a9..e7ce18079 100644
--- a/src/osal/osal_none.h
+++ b/src/osal/osal_none.h
@@ -34,14 +34,14 @@
//--------------------------------------------------------------------+
// TASK API
//--------------------------------------------------------------------+
-static inline void osal_task_delay(uint32_t msec)
-{
- (void) msec;
- // TODO only used by Host stack, will implement using SOF
-
-// uint32_t start = tusb_hal_millis();
-// while ( ( tusb_hal_millis() - start ) < msec ) {}
-}
+//static inline void osal_task_delay(uint32_t msec)
+//{
+// (void) msec;
+// // TODO only used by Host stack, will implement using SOF
+//
+//// uint32_t start = tusb_hal_millis();
+//// while ( ( tusb_hal_millis() - start ) < msec ) {}
+//}
//--------------------------------------------------------------------+
// Binary Semaphore API