separate hcd_init from ehci

This commit is contained in:
hathach 2021-02-22 22:40:51 +07:00
parent 1e07fc024c
commit c5b8980398
2 changed files with 12 additions and 8 deletions

View File

@ -51,6 +51,7 @@ CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4096) static ehci_data_t ehci_data;
// EHCI portable // EHCI portable
uint32_t hcd_ehci_register_addr(uint8_t rhport); uint32_t hcd_ehci_register_addr(uint8_t rhport);
bool hcd_ehci_init (uint8_t rhport); // TODO move later
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// PROTOTYPE // 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 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 inline ehci_link_t* list_next (ehci_link_t *p_link_pointer);
static bool ehci_init (uint8_t rhport);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// HCD API // 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) 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 // 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_data.regs = (ehci_registers_t* ) hcd_ehci_register_addr(rhport);
ehci_registers_t* regs = ehci_data.regs; ehci_registers_t* regs = ehci_data.regs;

View File

@ -65,6 +65,14 @@ typedef struct
#endif #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) void hcd_int_enable(uint8_t rhport)
{ {
NVIC_EnableIRQ(_hcd_controller[rhport].irqnum); NVIC_EnableIRQ(_hcd_controller[rhport].irqnum);