rename common func to avoid conflict
This commit is contained in:
@@ -604,14 +604,14 @@ static void period_list_xfer_complete_isr(uint8_t hostid, uint8_t interval_ms)
|
||||
|
||||
// TODO abstract max loop guard for period
|
||||
while( !next_item.terminate &&
|
||||
!(interval_ms > 1 && period_1ms_addr == align32(next_item.address)) &&
|
||||
!(interval_ms > 1 && period_1ms_addr == tu_align32(next_item.address)) &&
|
||||
max_loop < (HCD_MAX_ENDPOINT + EHCI_MAX_ITD + EHCI_MAX_SITD)*CFG_TUSB_HOST_DEVICE_MAX)
|
||||
{
|
||||
switch ( next_item.type )
|
||||
{
|
||||
case EHCI_QUEUE_ELEMENT_QHD:
|
||||
{
|
||||
ehci_qhd_t *p_qhd_int = (ehci_qhd_t *) align32(next_item.address);
|
||||
ehci_qhd_t *p_qhd_int = (ehci_qhd_t *) tu_align32(next_item.address);
|
||||
if ( !p_qhd_int->qtd_overlay.halted )
|
||||
{
|
||||
qhd_xfer_complete_isr(p_qhd_int);
|
||||
@@ -653,7 +653,7 @@ static void qhd_xfer_error_isr(ehci_qhd_t * p_qhd)
|
||||
|
||||
if ( TUSB_XFER_CONTROL == xfer_type )
|
||||
{
|
||||
p_qhd->total_xferred_bytes -= min8_of(8, p_qhd->total_xferred_bytes); // subtract setup size
|
||||
p_qhd->total_xferred_bytes -= tu_min8(8, p_qhd->total_xferred_bytes); // subtract setup size
|
||||
|
||||
// control cannot be halted --> clear all qtd list
|
||||
p_qhd->p_qtd_list_head = NULL;
|
||||
@@ -702,14 +702,14 @@ static void xfer_error_isr(uint8_t hostid)
|
||||
|
||||
// TODO abstract max loop guard for period
|
||||
while( !next_item.terminate &&
|
||||
!(interval_ms > 1 && period_1ms_addr == align32(next_item.address)) &&
|
||||
!(interval_ms > 1 && period_1ms_addr == tu_align32(next_item.address)) &&
|
||||
period_max_loop < (HCD_MAX_ENDPOINT + EHCI_MAX_ITD + EHCI_MAX_SITD)*CFG_TUSB_HOST_DEVICE_MAX)
|
||||
{
|
||||
switch ( next_item.type )
|
||||
{
|
||||
case EHCI_QUEUE_ELEMENT_QHD:
|
||||
{
|
||||
ehci_qhd_t *p_qhd_int = (ehci_qhd_t *) align32(next_item.address);
|
||||
ehci_qhd_t *p_qhd_int = (ehci_qhd_t *) tu_align32(next_item.address);
|
||||
qhd_xfer_error_isr(p_qhd_int);
|
||||
}
|
||||
break;
|
||||
@@ -828,7 +828,7 @@ static inline ehci_qhd_t* get_async_head(uint8_t hostid)
|
||||
static inline ehci_link_t* get_period_head(uint8_t hostid, uint8_t interval_ms)
|
||||
{
|
||||
return (ehci_link_t*) (&ehci_data.period_head_arr[ hostid_to_data_idx(hostid) ]
|
||||
[ log2_of( min8_of(EHCI_FRAMELIST_SIZE, interval_ms) ) ] );
|
||||
[ tu_log2( tu_min8(EHCI_FRAMELIST_SIZE, interval_ms) ) ] );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -869,7 +869,7 @@ static inline tusb_xfer_type_t qhd_get_xfer_type(ehci_qhd_t const * p_qhd)
|
||||
|
||||
static inline ehci_qhd_t* qhd_next(ehci_qhd_t const * p_qhd)
|
||||
{
|
||||
return (ehci_qhd_t*) align32(p_qhd->next.address);
|
||||
return (ehci_qhd_t*) tu_align32(p_qhd->next.address);
|
||||
}
|
||||
|
||||
static inline ehci_qhd_t* qhd_get_from_pipe_handle(pipe_handle_t pipe_hdl)
|
||||
@@ -907,7 +907,7 @@ static inline ehci_qtd_t* qtd_find_free(uint8_t dev_addr)
|
||||
|
||||
static inline ehci_qtd_t* qtd_next(ehci_qtd_t const * p_qtd )
|
||||
{
|
||||
return (ehci_qtd_t*) align32(p_qtd->next.address);
|
||||
return (ehci_qtd_t*) tu_align32(p_qtd->next.address);
|
||||
}
|
||||
|
||||
static inline void qtd_remove_1st_from_qhd(ehci_qhd_t *p_qhd)
|
||||
@@ -965,7 +965,7 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si
|
||||
(interval == 2) ? BIN8(10101010) : BIN8(01000100);
|
||||
}else
|
||||
{
|
||||
p_qhd->interval_ms = (uint8_t) min16_of( 1 << (interval-4), 255 );
|
||||
p_qhd->interval_ms = (uint8_t) tu_min16( 1 << (interval-4), 255 );
|
||||
p_qhd->interrupt_smask = BIT_(interval % 8);
|
||||
}
|
||||
}else
|
||||
@@ -1019,7 +1019,7 @@ static void qtd_init(ehci_qtd_t* p_qtd, uint32_t data_ptr, uint16_t total_bytes)
|
||||
p_qtd->buffer[0] = data_ptr;
|
||||
for(uint8_t i=1; i<5; i++)
|
||||
{
|
||||
p_qtd->buffer[i] |= align4k( p_qtd->buffer[i-1] ) + 4096;
|
||||
p_qtd->buffer[i] |= tu_align4k( p_qtd->buffer[i-1] ) + 4096;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1032,15 +1032,15 @@ static inline void list_insert(ehci_link_t *current, ehci_link_t *new, uint8_t n
|
||||
|
||||
static inline ehci_link_t* list_next(ehci_link_t *p_link_pointer)
|
||||
{
|
||||
return (ehci_link_t*) align32(p_link_pointer->address);
|
||||
return (ehci_link_t*) tu_align32(p_link_pointer->address);
|
||||
}
|
||||
|
||||
static ehci_link_t* list_find_previous_item(ehci_link_t* p_head, ehci_link_t* p_current)
|
||||
{
|
||||
ehci_link_t *p_prev = p_head;
|
||||
uint32_t max_loop = 0;
|
||||
while( (align32(p_prev->address) != (uint32_t) p_head) && // not loop around
|
||||
(align32(p_prev->address) != (uint32_t) p_current) && // not found yet
|
||||
while( (tu_align32(p_prev->address) != (uint32_t) p_head) && // not loop around
|
||||
(tu_align32(p_prev->address) != (uint32_t) p_current) && // not found yet
|
||||
!p_prev->terminate && // not advanceable
|
||||
max_loop < HCD_MAX_ENDPOINT)
|
||||
{
|
||||
@@ -1048,7 +1048,7 @@ static ehci_link_t* list_find_previous_item(ehci_link_t* p_head, ehci_link_t* p_
|
||||
max_loop++;
|
||||
}
|
||||
|
||||
return (align32(p_prev->address) != (uint32_t) p_head) ? p_prev : NULL;
|
||||
return (tu_align32(p_prev->address) != (uint32_t) p_head) ? p_prev : NULL;
|
||||
}
|
||||
|
||||
static tusb_error_t list_remove_qhd(ehci_link_t* p_head, ehci_link_t* p_remove)
|
||||
|
||||
@@ -389,15 +389,15 @@ static ohci_ed_t * ed_list_find_previous(ohci_ed_t const * p_head, ohci_ed_t con
|
||||
|
||||
TU_ASSERT(p_prev, NULL);
|
||||
|
||||
while ( align16(p_prev->next_ed) != 0 && /* not reach null */
|
||||
align16(p_prev->next_ed) != (uint32_t) p_ed && /* not found yet */
|
||||
while ( tu_align16(p_prev->next_ed) != 0 && /* not reach null */
|
||||
tu_align16(p_prev->next_ed) != (uint32_t) p_ed && /* not found yet */
|
||||
max_loop > 0)
|
||||
{
|
||||
p_prev = (ohci_ed_t const *) align16(p_prev->next_ed);
|
||||
p_prev = (ohci_ed_t const *) tu_align16(p_prev->next_ed);
|
||||
max_loop--;
|
||||
}
|
||||
|
||||
return ( align16(p_prev->next_ed) == (uint32_t) p_ed ) ? (ohci_ed_t*) p_prev : NULL;
|
||||
return ( tu_align16(p_prev->next_ed) == (uint32_t) p_ed ) ? (ohci_ed_t*) p_prev : NULL;
|
||||
}
|
||||
|
||||
static void ed_list_insert(ohci_ed_t * p_pre, ohci_ed_t * p_ed)
|
||||
@@ -410,7 +410,7 @@ static void ed_list_remove(ohci_ed_t * p_head, ohci_ed_t * p_ed)
|
||||
{
|
||||
ohci_ed_t * const p_prev = ed_list_find_previous(p_head, p_ed);
|
||||
|
||||
p_prev->next_ed = (p_prev->next_ed & 0x0fUL) | align16(p_ed->next_ed);
|
||||
p_prev->next_ed = (p_prev->next_ed & 0x0fUL) | tu_align16(p_ed->next_ed);
|
||||
// point the removed ED's next pointer to list head to make sure HC can always safely move away from this ED
|
||||
p_ed->next_ed = (uint32_t) p_head;
|
||||
p_ed->used = 0; // free ED
|
||||
@@ -457,13 +457,13 @@ static ohci_gtd_t * gtd_find_free(uint8_t dev_addr)
|
||||
static void td_insert_to_ed(ohci_ed_t* p_ed, ohci_gtd_t * p_gtd)
|
||||
{
|
||||
// tail is always NULL
|
||||
if ( align16(p_ed->td_head.address) == 0 )
|
||||
if ( tu_align16(p_ed->td_head.address) == 0 )
|
||||
{ // TD queue is empty --> head = TD
|
||||
p_ed->td_head.address |= (uint32_t) p_gtd;
|
||||
}
|
||||
else
|
||||
{ // TODO currently only support queue up to 2 TD each endpoint at a time
|
||||
((ohci_gtd_t*) align16(p_ed->td_head.address))->next_td = (uint32_t) p_gtd;
|
||||
((ohci_gtd_t*) tu_align16(p_ed->td_head.address))->next_td = (uint32_t) p_gtd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl)
|
||||
bool hcd_pipe_is_busy(pipe_handle_t pipe_hdl)
|
||||
{
|
||||
ohci_ed_t const * const p_ed = ed_from_pipe_handle(pipe_hdl);
|
||||
return align16(p_ed->td_head.address) != align16(p_ed->td_tail.address);
|
||||
return tu_align16(p_ed->td_head.address) != tu_align16(p_ed->td_tail.address);
|
||||
}
|
||||
|
||||
bool hcd_pipe_is_error(pipe_handle_t pipe_hdl)
|
||||
@@ -601,8 +601,8 @@ static inline ohci_ed_t* gtd_get_ed(ohci_gtd_t const * const p_qtd)
|
||||
static inline uint32_t gtd_xfer_byte_left(uint32_t buffer_end, uint32_t current_buffer) ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uint32_t gtd_xfer_byte_left(uint32_t buffer_end, uint32_t current_buffer)
|
||||
{ // 5.2.9 OHCI sample code
|
||||
return (align4k(buffer_end ^ current_buffer) ? 0x1000 : 0) +
|
||||
offset4k(buffer_end) - offset4k(current_buffer) + 1;
|
||||
return (tu_align4k(buffer_end ^ current_buffer) ? 0x1000 : 0) +
|
||||
tu_offset4k(buffer_end) - tu_offset4k(current_buffer) + 1;
|
||||
}
|
||||
|
||||
static void done_queue_isr(uint8_t hostid)
|
||||
@@ -610,7 +610,7 @@ static void done_queue_isr(uint8_t hostid)
|
||||
uint8_t max_loop = (CFG_TUSB_HOST_DEVICE_MAX+1)*(HCD_MAX_XFER+OHCI_MAX_ITD);
|
||||
|
||||
// done head is written in reversed order of completion --> need to reverse the done queue first
|
||||
ohci_td_item_t* td_head = list_reverse ( (ohci_td_item_t*) align16(ohci_data.hcca.done_head) );
|
||||
ohci_td_item_t* td_head = list_reverse ( (ohci_td_item_t*) tu_align16(ohci_data.hcca.done_head) );
|
||||
|
||||
while( td_head != NULL && max_loop > 0)
|
||||
{
|
||||
@@ -637,7 +637,7 @@ static void done_queue_isr(uint8_t hostid)
|
||||
if ((event != TUSB_EVENT_XFER_COMPLETE))
|
||||
{
|
||||
p_ed->td_tail.address &= 0x0Ful;
|
||||
p_ed->td_tail.address |= align16(p_ed->td_head.address); // mark halted EP as empty queue
|
||||
p_ed->td_tail.address |= tu_align16(p_ed->td_head.address); // mark halted EP as empty queue
|
||||
if ( event == TUSB_EVENT_XFER_STALLED ) p_ed->is_stalled = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -643,7 +643,7 @@ static inline uint8_t get_configure_number_for_device(tusb_desc_device_t* dev_de
|
||||
// invoke callback to ask user which configuration to select
|
||||
if (tuh_device_attached_cb)
|
||||
{
|
||||
config_num = min8_of(1, tuh_device_attached_cb(dev_desc) );
|
||||
config_num = tu_min8(1, tuh_device_attached_cb(dev_desc) );
|
||||
}
|
||||
|
||||
return config_num;
|
||||
|
||||
Reference in New Issue
Block a user