From c5b8980398a8e79f6501af1f1b1e17e0a599fabf Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 22 Feb 2021 22:40:51 +0700 Subject: [PATCH] separate hcd_init from ehci --- src/host/ehci/ehci.c | 12 ++++-------- src/portable/nxp/transdimension/hcd_transdimension.c | 8 ++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index b5f872c81..5626abcc8 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -51,6 +51,7 @@ CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4096) static ehci_data_t ehci_data; // EHCI portable uint32_t hcd_ehci_register_addr(uint8_t rhport); +bool hcd_ehci_init (uint8_t rhport); // TODO move later //--------------------------------------------------------------------+ // PROTOTYPE @@ -100,16 +101,9 @@ static void qtd_init (ehci_qtd_t* p_qtd, void* buffer, uint16_t total_bytes); static inline void list_insert (ehci_link_t *current, ehci_link_t *new, uint8_t new_type); static inline ehci_link_t* list_next (ehci_link_t *p_link_pointer); -static bool ehci_init (uint8_t rhport); - //--------------------------------------------------------------------+ // HCD API //--------------------------------------------------------------------+ -bool hcd_init(uint8_t rhport) -{ - tu_memclr(&ehci_data, sizeof(ehci_data_t)); - return ehci_init(rhport); -} uint32_t hcd_uframe_number(uint8_t rhport) { @@ -206,8 +200,10 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr) } // EHCI controller init -static bool ehci_init(uint8_t rhport) +bool hcd_ehci_init(uint8_t rhport) { + tu_memclr(&ehci_data, sizeof(ehci_data_t)); + ehci_data.regs = (ehci_registers_t* ) hcd_ehci_register_addr(rhport); ehci_registers_t* regs = ehci_data.regs; diff --git a/src/portable/nxp/transdimension/hcd_transdimension.c b/src/portable/nxp/transdimension/hcd_transdimension.c index f8ad7c719..62b14364d 100644 --- a/src/portable/nxp/transdimension/hcd_transdimension.c +++ b/src/portable/nxp/transdimension/hcd_transdimension.c @@ -65,6 +65,14 @@ typedef struct #endif +// TODO better prototype later +extern bool hcd_ehci_init (uint8_t rhport); // from ehci.c + +bool hcd_init(uint8_t rhport) +{ + return hcd_ehci_init(rhport); +} + void hcd_int_enable(uint8_t rhport) { NVIC_EnableIRQ(_hcd_controller[rhport].irqnum);