Преглед изворни кода

more clean up use inline bit funciton instead of macros

hathach пре 6 година
родитељ
комит
3e6d911ce9

+ 1 - 1
hw/bsp/ea4088qs/board_ea4088qs.c

@@ -123,7 +123,7 @@ void board_led_write(bool state)
 #if 0
 #if 0
 static bool button_read(uint8_t id)
 static bool button_read(uint8_t id)
 {
 {
-//  return !TU_BIT_TEST( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
+//  return !tu_bit_test( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
 }
 }
 #endif
 #endif
 
 

+ 1 - 1
hw/bsp/ea4357/board_ea4357.c

@@ -265,7 +265,7 @@ void board_led_write(bool state)
 #if 0
 #if 0
 static bool button_read(uint8_t id)
 static bool button_read(uint8_t id)
 {
 {
-//  return !TU_BIT_TEST( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
+//  return !tu_bit_test( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
 }
 }
 #endif
 #endif
 
 

+ 1 - 1
hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c

@@ -175,7 +175,7 @@ void board_led_write(bool state)
 #if 0
 #if 0
 static bool button_read(uint8_t id)
 static bool button_read(uint8_t id)
 {
 {
-//  return !TU_BIT_TEST( GPIO_ReadValue(buttons[id].port), buttons[id].pin ); // button is active low
+//  return !tu_bit_test( GPIO_ReadValue(buttons[id].port), buttons[id].pin ); // button is active low
   return false;
   return false;
 }
 }
 #endif
 #endif

+ 1 - 1
hw/bsp/mcb1800/board_mcb1800.c

@@ -188,7 +188,7 @@ void board_led_write(bool state)
 static bool button_read(uint8_t id)
 static bool button_read(uint8_t id)
 {
 {
   (void) id;
   (void) id;
-//  return !TU_BIT_TEST( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
+//  return !tu_bit_test( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
   return false;
   return false;
 }
 }
 */
 */

+ 2 - 2
src/class/cdc/cdc_device.c

@@ -99,7 +99,7 @@ static void _prep_out_transaction (uint8_t itf)
 bool tud_cdc_n_connected(uint8_t itf)
 bool tud_cdc_n_connected(uint8_t itf)
 {
 {
   // DTR (bit 0) active  is considered as connected
   // DTR (bit 0) active  is considered as connected
-  return tud_ready() && TU_BIT_TEST(_cdcd_itf[itf].line_state, 0);
+  return tud_ready() && tu_bit_test(_cdcd_itf[itf].line_state, 0);
 }
 }
 
 
 uint8_t tud_cdc_n_get_line_state (uint8_t itf)
 uint8_t tud_cdc_n_get_line_state (uint8_t itf)
