temporarily remove osal_task_delay() from osal
- add hcd_uframe_number() API, update EHCI to return uframe number - get host running on ea4357
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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) | ||||
| //--------------------------------------------------------------------+ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 hathach
					hathach