From 51903a60c51bd1006bec9266dbe1bfb35e282675 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 23 Jul 2018 22:36:29 +0700 Subject: [PATCH] rename timeout_ API to tu_timeout API --- src/class/hid/hid_device.c | 6 +++--- src/common/tusb_timeout.h | 14 +++++++------- src/host/ehci/ehci.c | 8 ++++---- src/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 4ce92772..82c7e3d3 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -142,14 +142,14 @@ bool tud_hid_keyboard_send_string(const char* str, uint32_t interval_ms) tud_hid_keyboard_send_char(ch); // Blocking delay - timeout_blocking_wait(interval_ms); + tu_timeout_wait(interval_ms); /* Only need to empty report if the next character is NULL or the same with * the current one, else no need to send */ if ( lookahead == ch || lookahead == 0 ) { tud_hid_keyboard_send_report(NULL); - timeout_blocking_wait(interval_ms); + tu_timeout_wait(interval_ms); } } @@ -170,7 +170,7 @@ bool tud_hid_mouse_busy(void) bool tud_hid_mouse_send(hid_mouse_report_t const *p_report) { - VERIFY( tud_mounted() && !tud_hid_mouse_is_busy() ); + VERIFY( tud_mounted() && !tud_hid_mouse_busy() ); hidd_interface_t * p_hid = &_mse_itf; memcpy(p_hid->report_buf, p_report, sizeof(hid_mouse_report_t)); diff --git a/src/common/tusb_timeout.h b/src/common/tusb_timeout.h index 40043470..7c51ff36 100644 --- a/src/common/tusb_timeout.h +++ b/src/common/tusb_timeout.h @@ -54,26 +54,26 @@ extern "C" { typedef struct { uint32_t start; uint32_t interval; -}timeout_timer_t; +}tu_timeout_t; -static inline void timeout_set(timeout_timer_t* tt, uint32_t msec) +static inline void tu_timeout_set(tu_timeout_t* tt, uint32_t msec) { tt->interval = msec; tt->start = tusb_hal_millis(); } -static inline bool timeout_expired(timeout_timer_t* tt) +static inline bool tu_timeout_expired(tu_timeout_t* tt) { return ( tusb_hal_millis() - tt->start ) >= tt->interval; } -static inline void timeout_blocking_wait(uint32_t msec) +static inline void tu_timeout_wait(uint32_t msec) { - timeout_timer_t tt; - timeout_set(&tt, msec); + tu_timeout_t tt; + tu_timeout_set(&tt, msec); // blocking delay - while ( !timeout_expired(&tt) ) { } + while ( !tu_timeout_expired(&tt) ) { } } #ifdef __cplusplus diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index 9e326ec5..ba23319c 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -268,14 +268,14 @@ static tusb_error_t hcd_controller_init(uint8_t hostid) static tusb_error_t hcd_controller_stop(uint8_t hostid) { ehci_registers_t* const regs = get_operational_register(hostid); - timeout_timer_t timeout; + tu_timeout_t timeout; regs->usb_cmd_bit.run_stop = 0; - timeout_set(&timeout, 2); // USB Spec: controller has to stop within 16 uframe = 2 frames - while( regs->usb_sts_bit.hc_halted == 0 && !timeout_expired(&timeout)) {} + tu_timeout_set(&timeout, 2); // USB Spec: controller has to stop within 16 uframe = 2 frames + while( regs->usb_sts_bit.hc_halted == 0 && !tu_timeout_expired(&timeout)) {} - return timeout_expired(&timeout) ? TUSB_ERROR_OSAL_TIMEOUT : TUSB_ERROR_NONE; + return tu_timeout_expired(&timeout) ? TUSB_ERROR_OSAL_TIMEOUT : TUSB_ERROR_NONE; } //--------------------------------------------------------------------+ diff --git a/src/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c index 92f9f1cf..18745d03 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/hal_lpc43xx.c @@ -72,11 +72,11 @@ static void hal_controller_reset(uint8_t rhport) // NXP chip powered with non-host mode --> sts bit is not correctly reflected (*p_reg_usbcmd) |= BIT_(1); -// timeout_timer_t timeout; -// timeout_set(&timeout, 2); // should not take longer the time to stop controller - while( ((*p_reg_usbcmd) & BIT_(1)) /*&& !timeout_expired(&timeout)*/) {} +// tu_timeout_t timeout; +// tu_timeout_set(&timeout, 2); // should not take longer the time to stop controller + while( ((*p_reg_usbcmd) & BIT_(1)) /*&& !tu_timeout_expired(&timeout)*/) {} // -// return timeout_expired(&timeout) ? TUSB_ERROR_OSAL_TIMEOUT : TUSB_ERROR_NONE; +// return tu_timeout_expired(&timeout) ? TUSB_ERROR_OSAL_TIMEOUT : TUSB_ERROR_NONE; } bool tusb_hal_init(void)