summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-10-23 12:19:32 +0700
committerhathach <[email protected]>2018-10-23 12:19:32 +0700
commitc7340f4b0eb8dcf15fa93f6bf6589a94fb59dc95 (patch)
treeebce72906cf8896a362c87a168bfd9d66e3f4543 /src
parent14cebcb5f57665182a311766364e997756614db5 (diff)
clean up helper func
Diffstat (limited to 'src')
-rw-r--r--src/class/cdc/cdc_device.c4
-rw-r--r--src/class/cdc/cdc_host.c4
-rw-r--r--src/class/cdc/cdc_rndis_host.c8
-rw-r--r--src/class/custom/custom_device.c2
-rw-r--r--src/class/custom/custom_host.c4
-rw-r--r--src/class/hid/hid_device.c8
-rw-r--r--src/class/hid/hid_host.c6
-rw-r--r--src/class/msc/msc_device.c12
-rw-r--r--src/class/msc/msc_host.c4
-rw-r--r--src/common/tusb_common.h34
-rw-r--r--src/device/usbd.c4
-rw-r--r--src/host/ehci/ehci.c8
-rw-r--r--src/host/hub.c4
-rw-r--r--src/host/ohci/ohci.c6
-rw-r--r--src/host/usbh.c2
-rw-r--r--src/osal/osal_mynewt.h2
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c2
-rw-r--r--src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c4
-rw-r--r--src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c6
-rw-r--r--src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c8
20 files changed, 52 insertions, 80 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index 70d51c258..06530bc7a 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -185,7 +185,7 @@ bool tud_cdc_n_write_flush (uint8_t itf)
//--------------------------------------------------------------------+
void cdcd_init(void)
{
- arrclr_( _cdcd_itf );
+ tu_memclr(_cdcd_itf, sizeof(_cdcd_itf));
for(uint8_t i=0; i<CFG_TUD_CDC; i++)
{
@@ -209,7 +209,7 @@ void cdcd_reset(uint8_t rhport)
for(uint8_t i=0; i<CFG_TUD_CDC; i++)
{
- memclr_(&_cdcd_itf[i], ITF_BUS_RESET_SZ);
+ tu_memclr(&_cdcd_itf[i], ITF_BUS_RESET_SZ);
tu_fifo_clear(&_cdcd_itf[i].rx_ff);
tu_fifo_clear(&_cdcd_itf[i].tx_ff);
}
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c
index ca448ba5e..af2e2c444 100644
--- a/src/class/cdc/cdc_host.c
+++ b/src/class/cdc/cdc_host.c
@@ -139,7 +139,7 @@ tusb_error_t tuh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length,
//--------------------------------------------------------------------+
void cdch_init(void)
{
- memclr_(cdch_data, sizeof(cdch_data_t)*CFG_TUSB_HOST_DEVICE_MAX);
+ tu_memclr(cdch_data, sizeof(cdch_data_t)*CFG_TUSB_HOST_DEVICE_MAX);
}
tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length)
@@ -234,7 +234,7 @@ void cdch_close(uint8_t dev_addr)
(void) hcd_pipe_close(p_cdc->pipe_in);
(void) hcd_pipe_close(p_cdc->pipe_out);
- memclr_(p_cdc, sizeof(cdch_data_t));
+ tu_memclr(p_cdc, sizeof(cdch_data_t));
tuh_cdc_unmounted_cb(dev_addr);
diff --git a/src/class/cdc/cdc_rndis_host.c b/src/class/cdc/cdc_rndis_host.c
index 4d28b0e0c..9b7684f77 100644
--- a/src/class/cdc/cdc_rndis_host.c
+++ b/src/class/cdc/cdc_rndis_host.c
@@ -117,7 +117,7 @@ static tusb_error_t rndis_body_subtask(void)
//--------------------------------------------------------------------+
void rndish_init(void)
{
- memclr_(rndish_data, sizeof(rndish_data_t)*CFG_TUSB_HOST_DEVICE_MAX);
+ tu_memclr(rndish_data, sizeof(rndish_data_t)*CFG_TUSB_HOST_DEVICE_MAX);
//------------- Task creation -------------//
@@ -131,7 +131,7 @@ void rndish_init(void)
void rndish_close(uint8_t dev_addr)
{
osal_semaphore_reset( rndish_data[dev_addr-1].sem_notification_hdl );
-// memclr_(&rndish_data[dev_addr-1], sizeof(rndish_data_t)); TODO need to move semaphore & its handle out before memclr
+// tu_memclr(&rndish_data[dev_addr-1], sizeof(rndish_data_t)); TODO need to move semaphore & its handle out before memclr
}
@@ -189,7 +189,7 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
//------------- Message Query 802.3 Permanent Address -------------//
memcpy(msg_payload, &msg_query_permanent_addr, sizeof(rndis_msg_query_t));
- memclr_(msg_payload + sizeof(rndis_msg_query_t), 6); // 6 bytes for MAC address
+ tu_memclr(msg_payload + sizeof(rndis_msg_query_t), 6); // 6 bytes for MAC address
STASK_INVOKE(
send_message_get_response_subtask( dev_addr, p_cdc,
@@ -205,7 +205,7 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
//------------- Set OID_GEN_CURRENT_PACKET_FILTER to (DIRECTED | MULTICAST | BROADCAST) -------------//
memcpy(msg_payload, &msg_set_packet_filter, sizeof(rndis_msg_set_t));
- memclr_(msg_payload + sizeof(rndis_msg_set_t), 4); // 4 bytes for filter flags
+ tu_memclr(msg_payload + sizeof(rndis_msg_set_t), 4); // 4 bytes for filter flags
((rndis_msg_set_t*) msg_payload)->oid_buffer[0] = (RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_MULTICAST | RNDIS_PACKET_TYPE_BROADCAST);
STASK_INVOKE(
diff --git a/src/class/custom/custom_device.c b/src/class/custom/custom_device.c
index 2c3783e35..d43a86b14 100644
--- a/src/class/custom/custom_device.c
+++ b/src/class/custom/custom_device.c
@@ -68,7 +68,7 @@ static cusd_interface_t _cusd_itf;
*------------------------------------------------------------------*/
void cusd_init(void)
{
- varclr_(&_cusd_itf);
+ tu_varclr(&_cusd_itf);
}
tusb_error_t cusd_open(uint8_t rhport, tusb_desc_interface_t const * p_desc_itf, uint16_t *p_len)
diff --git a/src/class/custom/custom_host.c b/src/class/custom/custom_host.c
index ad3315980..329012fda 100644
--- a/src/class/custom/custom_host.c
+++ b/src/class/custom/custom_host.c
@@ -104,7 +104,7 @@ tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t p
//--------------------------------------------------------------------+
void cush_init(void)
{
- memclr_(&custom_interface, sizeof(custom_interface_info_t) * CFG_TUSB_HOST_DEVICE_MAX);
+ tu_memclr(&custom_interface, sizeof(custom_interface_info_t) * CFG_TUSB_HOST_DEVICE_MAX);
}
tusb_error_t cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length)
@@ -152,7 +152,7 @@ void cush_close(uint8_t dev_addr)
err2 = hcd_pipe_close( p_interface->pipe_out );
}
- memclr_(p_interface, sizeof(custom_interface_info_t));
+ tu_memclr(p_interface, sizeof(custom_interface_info_t));
TU_ASSERT(err1 == TUSB_ERROR_NONE && err2 == TUSB_ERROR_NONE, (void) 0 );
}
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c
index b1cd1d1bd..d8696f137 100644
--- a/src/class/hid/hid_device.c
+++ b/src/class/hid/hid_device.c
@@ -188,7 +188,7 @@ bool tud_hid_keyboard_keycode(uint8_t modifier, uint8_t keycode[6])
memcpy(report.keycode, keycode, 6);
}else
{
- memclr_(report.keycode, 6);
+ tu_memclr(report.keycode, 6);
}
return hidd_kbd_report(&report);
@@ -307,14 +307,14 @@ void hidd_init(void)
void hidd_reset(uint8_t rhport)
{
- arrclr_(_hidd_itf);
+ tu_memclr(_hidd_itf, sizeof(_hidd_itf));
#if CFG_TUD_HID_KEYBOARD
- varclr_(&_kbd_rpt);
+ tu_varclr(&_kbd_rpt);
#endif
#if CFG_TUD_HID_MOUSE
- varclr_(&_mse_rpt);
+ tu_varclr(&_mse_rpt);
#endif
}
diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c
index 369dad638..518297eec 100644
--- a/src/class/hid/hid_host.c
+++ b/src/class/hid/hid_host.c
@@ -68,7 +68,7 @@ static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interfa
static inline void hidh_interface_close(hidh_interface_info_t *p_hid)
{
(void) hcd_pipe_close(p_hid->pipe_hdl);
- memclr_(p_hid, sizeof(hidh_interface_info_t));
+ tu_memclr(p_hid, sizeof(hidh_interface_info_t));
}
// called from public API need to validate parameters
@@ -164,11 +164,11 @@ tusb_error_t tuh_hid_mouse_get_report(uint8_t dev_addr, void * report)
void hidh_init(void)
{
#if CFG_TUSB_HOST_HID_KEYBOARD
- memclr_(&keyboardh_data, sizeof(hidh_interface_info_t)*CFG_TUSB_HOST_DEVICE_MAX);
+ tu_memclr(&keyboardh_data, sizeof(hidh_interface_info_t)*CFG_TUSB_HOST_DEVICE_MAX);
#endif
#if CFG_TUSB_HOST_HID_MOUSE
- memclr_(&mouseh_data, sizeof(hidh_interface_info_t)*CFG_TUSB_HOST_DEVICE_MAX);
+ tu_memclr(&mouseh_data, sizeof(hidh_interface_info_t)*CFG_TUSB_HOST_DEVICE_MAX);
#endif
#if CFG_TUSB_HOST_HID_GENERIC
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index 3335ad9b3..830ce85b7 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -62,9 +62,9 @@ enum
typedef struct {
CFG_TUSB_MEM_ALIGN msc_cbw_t cbw;
-#if defined (__ICCARM__) && (CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13UXX)
- uint8_t padding1[64-sizeof(msc_cbw_t)]; // IAR cannot align struct's member
-#endif
+//#if defined (__ICCARM__) && (CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13UXX)
+// uint8_t padding1[64-sizeof(msc_cbw_t)]; // IAR cannot align struct's member
+//#endif
CFG_TUSB_MEM_ALIGN msc_csw_t csw;
@@ -141,12 +141,12 @@ bool tud_msc_set_sense(uint8_t lun, uint8_t sense_key, uint8_t add_sense_code, u
//--------------------------------------------------------------------+
void mscd_init(void)
{
- memclr_(&_mscd_itf, sizeof(mscd_interface_t));
+ tu_memclr(&_mscd_itf, sizeof(mscd_interface_t));
}
void mscd_reset(uint8_t rhport)
{
- memclr_(&_mscd_itf, sizeof(mscd_interface_t));
+ tu_memclr(&_mscd_itf, sizeof(mscd_interface_t));
}
tusb_error_t mscd_open(uint8_t rhport, tusb_desc_interface_t const * p_desc_itf, uint16_t *p_len)
@@ -302,7 +302,6 @@ tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, tusb_event_t event, u
{
case MSC_STAGE_CMD:
//------------- new CBW received -------------//
-
// Complete IN while waiting for CMD is usually Status of previous SCSI op, ignore it
if(ep_addr != p_msc->ep_out) return TUSB_ERROR_NONE;
@@ -332,7 +331,6 @@ tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, tusb_event_t event, u
// 1. Zero : Invoke app callback, skip DATA and move to STATUS stage
// 2. OUT : queue transfer (invoke app callback after done)
// 3. IN : invoke app callback to get response
-
if ( p_cbw->xfer_bytes == 0)
{
int32_t const cb_result = tud_msc_scsi_cb(p_cbw->lun, p_cbw->command, NULL, 0);
diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c
index 7e6396389..9250b8df7 100644
--- a/src/class/msc/msc_host.c
+++ b/src/class/msc/msc_host.c
@@ -288,7 +288,7 @@ tusb_error_t tuh_msc_write10(uint8_t dev_addr, uint8_t lun, void const * p_buffe
//--------------------------------------------------------------------+
void msch_init(void)
{
- memclr_(msch_data, sizeof(msch_interface_t)*CFG_TUSB_HOST_DEVICE_MAX);
+ tu_memclr(msch_data, sizeof(msch_interface_t)*CFG_TUSB_HOST_DEVICE_MAX);
msch_sem_hdl = osal_semaphore_create(1, 0);
}
@@ -416,7 +416,7 @@ void msch_close(uint8_t dev_addr)
(void) hcd_pipe_close(msch_data[dev_addr-1].bulk_in);
(void) hcd_pipe_close(msch_data[dev_addr-1].bulk_out);
- memclr_(&msch_data[dev_addr-1], sizeof(msch_interface_t));
+ tu_memclr(&msch_data[dev_addr-1], sizeof(msch_interface_t));
osal_semaphore_reset(msch_sem_hdl);
tuh_msc_unmounted_cb(dev_addr); // invoke Application Callback
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 778e70676..85bd15d43 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -73,8 +73,7 @@
//--------------------------------------------------------------------+
// MACROS
//--------------------------------------------------------------------+
-#define MAX_OF(a, b) ( (a) > (b) ? (a) : (b) )
-#define MIN_OF(a, b) ( (a) < (b) ? (a) : (b) )
+#define TU_ARRAY_SZIE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
#define U16_HIGH_U8(u16) ((uint8_t) (((u16) >> 8) & 0x00ff))
#define U16_LOW_U8(u16) ((uint8_t) ((u16) & 0x00ff))
@@ -137,12 +136,10 @@
//--------------------------------------------------------------------+
// INLINE FUNCTION
//--------------------------------------------------------------------+
-#define memclr_(buffer, size) memset((buffer), 0, (size))
-#define varclr_(_var) memclr_(_var, sizeof(*(_var)))
-#define arrclr_(_arr) memclr_(_arr, sizeof(_arr))
-#define arrcount_(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
+#define tu_memclr(buffer, size) memset((buffer), 0, (size))
+#define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var)))
-static inline bool mem_all_zero(void const* buffer, uint32_t size)
+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;
@@ -193,11 +190,6 @@ static inline uint32_t tu_max32(uint32_t x, uint32_t y)
return (x > y) ? x : y;
}
-static inline uint16_t tu_max16(uint16_t x, uint16_t y)
-{
- return (x > y) ? x : y;
-}
-
//------------- Align -------------//
static inline uint32_t tu_align32 (uint32_t value)
{
@@ -249,24 +241,6 @@ static inline uint8_t tu_log2(uint32_t value)
return result;
}
-// return the number of set bits in 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
- // Published in 1988, the C Programming Language 2nd Ed. (by Brian W. Kernighan and Dennis M. Ritchie)
- // mentions this in exercise 2-9. On April 19, 2006 Don Knuth pointed out to me that this method
- // "was first published by Peter Wegner in CACM 3 (1960), 322. (Also discovered independently by Derrick Lehmer and
- // published in 1964 in a book edited by Beckenbach.)"
- uint8_t count;
- for (count = 0; value; count++)
- {
- value &= value - 1; // clear the least significant bit set
- }
-
- return count;
-}
-
#ifdef __cplusplus
}
#endif
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 89dd4b722..146f8ec89 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -274,7 +274,7 @@ static tusb_error_t usbd_main_st(void)
tusb_error_t err;
err = TUSB_ERROR_NONE;
- memclr_(&event, sizeof(usbd_task_event_t));
+ tu_memclr(&event, sizeof(usbd_task_event_t));
osal_queue_receive(_usbd_q, &event, OSAL_TIMEOUT_WAIT_FOREVER, &err);
@@ -318,7 +318,7 @@ static tusb_error_t usbd_main_st(void)
static void usbd_reset(uint8_t rhport)
{
- varclr_(&_usbd_dev);
+ tu_varclr(&_usbd_dev);
memset(_usbd_dev.itf2drv, 0xff, sizeof(_usbd_dev.itf2drv)); // invalid mapping
memset(_usbd_dev.ep2drv , 0xff, sizeof(_usbd_dev.ep2drv )); // invalid mapping
diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c
index 84821e3f5..99e7fdb65 100644
--- a/src/host/ehci/ehci.c
+++ b/src/host/ehci/ehci.c
@@ -130,7 +130,7 @@ static tusb_error_t hcd_controller_stop(uint8_t hostid) ATTR_WARN_UNUSED_RESULT
tusb_error_t hcd_init(void)
{
//------------- Data Structure init -------------//
- memclr_(&ehci_data, sizeof(ehci_data_t));
+ tu_memclr(&ehci_data, sizeof(ehci_data_t));
#if (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST)
TU_ASSERT_ERR (hcd_controller_init(0));
@@ -192,7 +192,7 @@ static tusb_error_t hcd_controller_init(uint8_t hostid)
//------------- Asynchronous List -------------//
ehci_qhd_t * const async_head = get_async_head(hostid);
- memclr_(async_head, sizeof(ehci_qhd_t));
+ tu_memclr(async_head, sizeof(ehci_qhd_t));
async_head->next.address = (uint32_t) async_head; // circular list, next is itself
async_head->next.type = EHCI_QUEUE_ELEMENT_QHD;
@@ -938,7 +938,7 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si
// address 0 is used as async head, which always on the list --> cannot be cleared (ehci halted otherwise)
if (dev_addr != 0)
{
- memclr_(p_qhd, sizeof(ehci_qhd_t));
+ tu_memclr(p_qhd, sizeof(ehci_qhd_t));
}
p_qhd->device_address = dev_addr;
@@ -1004,7 +1004,7 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si
static void qtd_init(ehci_qtd_t* p_qtd, uint32_t data_ptr, uint16_t total_bytes)
{
- memclr_(p_qtd, sizeof(ehci_qtd_t));
+ tu_memclr(p_qtd, sizeof(ehci_qtd_t));
p_qtd->used = 1;
diff --git a/src/host/hub.c b/src/host/hub.c
index 063cef61a..624e43563 100644
--- a/src/host/hub.c
+++ b/src/host/hub.c
@@ -152,7 +152,7 @@ tusb_speed_t hub_port_get_speed(void)
//--------------------------------------------------------------------+
void hub_init(void)
{
- memclr_(hub_data, CFG_TUSB_HOST_DEVICE_MAX*sizeof(usbh_hub_t));
+ tu_memclr(hub_data, CFG_TUSB_HOST_DEVICE_MAX*sizeof(usbh_hub_t));
// hub_enum_sem_hdl = osal_semaphore_create( OSAL_SEM_REF(hub_enum_semaphore) );
}
@@ -237,7 +237,7 @@ void hub_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes)
void hub_close(uint8_t dev_addr)
{
(void) hcd_pipe_close(hub_data[dev_addr-1].pipe_status);
- memclr_(&hub_data[dev_addr-1], sizeof(usbh_hub_t));
+ tu_memclr(&hub_data[dev_addr-1], sizeof(usbh_hub_t));
// osal_semaphore_reset(hub_enum_sem_hdl);
}
diff --git a/src/host/ohci/ohci.c b/src/host/ohci/ohci.c
index 1c9f3f293..b9183a025 100644
--- a/src/host/ohci/ohci.c
+++ b/src/host/ohci/ohci.c
@@ -164,7 +164,7 @@ static ohci_ed_t * ed_list_find_previous(ohci_ed_t const * p_head, ohci_ed_t con
tusb_error_t hcd_init(void)
{
//------------- Data Structure init -------------//
- memclr_(&ohci_data, sizeof(ohci_data_t));
+ tu_memclr(&ohci_data, sizeof(ohci_data_t));
for(uint8_t i=0; i<32; i++)
{ // assign all interrupt pointes to period head ed
ohci_data.hcca.interrupt_table[i] = (uint32_t) &ohci_data.period_head_ed;
@@ -245,7 +245,7 @@ static void ed_init(ohci_ed_t *p_ed, uint8_t dev_addr, uint16_t max_packet_size,
// address 0 is used as async head, which always on the list --> cannot be cleared
if (dev_addr != 0)
{
- memclr_(p_ed, sizeof(ohci_ed_t));
+ tu_memclr(p_ed, sizeof(ohci_ed_t));
}
p_ed->device_address = dev_addr;
@@ -261,7 +261,7 @@ static void ed_init(ohci_ed_t *p_ed, uint8_t dev_addr, uint16_t max_packet_size,
static void gtd_init(ohci_gtd_t* p_td, void* data_ptr, uint16_t total_bytes)
{
- memclr_(p_td, sizeof(ohci_gtd_t));
+ tu_memclr(p_td, sizeof(ohci_gtd_t));
p_td->used = 1;
p_td->expected_bytes = total_bytes;
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 8b858b2de..b849de9b9 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -142,7 +142,7 @@ uint32_t tuh_device_get_mounted_class_flag(uint8_t dev_addr)
//--------------------------------------------------------------------+
tusb_error_t usbh_init(void)
{
- memclr_(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
+ tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
TU_ASSERT_ERR( hcd_init() );
diff --git a/src/osal/osal_mynewt.h b/src/osal/osal_mynewt.h
index db65ac553..59cd1b821 100644
--- a/src/osal/osal_mynewt.h
+++ b/src/osal/osal_mynewt.h
@@ -145,7 +145,7 @@ static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * da
os_memblock_put(&queue_hdl->mpool, ptr);
return false;
}
- memclr_(ev, sizeof(struct os_event));
+ tu_memclr(ev, sizeof(struct os_event));
ev->ev_arg = ptr;
os_eventq_put(&queue_hdl->evq, ev);
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index 01926c76e..371c291a3 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -108,7 +108,7 @@ void bus_reset(void)
NRF_USBD->TASKS_STARTISOIN = 0;
NRF_USBD->TASKS_STARTISOOUT = 0;
- varclr_(&_dcd);
+ tu_varclr(&_dcd);
}
/*------------------------------------------------------------------*/
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 292d1fa6d..8e5a4d1aa 100644
--- a/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c
+++ b/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c
@@ -201,7 +201,7 @@ bool dcd_init(uint8_t rhport)
static void bus_reset(void)
{
- memclr_(&dcd_data, sizeof(dcd_11u_13u_data_t));
+ tu_memclr(&dcd_data, sizeof(dcd_11u_13u_data_t));
for(uint8_t ep_id = 2; ep_id < DCD_11U_13U_QHD_COUNT; ep_id++)
{ // disable all non-control endpoints on bus reset
dcd_data.qhd[ep_id][0].disable = dcd_data.qhd[ep_id][1].disable = 1;
@@ -473,7 +473,7 @@ edpt_hdl_t dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint
TU_ASSERT( dcd_data.qhd[ep_id][0].disable && dcd_data.qhd[ep_id][1].disable, null_handle ); // endpoint must not previously opened, normally this means running out of endpoints
- memclr_(dcd_data.qhd[ep_id], 2*sizeof(dcd_11u_13u_qhd_t));
+ tu_memclr(dcd_data.qhd[ep_id], 2*sizeof(dcd_11u_13u_qhd_t));
dcd_data.qhd[ep_id][0].is_isochronous = dcd_data.qhd[ep_id][1].is_isochronous = (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS);
dcd_data.class_code[ep_id] = class_code;
diff --git a/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c b/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c
index 4d3687830..189521d25 100644
--- a/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c
+++ b/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c
@@ -119,7 +119,7 @@ static void bus_reset(void)
LPC_USB->USBNDDRIntClr = 0xFFFFFFFF;
LPC_USB->USBSysErrIntClr = 0xFFFFFFFF;
- memclr_(&dcd_data, sizeof(dcd_data_t));
+ tu_memclr(&dcd_data, sizeof(dcd_data_t));
}
bool dcd_init(uint8_t rhport)
@@ -432,7 +432,7 @@ edpt_hdl_t dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint
//------------- first DD prepare -------------//
dcd_dma_descriptor_t* const p_dd = &dcd_data.dd[ep_id][0];
- memclr_(p_dd, sizeof(dcd_dma_descriptor_t));
+ tu_memclr(p_dd, sizeof(dcd_dma_descriptor_t));
p_dd->is_isochronous = (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) ? 1 : 0;
p_dd->max_packet_size = p_endpoint_desc->wMaxPacketSize.size;
@@ -498,7 +498,7 @@ tusb_error_t dcd_edpt_xfer(edpt_hdl_t edpt_hdl, uint8_t* buffer, uint16_t total_
{
// setup new dd
dcd_dma_descriptor_t* const p_dd = &dcd_data.dd[ edpt_hdl.index ][1];
- memclr_(p_dd, sizeof(dcd_dma_descriptor_t));
+ tu_memclr(p_dd, sizeof(dcd_dma_descriptor_t));
dd_xfer_init(p_dd, buffer, total_bytes);
diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c
index 7368542b8..5a7d61004 100644
--- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c
+++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c
@@ -133,7 +133,7 @@ static void bus_reset(uint8_t rhport)
//------------- Queue Head & Queue TD -------------//
dcd_data_t* p_dcd = dcd_data_ptr[rhport];
- memclr_(p_dcd, sizeof(dcd_data_t));
+ tu_memclr(p_dcd, sizeof(dcd_data_t));
//------------- Set up Control Endpoints (0 OUT, 1 IN) -------------//
p_dcd->qhd[0].zero_length_termination = p_dcd->qhd[1].zero_length_termination = 1;
@@ -149,7 +149,7 @@ bool dcd_init(uint8_t rhport)
LPC_USB0_Type* const lpc_usb = LPC_USB[rhport];
dcd_data_t* p_dcd = dcd_data_ptr[rhport];
- memclr_(p_dcd, sizeof(dcd_data_t));
+ tu_memclr(p_dcd, sizeof(dcd_data_t));
lpc_usb->ENDPOINTLISTADDR = (uint32_t) p_dcd->qhd; // Endpoint List Address has to be 2K alignment
lpc_usb->USBSTS_D = lpc_usb->USBSTS_D;
@@ -196,7 +196,7 @@ static inline uint8_t edpt_phy2log(uint8_t physical_endpoint)
static void qtd_init(dcd_qtd_t* p_qtd, void * data_ptr, uint16_t total_bytes)
{
- memclr_(p_qtd, sizeof(dcd_qtd_t));
+ tu_memclr(p_qtd, sizeof(dcd_qtd_t));
p_qtd->used = 1;
@@ -303,7 +303,7 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
uint8_t ep_idx = edpt_addr2phy(p_endpoint_desc->bEndpointAddress);
dcd_qhd_t * p_qhd = &dcd_data_ptr[rhport]->qhd[ep_idx];
- memclr_(p_qhd, sizeof(dcd_qhd_t));
+ tu_memclr(p_qhd, sizeof(dcd_qhd_t));
p_qhd->zero_length_termination = 1;
p_qhd->max_package_size = p_endpoint_desc->wMaxPacketSize.size;