mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-01 01:20:14 +00:00
rename timeout_ API to tu_timeout API
This commit is contained in:
parent
361928f429
commit
51903a60c5
@ -142,14 +142,14 @@ bool tud_hid_keyboard_send_string(const char* str, uint32_t interval_ms)
|
|||||||
tud_hid_keyboard_send_char(ch);
|
tud_hid_keyboard_send_char(ch);
|
||||||
|
|
||||||
// Blocking delay
|
// 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
|
/* Only need to empty report if the next character is NULL or the same with
|
||||||
* the current one, else no need to send */
|
* the current one, else no need to send */
|
||||||
if ( lookahead == ch || lookahead == 0 )
|
if ( lookahead == ch || lookahead == 0 )
|
||||||
{
|
{
|
||||||
tud_hid_keyboard_send_report(NULL);
|
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)
|
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;
|
hidd_interface_t * p_hid = &_mse_itf;
|
||||||
memcpy(p_hid->report_buf, p_report, sizeof(hid_mouse_report_t));
|
memcpy(p_hid->report_buf, p_report, sizeof(hid_mouse_report_t));
|
||||||
|
@ -54,26 +54,26 @@ extern "C" {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t start;
|
uint32_t start;
|
||||||
uint32_t interval;
|
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->interval = msec;
|
||||||
tt->start = tusb_hal_millis();
|
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;
|
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;
|
tu_timeout_t tt;
|
||||||
timeout_set(&tt, msec);
|
tu_timeout_set(&tt, msec);
|
||||||
|
|
||||||
// blocking delay
|
// blocking delay
|
||||||
while ( !timeout_expired(&tt) ) { }
|
while ( !tu_timeout_expired(&tt) ) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -268,14 +268,14 @@ static tusb_error_t hcd_controller_init(uint8_t hostid)
|
|||||||
static tusb_error_t hcd_controller_stop(uint8_t hostid)
|
static tusb_error_t hcd_controller_stop(uint8_t hostid)
|
||||||
{
|
{
|
||||||
ehci_registers_t* const regs = get_operational_register(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;
|
regs->usb_cmd_bit.run_stop = 0;
|
||||||
|
|
||||||
timeout_set(&timeout, 2); // USB Spec: controller has to stop within 16 uframe = 2 frames
|
tu_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)) {}
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -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
|
// NXP chip powered with non-host mode --> sts bit is not correctly reflected
|
||||||
(*p_reg_usbcmd) |= BIT_(1);
|
(*p_reg_usbcmd) |= BIT_(1);
|
||||||
|
|
||||||
// timeout_timer_t timeout;
|
// tu_timeout_t timeout;
|
||||||
// timeout_set(&timeout, 2); // should not take longer the time to stop controller
|
// tu_timeout_set(&timeout, 2); // should not take longer the time to stop controller
|
||||||
while( ((*p_reg_usbcmd) & BIT_(1)) /*&& !timeout_expired(&timeout)*/) {}
|
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)
|
bool tusb_hal_init(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user