summaryrefslogtreecommitdiff
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
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
-rw-r--r--examples/host/cdc_msc_hid/src/tusb_config.h2
-rw-r--r--hw/bsp/ea4357/board.mk4
-rw-r--r--hw/bsp/ea4357/ea4357.c26
-rw-r--r--hw/bsp/mcb1800/mcb1800.c25
-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
10 files changed, 72 insertions, 40 deletions
diff --git a/examples/host/cdc_msc_hid/src/tusb_config.h b/examples/host/cdc_msc_hid/src/tusb_config.h
index 235402180..a929e36d8 100644
--- a/examples/host/cdc_msc_hid/src/tusb_config.h
+++ b/examples/host/cdc_msc_hid/src/tusb_config.h
@@ -69,7 +69,7 @@
// CONFIGURATION
//--------------------------------------------------------------------
-#define CFG_TUH_HUB 1
+#define CFG_TUH_HUB 0
#define CFG_TUH_CDC 1
#define CFG_TUH_HID_KEYBOARD 0
#define CFG_TUH_HID_MOUSE 0
diff --git a/hw/bsp/ea4357/board.mk b/hw/bsp/ea4357/board.mk
index dc002215b..dd987f476 100644
--- a/hw/bsp/ea4357/board.mk
+++ b/hw/bsp/ea4357/board.mk
@@ -6,9 +6,9 @@ CFLAGS += \
-mfloat-abi=hard \
-mfpu=fpv4-sp-d16 \
-nostdlib \
+ -D__USE_LPCOPEN \
-DCORE_M4 \
- -DCFG_TUSB_MCU=OPT_MCU_LPC43XX \
- -D__USE_LPCOPEN
+ -DCFG_TUSB_MCU=OPT_MCU_LPC43XX
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes
diff --git a/hw/bsp/ea4357/ea4357.c b/hw/bsp/ea4357/ea4357.c
index 193e19831..daa3a6bd0 100644
--- a/hw/bsp/ea4357/ea4357.c
+++ b/hw/bsp/ea4357/ea4357.c
@@ -163,19 +163,19 @@ void board_init(void)
#if CFG_TUSB_RHPORT0_MODE
Chip_USB0_Init();
-// // Reset controller
-// LPC_USB0->USBCMD_D |= 0x02;
-// while( LPC_USB0->USBCMD_D & 0x02 ) {}
-//
-// // Set mode
-// #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
-// LPC_USB0->USBMODE_H = USBMODE_HOST | (USBMODE_VBUS_HIGH << 5);
-//
-// LPC_USB0->PORTSC1_D |= (1<<24); // FIXME force full speed for debugging
-// #else // TODO OTG
-// LPC_USB0->USBMODE_D = USBMODE_DEVICE;
-// LPC_USB0->OTGSC = (1<<3) | (1<<0) /*| (1<<16)| (1<<24)| (1<<25)| (1<<26)| (1<<27)| (1<<28)| (1<<29)| (1<<30)*/;
-// #endif
+ // Reset controller
+ LPC_USB0->USBCMD_D |= 0x02;
+ while( LPC_USB0->USBCMD_D & 0x02 ) {}
+
+ // Set mode
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
+ LPC_USB0->USBMODE_H = USBMODE_HOST | (USBMODE_VBUS_HIGH << 5);
+
+ LPC_USB0->PORTSC1_D |= (1<<24); // FIXME force full speed for debugging
+ #else // TODO OTG
+ LPC_USB0->USBMODE_D = USBMODE_DEVICE;
+ LPC_USB0->OTGSC = (1<<3) | (1<<0) /*| (1<<16)| (1<<24)| (1<<25)| (1<<26)| (1<<27)| (1<<28)| (1<<29)| (1<<30)*/;
+ #endif
#endif
/* USB1
diff --git a/hw/bsp/mcb1800/mcb1800.c b/hw/bsp/mcb1800/mcb1800.c
index fdbe389a3..bfeb126fc 100644
--- a/hw/bsp/mcb1800/mcb1800.c
+++ b/hw/bsp/mcb1800/mcb1800.c
@@ -82,9 +82,9 @@ static const PINMUX_GRP_T pinmuxing[] =
{ 0xD, 12, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
{ 0xD, 13, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
{ 0xD, 14, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
- { 0x9, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
- { 0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
- { 0x9, 2, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+ { 0x9, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+ { 0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+ { 0x9, 2, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
// Button
{ 0x4, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLUP) },
@@ -93,19 +93,20 @@ static const PINMUX_GRP_T pinmuxing[] =
{ UART_PORT, UART_PIN_TX, SCU_MODE_PULLDOWN | SCU_MODE_FUNC2 },
{ UART_PORT, UART_PIN_RX, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 },
- // USB
- { 0x9, 5, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2 }, // P9_5 USB1_VBUS_EN, USB1 VBus function
- { 0x2, 5, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 }, // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION */
- { 0x6, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1 } // P6_3 USB0_PWR_EN, USB0 VBus function
+ // USB0
+ { 0x6, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1 }, // P6_3 USB0_PWR_EN, USB0 VBus function
+
+ { 0x9, 5, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2 }, // P9_5 USB1_VBUS_EN, USB1 VBus function
+ { 0x2, 5, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 }, // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION
};
/* Pin clock mux values, re-used structure, value in first index is meaningless */
static const PINMUX_GRP_T pinclockmuxing[] =
{
- {0, 0, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
- {0, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
- {0, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
- {0, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 0, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
};
// Invoked by startup code
@@ -172,7 +173,7 @@ void board_init(void)
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
LPC_USB0->USBMODE_H = USBMODE_HOST | (USBMODE_VBUS_HIGH << 5);
- LPC_USB0->PORTSC1_D |= (1<<24); // FIXME force full speed for debugging
+// LPC_USB0->PORTSC1_D |= (1<<24); // FIXME force full speed for debugging
#else // TODO OTG
LPC_USB0->USBMODE_D = USBMODE_DEVICE;
LPC_USB0->OTGSC = (1<<3) | (1<<0) /*| (1<<16)| (1<<24)| (1<<25)| (1<<26)| (1<<27)| (1<<28)| (1<<29)| (1<<30)*/;
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