diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 075a7f8d..2a598f05 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -208,7 +208,7 @@ tusb_error_t cdcd_open(uint8_t rhport, tusb_desc_interface_t const * p_interface { if ( CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL != p_interface_desc->bInterfaceSubClass) return TUSB_ERROR_CDC_UNSUPPORTED_SUBCLASS; - if ( !(is_in_range(CDC_COMM_PROTOCOL_ATCOMMAND, p_interface_desc->bInterfaceProtocol, CDC_COMM_PROTOCOL_ATCOMMAND_CDMA) || + if ( !(tu_within(CDC_COMM_PROTOCOL_ATCOMMAND, p_interface_desc->bInterfaceProtocol, CDC_COMM_PROTOCOL_ATCOMMAND_CDMA) || 0xff == p_interface_desc->bInterfaceProtocol) ) { return TUSB_ERROR_CDC_UNSUPPORTED_PROTOCOL; @@ -282,7 +282,7 @@ tusb_error_t cdcd_control_request_st(uint8_t rhport, tusb_control_request_t cons if ( (CDC_REQUEST_GET_LINE_CODING == p_request->bRequest) || (CDC_REQUEST_SET_LINE_CODING == p_request->bRequest) ) { - uint16_t len = min16_of(sizeof(cdc_line_coding_t), p_request->wLength); + uint16_t len = tu_min16(sizeof(cdc_line_coding_t), p_request->wLength); usbd_control_xfer_st(rhport, p_request->bmRequestType_bit.direction, &p_cdc->line_coding, len); // Invoke callback diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c index 6950759d..ca448ba5 100644 --- a/src/class/cdc/cdc_host.c +++ b/src/class/cdc/cdc_host.c @@ -149,7 +149,7 @@ tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_ if ( CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL != p_interface_desc->bInterfaceSubClass) return TUSB_ERROR_CDC_UNSUPPORTED_SUBCLASS; - if ( !(is_in_range(CDC_COMM_PROTOCOL_ATCOMMAND, p_interface_desc->bInterfaceProtocol, CDC_COMM_PROTOCOL_ATCOMMAND_CDMA) || + if ( !(tu_within(CDC_COMM_PROTOCOL_ATCOMMAND, p_interface_desc->bInterfaceProtocol, CDC_COMM_PROTOCOL_ATCOMMAND_CDMA) || 0xff == p_interface_desc->bInterfaceProtocol) ) { return TUSB_ERROR_CDC_UNSUPPORTED_PROTOCOL; diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 410359e6..b1cd1d1b 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -412,8 +412,8 @@ tusb_error_t hidd_control_request_st(uint8_t rhport, tusb_control_request_t cons //------------- STD Request -------------// if (p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD) { - uint8_t const desc_type = u16_high_u8(p_request->wValue); - uint8_t const desc_index = u16_low_u8 (p_request->wValue); + uint8_t const desc_type = tu_u16_high(p_request->wValue); + uint8_t const desc_index = tu_u16_low (p_request->wValue); (void) desc_index; if (p_request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT) @@ -434,8 +434,8 @@ tusb_error_t hidd_control_request_st(uint8_t rhport, tusb_control_request_t cons if( HID_REQ_CONTROL_GET_REPORT == p_request->bRequest ) { // wValue = Report Type | Report ID - uint8_t const report_type = u16_high_u8(p_request->wValue); - uint8_t const report_id = u16_low_u8(p_request->wValue); + uint8_t const report_type = tu_u16_high(p_request->wValue); + uint8_t const report_id = tu_u16_low(p_request->wValue); uint16_t xferlen; if ( p_hid->get_report_cb ) @@ -455,8 +455,8 @@ tusb_error_t hidd_control_request_st(uint8_t rhport, tusb_control_request_t cons usbd_control_xfer_st(rhport, p_request->bmRequestType_bit.direction, _usbd_ctrl_buf, p_request->wLength); // wValue = Report Type | Report ID - uint8_t const report_type = u16_high_u8(p_request->wValue); - uint8_t const report_id = u16_low_u8(p_request->wValue); + uint8_t const report_type = tu_u16_high(p_request->wValue); + uint8_t const report_id = tu_u16_low(p_request->wValue); if ( p_hid->set_report_cb ) { @@ -466,7 +466,7 @@ tusb_error_t hidd_control_request_st(uint8_t rhport, tusb_control_request_t cons else if (HID_REQ_CONTROL_SET_IDLE == p_request->bRequest) { // TODO idle rate of report - p_hid->idle_rate = u16_high_u8(p_request->wValue); + p_hid->idle_rate = tu_u16_high(p_request->wValue); dcd_control_status(rhport, p_request->bmRequestType_bit.direction); } else if (HID_REQ_CONTROL_GET_IDLE == p_request->bRequest) diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index a11212c4..3335ad9b 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -531,7 +531,7 @@ static void proc_read10_cmd(uint8_t rhport, mscd_interface_t* p_msc) uint32_t const lba = rdwr10_get_lba(p_cbw->command) + (p_msc->xferred_len / block_sz); // remaining bytes capped at class buffer - int32_t nbytes = (int32_t) min32_of(sizeof(_mscd_buf), p_cbw->xfer_bytes-p_msc->xferred_len); + int32_t nbytes = (int32_t) tu_min32(sizeof(_mscd_buf), p_cbw->xfer_bytes-p_msc->xferred_len); // Application can consume smaller bytes nbytes = tud_msc_read10_cb(p_cbw->lun, lba, p_msc->xferred_len % block_sz, _mscd_buf, (uint32_t) nbytes); @@ -561,7 +561,7 @@ static void proc_write10_cmd(uint8_t rhport, mscd_interface_t* p_msc) msc_cbw_t const * p_cbw = &p_msc->cbw; // remaining bytes capped at class buffer - int32_t nbytes = (int32_t) min32_of(sizeof(_mscd_buf), p_cbw->xfer_bytes-p_msc->xferred_len); + int32_t nbytes = (int32_t) tu_min32(sizeof(_mscd_buf), p_cbw->xfer_bytes-p_msc->xferred_len); // Write10 callback will be called later when usb transfer complete TU_ASSERT( dcd_edpt_xfer(rhport, p_msc->ep_out, _mscd_buf, nbytes), ); diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h index e8baa9de..778e7067 100644 --- a/src/common/tusb_common.h +++ b/src/common/tusb_common.h @@ -151,119 +151,94 @@ static inline bool mem_all_zero(void const* buffer, uint32_t size) //------------- Conversion -------------// -/// form an uint32_t from 4 x uint8_t -static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) +static inline uint32_t tu_u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) { return ( ((uint32_t) b1) << 24) + ( ((uint32_t) b2) << 16) + ( ((uint32_t) b3) << 8) + b4; } -static inline uint8_t u16_high_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE; -static inline uint8_t u16_high_u8(uint16_t u16) +static inline uint8_t tu_u16_high(uint16_t u16) { return (uint8_t) ( ((uint16_t) (u16 >> 8)) & 0x00ff); } -static inline uint8_t u16_low_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE; -static inline uint8_t u16_low_u8(uint16_t u16) +static inline uint8_t tu_u16_low(uint16_t u16) { return (uint8_t) (u16 & 0x00ff); } -static inline uint16_t u16_le2be(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE; -static inline uint16_t u16_le2be(uint16_t u16) +static inline uint16_t tu_u16_le2be(uint16_t u16) { - return ((uint16_t)(u16_low_u8(u16) << 8)) | u16_high_u8(u16); + return ((uint16_t)(tu_u16_low(u16) << 8)) | tu_u16_high(u16); } //------------- Min -------------// -static inline uint8_t min8_of(uint8_t x, uint8_t y) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint8_t min8_of(uint8_t x, uint8_t y) +static inline uint8_t tu_min8(uint8_t x, uint8_t y) { return (x < y) ? x : y; } -static inline uint16_t min16_of(uint16_t x, uint16_t y) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint16_t min16_of(uint16_t x, uint16_t y) +static inline uint16_t tu_min16(uint16_t x, uint16_t y) { return (x < y) ? x : y; } -static inline uint32_t min32_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t min32_of(uint32_t x, uint32_t y) +static inline uint32_t tu_min32(uint32_t x, uint32_t y) { return (x < y) ? x : y; } //------------- Max -------------// -static inline uint32_t max32_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t max32_of(uint32_t x, uint32_t y) +static inline uint32_t tu_max32(uint32_t x, uint32_t y) { return (x > y) ? x : y; } -static inline uint16_t max16_of(uint16_t x, uint16_t y) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint16_t max16_of(uint16_t x, uint16_t y) +static inline uint16_t tu_max16(uint16_t x, uint16_t y) { return (x > y) ? x : y; } //------------- Align -------------// -static inline uint32_t align32 (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t align32 (uint32_t value) +static inline uint32_t tu_align32 (uint32_t value) { return (value & 0xFFFFFFE0UL); } -static inline uint32_t align16 (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t align16 (uint32_t value) +static inline uint32_t tu_align16 (uint32_t value) { return (value & 0xFFFFFFF0UL); } -static inline uint32_t align_n (uint32_t alignment, uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t align_n (uint32_t alignment, uint32_t value) +static inline uint32_t tu_align_n (uint32_t alignment, uint32_t value) { return value & ((uint32_t) ~(alignment-1)); } -static inline uint32_t align4k (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t align4k (uint32_t value) +static inline uint32_t tu_align4k (uint32_t value) { return (value & 0xFFFFF000UL); } -static inline uint32_t offset4k(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t offset4k(uint32_t value) +static inline uint32_t tu_offset4k(uint32_t value) { return (value & 0xFFFUL); } //------------- Mathematics -------------// -static inline uint32_t abs_of(int32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint32_t abs_of(int32_t value) +static inline uint32_t tu_abs(int32_t value) { return (value < 0) ? (-value) : value; } /// inclusive range checking -static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) +static inline bool tu_within(uint32_t lower, uint32_t value, uint32_t upper) { return (lower <= value) && (value <= upper); } -/// exclusive range checking -static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper) -{ - return (lower < value) && (value < upper); -} - // TODO use clz -static inline uint8_t log2_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint8_t log2_of(uint32_t value) +static inline uint8_t tu_log2(uint32_t value) { uint8_t result = 0; // log2 of a value is its MSB's position @@ -275,8 +250,7 @@ static inline uint8_t log2_of(uint32_t value) } // return the number of set bits in value -static inline uint8_t cardinality_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; -static inline uint8_t cardinality_of(uint32_t value) +static inline uint8_t tu_cardof(uint32_t value) { // Brian Kernighan's method goes through as many iterations as there are set bits. So if we have a 32-bit word with only // the high bit set, then it will only go once through the loop diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c index 09763bee..e90264f8 100644 --- a/src/common/tusb_fifo.c +++ b/src/common/tusb_fifo.c @@ -54,7 +54,7 @@ #endif -static inline uint16_t min16_of(uint16_t x, uint16_t y) +static inline uint16_t tu_min16(uint16_t x, uint16_t y) { return (x < y) ? x : y; } @@ -136,7 +136,7 @@ uint16_t tu_fifo_read_n (tu_fifo_t* f, void * p_buffer, uint16_t count) if( tu_fifo_empty(f) ) return 0; /* Limit up to fifo's count */ - count = min16_of(count, f->count); + count = tu_min16(count, f->count); if( count == 0 ) return 0; mutex_lock_if_needed(f); @@ -145,7 +145,7 @@ uint16_t tu_fifo_read_n (tu_fifo_t* f, void * p_buffer, uint16_t count) * case 1: ....RxxxxW....... * case 2: xxxxxW....Rxxxxxx */ -// uint16_t index2upper = min16_of(count, f->count-f->rd_idx); +// uint16_t index2upper = tu_min16(count, f->count-f->rd_idx); uint8_t* p_buf = (uint8_t*) p_buffer; uint16_t len = 0; diff --git a/src/device/usbd.c b/src/device/usbd.c index 79ad8ffa..ea5e2488 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -377,9 +377,9 @@ static tusb_error_t proc_control_request_st(uint8_t rhport, tusb_control_request //------------- Class/Interface Specific Request -------------// else if ( TUSB_REQ_RCPT_INTERFACE == p_request->bmRequestType_bit.recipient ) { - if (_usbd_dev.itf2drv[ u16_low_u8(p_request->wIndex) ] < USBD_CLASS_DRIVER_COUNT) + if (_usbd_dev.itf2drv[ tu_u16_low(p_request->wIndex) ] < USBD_CLASS_DRIVER_COUNT) { - STASK_INVOKE( usbd_class_drivers[ _usbd_dev.itf2drv[ u16_low_u8(p_request->wIndex) ] ].control_req_st(rhport, p_request), error ); + STASK_INVOKE( usbd_class_drivers[ _usbd_dev.itf2drv[ tu_u16_low(p_request->wIndex) ] ].control_req_st(rhport, p_request), error ); }else { dcd_control_stall(rhport); // Stall unsupported request @@ -392,7 +392,7 @@ static tusb_error_t proc_control_request_st(uint8_t rhport, tusb_control_request { if (TUSB_REQ_GET_STATUS == p_request->bRequest ) { - uint16_t status = dcd_edpt_stalled(rhport, u16_low_u8(p_request->wIndex)) ? 0x0001 : 0x0000; + uint16_t status = dcd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000; memcpy(_usbd_ctrl_buf, &status, 2); usbd_control_xfer_st(rhport, p_request->bmRequestType_bit.direction, _usbd_ctrl_buf, 2); @@ -400,13 +400,13 @@ static tusb_error_t proc_control_request_st(uint8_t rhport, tusb_control_request else if (TUSB_REQ_CLEAR_FEATURE == p_request->bRequest ) { // only endpoint feature is halted/stalled - dcd_edpt_clear_stall(rhport, u16_low_u8(p_request->wIndex)); + dcd_edpt_clear_stall(rhport, tu_u16_low(p_request->wIndex)); dcd_control_status(rhport, p_request->bmRequestType_bit.direction); } else if (TUSB_REQ_SET_FEATURE == p_request->bRequest ) { // only endpoint feature is halted/stalled - dcd_edpt_stall(rhport, u16_low_u8(p_request->wIndex)); + dcd_edpt_stall(rhport, tu_u16_low(p_request->wIndex)); dcd_control_status(rhport, p_request->bmRequestType_bit.direction); } else @@ -484,8 +484,8 @@ static uint16_t get_descriptor(uint8_t rhport, tusb_control_request_t const * co { (void) rhport; - tusb_desc_type_t const desc_type = (tusb_desc_type_t) u16_high_u8(p_request->wValue); - uint8_t const desc_index = u16_low_u8( p_request->wValue ); + tusb_desc_type_t const desc_type = (tusb_desc_type_t) tu_u16_high(p_request->wValue); + uint8_t const desc_index = tu_u16_low( p_request->wValue ); uint8_t const * desc_data = NULL ; uint16_t len = 0; @@ -532,7 +532,7 @@ static uint16_t get_descriptor(uint8_t rhport, tusb_control_request_t const * co TU_ASSERT( desc_data != NULL, 0); // up to Host's length - len = min16_of(p_request->wLength, len ); + len = tu_min16(p_request->wLength, len ); (*pp_buffer) = desc_data; return len; diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index 32fcc814..84821e3f 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -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) diff --git a/src/host/ohci/ohci.c b/src/host/ohci/ohci.c index 644dbfa0..1c9f3f29 100644 --- a/src/host/ohci/ohci.c +++ b/src/host/ohci/ohci.c @@ -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; } diff --git a/src/host/usbh.c b/src/host/usbh.c index 6d1cd37a..8b858b2d 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -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; diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index 72cd8d0b..1c91779a 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -178,7 +178,7 @@ static void edpt_dma_end(void) static void xact_control_start(void) { // Each transaction is up to 64 bytes - uint8_t const xact_len = min16_of(_dcd.control.total_len-_dcd.control.actual_len, MAX_PACKET_SIZE); + uint8_t const xact_len = tu_min16(_dcd.control.total_len-_dcd.control.actual_len, MAX_PACKET_SIZE); if ( _dcd.control.dir == TUSB_DIR_OUT ) { @@ -274,7 +274,7 @@ static void xact_in_prepare(uint8_t epnum) nom_xfer_t* xfer = get_td(epnum, TUSB_DIR_IN); // Each transaction is up to Max Packet Size - uint8_t const xact_len = min16_of(xfer->total_len - xfer->actual_len, xfer->mps); + uint8_t const xact_len = tu_min16(xfer->total_len - xfer->actual_len, xfer->mps); NRF_USBD->EPIN[epnum].PTR = (uint32_t) xfer->buffer; NRF_USBD->EPIN[epnum].MAXCNT = xact_len; diff --git a/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c b/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c index 0eaecf1b..3e536312 100644 --- a/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c +++ b/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c @@ -497,7 +497,7 @@ bool dcd_edpt_busy(edpt_hdl_t edpt_hdl) static void queue_xfer_to_buffer(uint8_t ep_id, uint8_t buff_idx, uint16_t buff_addr_offset, uint16_t total_bytes) { - uint16_t const queued_bytes = min16_of(total_bytes, DCD_11U_13U_MAX_BYTE_PER_TD); + uint16_t const queued_bytes = tu_min16(total_bytes, DCD_11U_13U_MAX_BYTE_PER_TD); dcd_data.current_td[ep_id].queued_bytes_in_buff[buff_idx] = queued_bytes; dcd_data.current_td[ep_id].remaining_bytes -= queued_bytes; diff --git a/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c b/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c index a87e7d89..8c87984e 100644 --- a/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c +++ b/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c @@ -312,7 +312,7 @@ static inline uint16_t length_byte2dword(uint16_t length_in_bytes) static tusb_error_t pipe_control_xfer(uint8_t ep_id, uint8_t* p_buffer, uint16_t length) { - uint16_t const packet_len = min16_of(length, CFG_TUD_ENDOINT0_SIZE); + uint16_t const packet_len = tu_min16(length, CFG_TUD_ENDOINT0_SIZE); if (ep_id) { @@ -355,7 +355,7 @@ static tusb_error_t pipe_control_read(void * buffer, uint16_t length) LPC_USB->USBCtrl = USBCTRL_READ_ENABLE_MASK; // logical endpoint = 0 while ((LPC_USB->USBRxPLen & USBRXPLEN_PACKET_READY_MASK) == 0) {} // TODO blocking, should have timeout - uint16_t actual_length = min16_of(length, (uint16_t) (LPC_USB->USBRxPLen & USBRXPLEN_PACKET_LENGTH_MASK) ); + uint16_t actual_length = tu_min16(length, (uint16_t) (LPC_USB->USBRxPLen & USBRXPLEN_PACKET_LENGTH_MASK) ); uint32_t *p_read_data = (uint32_t*) buffer; for( uint16_t count=0; count < length_byte2dword(actual_length); count++) { diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 61f82971..792a009f 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -209,7 +209,7 @@ static void qtd_init(dcd_qtd_t* p_qtd, void * data_ptr, uint16_t total_bytes) p_qtd->buffer[0] = (uint32_t) 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; } } } diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_ehci_init.c b/tests/lpc18xx_43xx/test/host/ehci/test_ehci_init.c index f3194433..69b7c1dd 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_ehci_init.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_ehci_init.c @@ -107,7 +107,7 @@ void test_hcd_init_async_list(void) TEST_ASSERT_EQUAL_HEX(async_head, regs->async_list_base); - TEST_ASSERT_EQUAL_HEX(async_head, align32( (uint32_t) async_head) ); + TEST_ASSERT_EQUAL_HEX(async_head, tu_align32( (uint32_t) async_head) ); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, async_head->next.type); TEST_ASSERT_FALSE(async_head->next.terminate); @@ -118,7 +118,7 @@ void test_hcd_init_async_list(void) void check_qhd_endpoint_link(ehci_link_t *p_prev, ehci_qhd_t *p_qhd) { //------------- period list check -------------// - TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, align32(p_prev->address)); + TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, tu_align32(p_prev->address)); TEST_ASSERT_FALSE(p_prev->terminate); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, p_prev->type); } diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c index c2d52ce4..a26b990d 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c @@ -143,7 +143,7 @@ void verify_bulk_open_qhd(ehci_qhd_t *p_qhd, tusb_desc_endpoint_t const * desc_e TEST_ASSERT_EQUAL(class_code, p_qhd->class_code); //------------- async list check -------------// - TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, align32(async_head->next.address)); + TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, tu_align32(async_head->next.address)); TEST_ASSERT_FALSE(async_head->next.terminate); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, async_head->next.type); } @@ -164,7 +164,7 @@ void test_open_bulk_qhd_data(void) verify_bulk_open_qhd(p_qhd, desc_endpoint, TUSB_CLASS_MSC); //------------- async list check -------------// - TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, align32(async_head->next.address)); + TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, tu_align32(async_head->next.address)); TEST_ASSERT_FALSE(async_head->next.terminate); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, async_head->next.type); } @@ -194,7 +194,7 @@ void test_bulk_close(void) hcd_pipe_close(pipe_hdl); TEST_ASSERT(p_qhd->is_removing); - TEST_ASSERT( align32(async_head->next.address) != (uint32_t) p_qhd ); - TEST_ASSERT_EQUAL_HEX( (uint32_t) async_head, align32(p_qhd->next.address) ); + TEST_ASSERT( tu_align32(async_head->next.address) != (uint32_t) p_qhd ); + TEST_ASSERT_EQUAL_HEX( (uint32_t) async_head, tu_align32(p_qhd->next.address) ); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, p_qhd->next.type); } diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c index e3d78f66..a52c721f 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c @@ -140,7 +140,7 @@ void verify_qtd(ehci_qtd_t *p_qtd, uint8_t p_data[], uint16_t length) TEST_ASSERT_EQUAL_HEX( p_data, p_qtd->buffer[0] ); for(uint8_t i=1; i<5; i++) { - TEST_ASSERT_EQUAL_HEX( align4k((uint32_t) (p_data+4096*i)), align4k(p_qtd->buffer[i]) ); + TEST_ASSERT_EQUAL_HEX( tu_align4k((uint32_t) (p_data+4096*i)), tu_align4k(p_qtd->buffer[i]) ); } } @@ -193,7 +193,7 @@ void test_bulk_xfer_double(void) //------------- list tail -------------// TEST_ASSERT_NOT_NULL(p_tail); verify_qtd(p_tail, data2, sizeof(data2)); - TEST_ASSERT_EQUAL_HEX( align32(p_head->next.address), p_tail); + TEST_ASSERT_EQUAL_HEX( tu_align32(p_head->next.address), p_tail); TEST_ASSERT_EQUAL(EHCI_PID_IN, p_tail->pid); TEST_ASSERT_TRUE(p_tail->next.terminate); TEST_ASSERT_TRUE(p_tail->int_on_complete); diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_open.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_open.c index 1143b9fa..22cbf756 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_open.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_open.c @@ -142,7 +142,7 @@ void test_control_open_qhd_data(void) TEST_ASSERT_FALSE(p_control_qhd->head_list_flag); //------------- async list check -------------// - TEST_ASSERT_EQUAL_HEX((uint32_t) p_control_qhd, align32(async_head->next.address)); + TEST_ASSERT_EQUAL_HEX((uint32_t) p_control_qhd, tu_align32(async_head->next.address)); TEST_ASSERT_FALSE(async_head->next.terminate); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, async_head->next.type); } @@ -191,6 +191,6 @@ void test_control_close(void) TEST_ASSERT(p_control_qhd->is_removing); TEST_ASSERT(p_control_qhd->used); - TEST_ASSERT( align32(get_async_head(hostid)->next.address) != (uint32_t) p_control_qhd ); - TEST_ASSERT_EQUAL( get_async_head(hostid), align32(p_control_qhd->next.address)); + TEST_ASSERT( tu_align32(get_async_head(hostid)->next.address) != (uint32_t) p_control_qhd ); + TEST_ASSERT_EQUAL( get_async_head(hostid), tu_align32(p_control_qhd->next.address)); } diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_open.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_open.c index 1f8fc9a1..f39021ef 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_open.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_open.c @@ -136,7 +136,7 @@ void verify_int_qhd(ehci_qhd_t *p_qhd, tusb_desc_endpoint_t const * desc_endpoin void check_int_endpoint_link(ehci_qhd_t *p_prev, ehci_qhd_t *p_qhd) { //------------- period list check -------------// - TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, align32(p_prev->next.address)); + TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, tu_align32(p_prev->next.address)); TEST_ASSERT_FALSE(p_prev->next.terminate); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, p_prev->next.type); } @@ -181,7 +181,7 @@ void test_open_interrupt_hs_interval_2(void) p_int_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1].qhd[ pipe_hdl.index ]; TEST_ASSERT_EQUAL(0 , p_int_qhd->interval_ms); - TEST_ASSERT_EQUAL(4 , cardinality_of(p_int_qhd->interrupt_smask)); // either 10101010 or 01010101 + TEST_ASSERT_EQUAL(4 , tu_cardof(p_int_qhd->interrupt_smask)); // either 10101010 or 01010101 check_int_endpoint_link(period_head_arr, p_int_qhd); } @@ -195,7 +195,7 @@ void test_open_interrupt_hs_interval_3(void) p_int_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1].qhd[ pipe_hdl.index ]; TEST_ASSERT_EQUAL(0, p_int_qhd->interval_ms); - TEST_ASSERT_EQUAL(2, cardinality_of(p_int_qhd->interrupt_smask) ); + TEST_ASSERT_EQUAL(2, tu_cardof(p_int_qhd->interrupt_smask) ); check_int_endpoint_link(period_head_arr, p_int_qhd); } @@ -209,7 +209,7 @@ void test_open_interrupt_hs_interval_4(void) p_int_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1].qhd[ pipe_hdl.index ]; TEST_ASSERT_EQUAL(1, p_int_qhd->interval_ms); - TEST_ASSERT_EQUAL(1, cardinality_of(p_int_qhd->interrupt_smask) ); + TEST_ASSERT_EQUAL(1, tu_cardof(p_int_qhd->interrupt_smask) ); check_int_endpoint_link(period_head_arr, p_int_qhd); } @@ -223,7 +223,7 @@ void test_open_interrupt_hs_interval_5(void) p_int_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1].qhd[ pipe_hdl.index ]; TEST_ASSERT_EQUAL(2, p_int_qhd->interval_ms); - TEST_ASSERT_EQUAL(1, cardinality_of(p_int_qhd->interrupt_smask) ); + TEST_ASSERT_EQUAL(1, tu_cardof(p_int_qhd->interrupt_smask) ); check_int_endpoint_link( get_period_head(hostid, 2), p_int_qhd ); } @@ -237,7 +237,7 @@ void test_open_interrupt_hs_interval_6(void) p_int_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1].qhd[ pipe_hdl.index ]; TEST_ASSERT_EQUAL(4, p_int_qhd->interval_ms); - TEST_ASSERT_EQUAL(1, cardinality_of(p_int_qhd->interrupt_smask) ); + TEST_ASSERT_EQUAL(1, tu_cardof(p_int_qhd->interrupt_smask) ); check_int_endpoint_link( get_period_head(hostid, 4), p_int_qhd); } @@ -251,7 +251,7 @@ void test_open_interrupt_hs_interval_7(void) p_int_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1].qhd[ pipe_hdl.index ]; TEST_ASSERT_EQUAL(8, p_int_qhd->interval_ms); - TEST_ASSERT_EQUAL(1, cardinality_of(p_int_qhd->interrupt_smask) ); + TEST_ASSERT_EQUAL(1, tu_cardof(p_int_qhd->interrupt_smask) ); check_int_endpoint_link( get_period_head(hostid, 8), p_int_qhd); } @@ -265,7 +265,7 @@ void test_open_interrupt_hs_interval_8(void) p_int_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1].qhd[ pipe_hdl.index ]; TEST_ASSERT_EQUAL(255, p_int_qhd->interval_ms); - TEST_ASSERT_EQUAL(1, cardinality_of(p_int_qhd->interrupt_smask) ); + TEST_ASSERT_EQUAL(1, tu_cardof(p_int_qhd->interrupt_smask) ); check_int_endpoint_link( get_period_head(hostid, 255), p_int_qhd); check_int_endpoint_link( get_period_head(hostid, 8) , p_int_qhd); } @@ -318,8 +318,8 @@ void test_interrupt_close(void) hcd_pipe_close(pipe_hdl) ); TEST_ASSERT(p_int_qhd->is_removing); - TEST_ASSERT( align32(period_head_arr->next.address) != (uint32_t) p_int_qhd ); - TEST_ASSERT_EQUAL_HEX( (uint32_t) period_head_arr, align32(p_int_qhd->next.address ) ); + TEST_ASSERT( tu_align32(period_head_arr->next.address) != (uint32_t) p_int_qhd ); + TEST_ASSERT_EQUAL_HEX( (uint32_t) period_head_arr, tu_align32(p_int_qhd->next.address ) ); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, p_int_qhd->next.type); } @@ -336,7 +336,7 @@ void test_interrupt_256ms_close(void) hcd_pipe_close(pipe_hdl) ); TEST_ASSERT(p_int_qhd->is_removing); - TEST_ASSERT( align32(get_period_head(hostid, 8)->address) != (uint32_t) p_int_qhd ); - TEST_ASSERT_EQUAL_HEX( (uint32_t) get_period_head(hostid, 8), align32(p_int_qhd->next.address ) ); + TEST_ASSERT( tu_align32(get_period_head(hostid, 8)->address) != (uint32_t) p_int_qhd ); + TEST_ASSERT_EQUAL_HEX( (uint32_t) get_period_head(hostid, 8), tu_align32(p_int_qhd->next.address ) ); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, p_int_qhd->next.type); } diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c index cacc1e98..aeb09493 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c @@ -142,7 +142,7 @@ void verify_qtd(ehci_qtd_t *p_qtd, uint8_t p_data[], uint16_t length) TEST_ASSERT_EQUAL_HEX( p_data, p_qtd->buffer[0] ); for(uint8_t i=1; i<5; i++) { - TEST_ASSERT_EQUAL_HEX( align4k((uint32_t) (p_data+4096*i)), align4k(p_qtd->buffer[i]) ); + TEST_ASSERT_EQUAL_HEX( tu_align4k((uint32_t) (p_data+4096*i)), tu_align4k(p_qtd->buffer[i]) ); } } @@ -182,7 +182,7 @@ void test_interrupt_xfer_double(void) //------------- list tail -------------// TEST_ASSERT_NOT_NULL(p_tail); verify_qtd(p_tail, data2, sizeof(data2)); - TEST_ASSERT_EQUAL_HEX( align32(p_head->next.address), p_tail); + TEST_ASSERT_EQUAL_HEX( tu_align32(p_head->next.address), p_tail); TEST_ASSERT_EQUAL(EHCI_PID_IN, p_tail->pid); TEST_ASSERT_TRUE(p_tail->next.terminate); TEST_ASSERT_TRUE(p_tail->int_on_complete); diff --git a/tests/support/ehci_controller_fake.c b/tests/support/ehci_controller_fake.c index 04d55172..041e1dbb 100644 --- a/tests/support/ehci_controller_fake.c +++ b/tests/support/ehci_controller_fake.c @@ -95,7 +95,7 @@ void complete_qtd_in_qhd(ehci_qhd_t *p_qhd) { while(!p_qhd->qtd_overlay.next.terminate) { - ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address); + ehci_qtd_t* p_qtd = (ehci_qtd_t*) tu_align32(p_qhd->qtd_overlay.next.address); p_qtd->active = 0; p_qtd->total_bytes = 0; p_qhd->qtd_overlay = *p_qtd; @@ -110,7 +110,7 @@ bool complete_all_qtd_in_async(ehci_qhd_t *head) do { complete_qtd_in_qhd(p_qhd); - p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address); + p_qhd = (ehci_qhd_t*) tu_align32(p_qhd->next.address); }while(p_qhd != head); // stop if loop around return true; @@ -121,7 +121,7 @@ bool complete_all_qtd_in_period(ehci_link_t *head) while(!head->terminate) { uint32_t queue_type = head->type; - head = (ehci_link_t*) align32(head->address); + head = (ehci_link_t*) tu_align32(head->address); if ( queue_type == EHCI_QUEUE_ELEMENT_QHD) { @@ -153,7 +153,7 @@ void complete_1st_qtd_with_error(ehci_qhd_t* p_qhd, bool halted, bool xact_err) { if(!p_qhd->qtd_overlay.next.terminate) // TODO add active check { - ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address); + ehci_qtd_t* p_qtd = (ehci_qtd_t*) tu_align32(p_qhd->qtd_overlay.next.address); p_qtd->active = 0; p_qtd->halted = halted ? 1 : 0; p_qtd->xact_err = xact_err ? 1 : 0; @@ -172,7 +172,7 @@ void complete_list_with_error(uint8_t hostid, bool halted, bool xact_err) do { complete_1st_qtd_with_error(p_qhd, halted, xact_err); - p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address); + p_qhd = (ehci_qhd_t*) tu_align32(p_qhd->next.address); }while(p_qhd != get_async_head(hostid)); // stop if loop around //------------- Period List -------------// @@ -183,7 +183,7 @@ void complete_list_with_error(uint8_t hostid, bool halted, bool xact_err) while(!head->terminate) { uint32_t queue_type = head->type; - head = (ehci_link_t*) align32(head->address); + head = (ehci_link_t*) tu_align32(head->address); if ( queue_type == EHCI_QUEUE_ELEMENT_QHD) { diff --git a/tests/support/type_helper.h b/tests/support/type_helper.h index d0712e4f..3e27cef2 100644 --- a/tests/support/type_helper.h +++ b/tests/support/type_helper.h @@ -70,7 +70,7 @@ #define TEST_ASSERT_STATUS( actual )\ TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, (actual) ) -// log2_of a value is equivalent to its highest set bit's position +// tu_log2 a value is equivalent to its highest set bit's position #define BITFIELD_OFFSET_OF_MEMBER(struct_type, member, bitfield_member) \ ({\ uint32_t value=0;\ @@ -78,7 +78,7 @@ memclr_((void*)&str, sizeof(struct_type));\ str.member.bitfield_member = 1;\ memcpy(&value, (void*)&str.member, sizeof(str.member));\ - log2_of( value );\ + tu_log2( value );\ }) #define BITFIELD_OFFSET_OF_UINT32(struct_type, offset, bitfield_member) \ @@ -86,7 +86,7 @@ struct_type str;\ memclr_(&str, sizeof(struct_type));\ str.bitfield_member = 1;\ - log2_of( ((uint32_t*) &str)[offset] );\ + tu_log2( ((uint32_t*) &str)[offset] );\ }) #ifdef __cplusplus