@@ -358,7 +358,7 @@ bool cdcd_control_request(uint8_t rhport, tusb_control_request_t const * request
       usbd_control_status(rhport, request);
       usbd_control_status(rhport, request);
 
 
       // Invoke callback
       // Invoke callback
-      if ( tud_cdc_line_state_cb) tud_cdc_line_state_cb(itf, TU_BIT_TEST(request->wValue, 0), TU_BIT_TEST(request->wValue, 1));
+      if ( tud_cdc_line_state_cb) tud_cdc_line_state_cb(itf, tu_bit_test(request->wValue, 0), tu_bit_test(request->wValue, 1));
     break;
     break;
 
 
     default: return false; // stall unsupported request
     default: return false; // stall unsupported request

+ 2 - 2
src/class/msc/msc_device.c

@@ -391,7 +391,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
         // For other SCSI commands
         // For other SCSI commands
         // 1. OUT : queue transfer (invoke app callback after done)
         // 1. OUT : queue transfer (invoke app callback after done)
         // 2. IN & Zero: Process if is built-in, else Invoke app callback. Skip DATA if zero length
         // 2. IN & Zero: Process if is built-in, else Invoke app callback. Skip DATA if zero length
-        if ( (p_cbw->total_bytes > 0 ) && !TU_BIT_TEST(p_cbw->dir, 7) )
+        if ( (p_cbw->total_bytes > 0 ) && !tu_bit_test(p_cbw->dir, 7) )
         {
         {
           // queue transfer
           // queue transfer
           TU_ASSERT( dcd_edpt_xfer(rhport, p_msc->ep_out, _mscd_buf, p_msc->total_len) );
           TU_ASSERT( dcd_edpt_xfer(rhport, p_msc->ep_out, _mscd_buf, p_msc->total_len) );
@@ -440,7 +440,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
 
 
     case MSC_STAGE_DATA:
     case MSC_STAGE_DATA:
       // OUT transfer, invoke callback if needed
       // OUT transfer, invoke callback if needed
-      if ( !TU_BIT_TEST(p_cbw->dir, 7) )
+      if ( !tu_bit_test(p_cbw->dir, 7) )
       {
       {
         if ( SCSI_CMD_WRITE_10 != p_cbw->command[0] )
         if ( SCSI_CMD_WRITE_10 != p_cbw->command[0] )
         {
         {

+ 3 - 17
src/common/tusb_common.h

@@ -55,11 +55,7 @@
 #define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32)
 #define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32)
 #define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32)
 #define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32)
 
 
-//------------- Bit -------------//
-#define TU_BIT(n) (1U << (n))                                   ///< n-th Bit
-#define TU_BIT_SET(x, n) ( (x) | TU_BIT(n) )                    ///< set n-th bit of x to 1
-#define TU_BIT_CLEAR(x, n) ( (x) & (~TU_BIT(n)) )               ///< clear n-th bit of x
-#define TU_BIT_TEST(x, n) ( ((x) & TU_BIT(n)) ? true : false )  ///< check if n-th bit of x is 1
+#define TU_BIT(n)           (1U << (n))
 
 
 // for declaration of reserved field, make use of _TU_COUNTER_
 // for declaration of reserved field, make use of _TU_COUNTER_
 #define TU_RESERVED   XSTRING_CONCAT_(reserved, _TU_COUNTER_)
 #define TU_RESERVED   XSTRING_CONCAT_(reserved, _TU_COUNTER_)
@@ -89,14 +85,6 @@
 #define tu_memclr(buffer, size)  memset((buffer), 0, (size))
 #define tu_memclr(buffer, size)  memset((buffer), 0, (size))
 #define tu_varclr(_var)          tu_memclr(_var, sizeof(*(_var)))
 #define tu_varclr(_var)          tu_memclr(_var, sizeof(*(_var)))
 
 
-static inline bool tu_mem_test_zero (void const* buffer, uint32_t size)
-{
-  uint8_t const* p_mem = (uint8_t const*) buffer;
-  for(uint32_t i=0; i<size; i++) if (p_mem[i] != 0)  return false;
-  return true;
-}
-
-
 //------------- Conversion -------------//
 //------------- Conversion -------------//
 static inline uint32_t tu_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)
 {
 {
@@ -136,9 +124,7 @@ static inline uint32_t tu_max32 (uint32_t x, uint32_t y) { return (x > y) ? x :
 // Align
 // Align
 static inline uint32_t tu_align32 (uint32_t value) { return (value & 0xFFFFFFE0UL); }
 static inline uint32_t tu_align32 (uint32_t value) { return (value & 0xFFFFFFE0UL); }
 static inline uint32_t tu_align16 (uint32_t value) { return (value & 0xFFFFFFF0UL); }
 static inline uint32_t tu_align16 (uint32_t value) { return (value & 0xFFFFFFF0UL); }
-static inline uint32_t tu_align_n (uint32_t alignment, uint32_t value) { return value & ((uint32_t) ~(alignment-1)); }
 static inline uint32_t tu_align4k (uint32_t value) { return (value & 0xFFFFF000UL); }
 static inline uint32_t tu_align4k (uint32_t value) { return (value & 0xFFFFF000UL); }
-
 static inline uint32_t tu_offset4k(uint32_t value) { return (value & 0xFFFUL); }
 static inline uint32_t tu_offset4k(uint32_t value) { return (value & 0xFFFUL); }
 
 
 //------------- Mathematics -------------//
 //------------- Mathematics -------------//
@@ -164,9 +150,9 @@ static inline uint8_t tu_log2(uint32_t value)
 }
 }
 
 
 // Bit
 // Bit
-static inline uint32_t tu_bit_set(uint32_t value, uint8_t n) { return value | TU_BIT(n); }
+static inline uint32_t tu_bit_set  (uint32_t value, uint8_t n) { return value | TU_BIT(n); }
 static inline uint32_t tu_bit_clear(uint32_t value, uint8_t n) { return value & (~TU_BIT(n)); }
 static inline uint32_t tu_bit_clear(uint32_t value, uint8_t n) { return value & (~TU_BIT(n)); }
-static inline bool tu_bit_test(uint32_t value, uint8_t n) { return (value & TU_BIT(n)) ? true : false; }
+static inline bool     tu_bit_test (uint32_t value, uint8_t n) { return (value & TU_BIT(n)) ? true : false; }
 
 
 /*------------------------------------------------------------------*/
 /*------------------------------------------------------------------*/
 /* Count number of arguments of __VA_ARGS__
 /* Count number of arguments of __VA_ARGS__

+ 15 - 9
src/common/tusb_compiler.h

@@ -43,15 +43,16 @@
   #define _TU_COUNTER_ __LINE__
   #define _TU_COUNTER_ __LINE__
 #endif
 #endif
 
 
-//--------------------------------------------------------------------+
-// Compile-time Assert (use TU_VERIFY_STATIC to avoid name conflict)
-//--------------------------------------------------------------------+
+// Compile-time Assert
 #if __STDC_VERSION__ >= 201112L
 #if __STDC_VERSION__ >= 201112L
   #define TU_VERIFY_STATIC   _Static_assert
   #define TU_VERIFY_STATIC   _Static_assert
 #else
 #else
   #define TU_VERIFY_STATIC(const_expr, _mess) enum { XSTRING_CONCAT_(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
   #define TU_VERIFY_STATIC(const_expr, _mess) enum { XSTRING_CONCAT_(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
 #endif
 #endif
 
 
+//--------------------------------------------------------------------+
+// Compiler porting with Attribute and Endian
+//--------------------------------------------------------------------+
 #if defined(__GNUC__)
 #if defined(__GNUC__)
   #define ATTR_ALIGNED(Bytes)        __attribute__ ((aligned(Bytes)))
   #define ATTR_ALIGNED(Bytes)        __attribute__ ((aligned(Bytes)))
   #define ATTR_SECTION(sec_name)     __attribute__ ((section(#sec_name)))
   #define ATTR_SECTION(sec_name)     __attribute__ ((section(#sec_name)))
@@ -61,15 +62,20 @@
   #define ATTR_DEPRECATED(mess)      __attribute__ ((deprecated(mess))) // warn if function with this attribute is used
   #define ATTR_DEPRECATED(mess)      __attribute__ ((deprecated(mess))) // warn if function with this attribute is used
   #define ATTR_UNUSED                __attribute__ ((unused))           // Function/Variable is meant to be possibly unused
   #define ATTR_UNUSED                __attribute__ ((unused))           // Function/Variable is meant to be possibly unused
 
 
-  #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
   // Endian conversion use well-known host to network (big endian) naming
   // Endian conversion use well-known host to network (big endian) naming
-  #define tu_htonl(x)    __builtin_bswap32(x)
-  #define tu_ntohl(x)    tu_htonl(x)
+  #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+    #define tu_htonl(u32)  __builtin_bswap32(u32)
+    #define tu_ntohl(u32)  __builtin_bswap32(u32)
 
 
-  #define tu_htons(u16)  __builtin_bswap16(u16)
-  #define tu_ntohs(u16)  tu_htons(u16)
-  #endif
+    #define tu_htons(u16)  __builtin_bswap16(u16)
+    #define tu_ntohs(u16)  __builtin_bswap16(u16)
+  #else
+    #define tu_htonl(u32)  (u32)
+    #define tu_ntohl(u32)  (u32)
 
 
+    #define tu_htons(u16)  (u16)
+    #define tu_ntohs(u16)  (u16)
+  #endif
 #else
 #else
   #error "Compiler attribute porting are required"
   #error "Compiler attribute porting are required"
 #endif
 #endif

+ 2 - 2
src/device/usbd.c

@@ -739,7 +739,7 @@ void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
   uint8_t const dir   = tu_edpt_dir(ep_addr);
   uint8_t const dir   = tu_edpt_dir(ep_addr);
 
 
   dcd_edpt_stall(rhport, ep_addr);
   dcd_edpt_stall(rhport, ep_addr);
-  _usbd_dev.ep_stall_mask[dir] = tu_bit_set(_usbd_dev.ep_stall_mask[dir], epnum);
+  _usbd_dev.ep_stall_mask[dir] = (uint8_t) tu_bit_set(_usbd_dev.ep_stall_mask[dir], epnum);
 }
 }
 
 
 void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
 void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
@@ -748,7 +748,7 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
   uint8_t const dir   = tu_edpt_dir(ep_addr);
   uint8_t const dir   = tu_edpt_dir(ep_addr);
 
 
   dcd_edpt_clear_stall(rhport, ep_addr);
   dcd_edpt_clear_stall(rhport, ep_addr);
-  _usbd_dev.ep_stall_mask[dir] = tu_bit_clear(_usbd_dev.ep_stall_mask[dir], epnum);
+  _usbd_dev.ep_stall_mask[dir] = (uint8_t) tu_bit_clear(_usbd_dev.ep_stall_mask[dir], epnum);
 }
 }
 
 
 bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)
 bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)

+ 1 - 1
src/device/usbd.h

@@ -94,7 +94,7 @@ ATTR_WEAK void tud_resume_cb(void);
 
 
 #define TUD_CONFIG_DESC_LEN   (9)
 #define TUD_CONFIG_DESC_LEN   (9)
 
 
-// Inteface count, string index, total length, attribute, power in mA
+// Interface count, string index, total length, attribute, power in mA
 #define TUD_CONFIG_DESCRIPTOR(_itfcount, _stridx, _total_len, _attribute, _power_ma) \
 #define TUD_CONFIG_DESCRIPTOR(_itfcount, _stridx, _total_len, _attribute, _power_ma) \
   9, TUSB_DESC_CONFIGURATION, U16_TO_U8S_LE(_total_len), _itfcount, 1, _stridx, TU_BIT(7) | _attribute, (_power_ma)/2
   9, TUSB_DESC_CONFIGURATION, U16_TO_U8S_LE(_total_len), _itfcount, 1, _stridx, TU_BIT(7) | _attribute, (_power_ma)/2
 
 

+ 2 - 2
src/host/hub.c

@@ -83,7 +83,7 @@ bool hub_port_clear_feature_subtask(uint8_t hub_addr, uint8_t hub_port, uint8_t
   hub_port_status_response_t * p_port_status;
   hub_port_status_response_t * p_port_status;
   p_port_status = (hub_port_status_response_t *) hub_enum_buffer;
   p_port_status = (hub_port_status_response_t *) hub_enum_buffer;
 
 
-  TU_ASSERT( !TU_BIT_TEST(p_port_status->status_change.value, feature-16)  );
+  TU_ASSERT( !tu_bit_test(p_port_status->status_change.value, feature-16)  );
 
 
   return true;
   return true;
 }
 }
@@ -211,7 +211,7 @@ void hub_isr(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xf
     for (uint8_t port=1; port <= p_hub->port_number; port++)
     for (uint8_t port=1; port <= p_hub->port_number; port++)
     {
     {
       // TODO HUB ignore bit0 hub_status_change
       // TODO HUB ignore bit0 hub_status_change
-      if ( TU_BIT_TEST(p_hub->status_change, port) )
+      if ( tu_bit_test(p_hub->status_change, port) )
       {
       {
         hcd_event_t event =
         hcd_event_t event =
         {
         {

+ 4 - 4
src/portable/nordic/nrf5x/dcd_nrf5x.c

@@ -375,7 +375,7 @@ void USBD_IRQHandler(void)
 
 
   for(uint8_t i=0; i<USBD_INTEN_EPDATA_Pos+1; i++)
   for(uint8_t i=0; i<USBD_INTEN_EPDATA_Pos+1; i++)
   {
   {
-    if ( TU_BIT_TEST(inten, i) && regevt[i]  )
+    if ( tu_bit_test(inten, i) && regevt[i]  )
     {
     {
       int_status |= TU_BIT(i);
       int_status |= TU_BIT(i);
 
 
@@ -477,7 +477,7 @@ void USBD_IRQHandler(void)
    */
    */
   for(uint8_t epnum=0; epnum<8; epnum++)
   for(uint8_t epnum=0; epnum<8; epnum++)
   {
   {
-    if ( TU_BIT_TEST(int_status, USBD_INTEN_ENDEPOUT0_Pos+epnum))
+    if ( tu_bit_test(int_status, USBD_INTEN_ENDEPOUT0_Pos+epnum))
     {
     {
       xfer_td_t* xfer = get_td(epnum, TUSB_DIR_OUT);
       xfer_td_t* xfer = get_td(epnum, TUSB_DIR_OUT);
       uint8_t const xact_len = NRF_USBD->EPOUT[epnum].AMOUNT;
       uint8_t const xact_len = NRF_USBD->EPOUT[epnum].AMOUNT;
@@ -517,7 +517,7 @@ void USBD_IRQHandler(void)
     // CBI In: Endpoint -> Host (transaction complete)
     // CBI In: Endpoint -> Host (transaction complete)
     for(uint8_t epnum=0; epnum<8; epnum++)
     for(uint8_t epnum=0; epnum<8; epnum++)
     {
     {
-      if ( TU_BIT_TEST(data_status, epnum ) || ( epnum == 0 && is_control_in) )
+      if ( tu_bit_test(data_status, epnum ) || ( epnum == 0 && is_control_in) )
       {
       {
         xfer_td_t* xfer = get_td(epnum, TUSB_DIR_IN);
         xfer_td_t* xfer = get_td(epnum, TUSB_DIR_IN);
 
 
@@ -538,7 +538,7 @@ void USBD_IRQHandler(void)
     // CBI OUT: Host -> Endpoint
     // CBI OUT: Host -> Endpoint
     for(uint8_t epnum=0; epnum<8; epnum++)
     for(uint8_t epnum=0; epnum<8; epnum++)
     {
     {
-      if ( TU_BIT_TEST(data_status, 16+epnum ) || ( epnum == 0 && is_control_out) )
+      if ( tu_bit_test(data_status, 16+epnum ) || ( epnum == 0 && is_control_out) )
       {
       {
         xfer_td_t* xfer = get_td(epnum, TUSB_DIR_OUT);
         xfer_td_t* xfer = get_td(epnum, TUSB_DIR_OUT);
 
 

+ 3 - 3
src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c

@@ -279,7 +279,7 @@ static void process_xfer_isr(uint32_t int_status)
 {
 {
   for(uint8_t ep_id = 0; ep_id < EP_COUNT; ep_id++ )
   for(uint8_t ep_id = 0; ep_id < EP_COUNT; ep_id++ )
   {
   {
-    if ( TU_BIT_TEST(int_status, ep_id) )
+    if ( tu_bit_test(int_status, ep_id) )
     {
     {
       ep_cmd_sts_t * ep_cs = &_dcd.ep[ep_id][0];
       ep_cmd_sts_t * ep_cs = &_dcd.ep[ep_id][0];
       xfer_dma_t* xfer_dma = &_dcd.dma[ep_id];
       xfer_dma_t* xfer_dma = &_dcd.dma[ep_id];
@@ -354,7 +354,7 @@ void USB_IRQHandler(void)
   }
   }
 
 
   // Setup Receive
   // Setup Receive
-  if ( TU_BIT_TEST(int_status, 0) && (dev_cmd_stat & CMDSTAT_SETUP_RECEIVED_MASK) )
+  if ( tu_bit_test(int_status, 0) && (dev_cmd_stat & CMDSTAT_SETUP_RECEIVED_MASK) )
   {
   {
     // Follow UM flowchart to clear Active & Stall on both Control IN/OUT endpoints
     // Follow UM flowchart to clear Active & Stall on both Control IN/OUT endpoints
     _dcd.ep[0][0].active = _dcd.ep[1][0].active = 0;
     _dcd.ep[0][0].active = _dcd.ep[1][0].active = 0;
@@ -368,7 +368,7 @@ void USB_IRQHandler(void)
     _dcd.ep[0][1].buffer_offset = get_buf_offset(_dcd.setup_packet);
     _dcd.ep[0][1].buffer_offset = get_buf_offset(_dcd.setup_packet);
 
 
     // clear bit0
     // clear bit0
-    int_status = TU_BIT_CLEAR(int_status, 0);
+    int_status = tu_bit_clear(int_status, 0);
   }
   }
 
 
   // Endpoint transfer complete interrupt
   // Endpoint transfer complete interrupt

+ 2 - 2
src/portable/nxp/lpc17_40/dcd_lpc17_40.c

@@ -530,7 +530,7 @@ void hal_dcd_isr(uint8_t rhport)
   {
   {
     for ( uint8_t ep_id = 3; ep_id < DCD_ENDPOINT_MAX; ep_id += 2 )
     for ( uint8_t ep_id = 3; ep_id < DCD_ENDPOINT_MAX; ep_id += 2 )
     {
     {
-      if ( TU_BIT_TEST(ep_int_status, ep_id) )
+      if ( tu_bit_test(ep_int_status, ep_id) )
       {
       {
         LPC_USB->EpIntClr = TU_BIT(ep_id);
         LPC_USB->EpIntClr = TU_BIT(ep_id);
 
 
@@ -553,7 +553,7 @@ void hal_dcd_isr(uint8_t rhport)
 
 
     for ( uint8_t ep_id = 2; ep_id < DCD_ENDPOINT_MAX; ep_id++ )
     for ( uint8_t ep_id = 2; ep_id < DCD_ENDPOINT_MAX; ep_id++ )
     {
     {
-      if ( TU_BIT_TEST(eot, ep_id) )
+      if ( tu_bit_test(eot, ep_id) )
       {
       {
         if ( ep_id & 0x01 )
         if ( ep_id & 0x01 )
         {
         {

+ 1 - 1
src/portable/nxp/lpc18_43/dcd_lpc18_43.c

@@ -341,7 +341,7 @@ void hal_dcd_isr(uint8_t rhport)
     {
     {
       for(uint8_t ep_idx = 0; ep_idx < QHD_MAX; ep_idx++)
       for(uint8_t ep_idx = 0; ep_idx < QHD_MAX; ep_idx++)
       {
       {
-        if ( TU_BIT_TEST(edpt_complete, ep_idx2bit(ep_idx)) )
+        if ( tu_bit_test(edpt_complete, ep_idx2bit(ep_idx)) )
         {
         {
           // 23.10.12.3 Failed QTD also get ENDPTCOMPLETE set
           // 23.10.12.3 Failed QTD also get ENDPTCOMPLETE set
           dcd_qtd_t * p_qtd = &dcd_data_ptr[rhport]->qtd[ep_idx];
           dcd_qtd_t * p_qtd = &dcd_data_ptr[rhport]->qtd[ep_idx];