Remove mbed wait deprecated APIs

pull/12572/head
Rajkumar Kanagaraj 2020-03-03 09:55:36 -08:00
parent 4b3cddff2a
commit 83be3f24a5
40 changed files with 115 additions and 248 deletions

View File

@ -61,7 +61,7 @@ static volatile event_t received_event;
static void tx_done() static void tx_done()
{ {
wait_ms(2); thread_sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event); TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_TX_DONE; received_event = EV_TX_DONE;
TEST_ASSERT_EQUAL(osOK, event_sem.release()); TEST_ASSERT_EQUAL(osOK, event_sem.release());
@ -69,7 +69,7 @@ static void tx_done()
static void tx_timeout() static void tx_timeout()
{ {
wait_ms(2); thread_sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event); TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_TX_TIMEOUT; received_event = EV_TX_TIMEOUT;
TEST_ASSERT_EQUAL(osOK, event_sem.release()); TEST_ASSERT_EQUAL(osOK, event_sem.release());
@ -77,7 +77,7 @@ static void tx_timeout()
static void rx_done(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) static void rx_done(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
{ {
wait_ms(2); thread_sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event); TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_RX_DONE; received_event = EV_RX_DONE;
TEST_ASSERT_EQUAL(osOK, event_sem.release()); TEST_ASSERT_EQUAL(osOK, event_sem.release());
@ -85,7 +85,7 @@ static void rx_done(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t
static void rx_timeout() static void rx_timeout()
{ {
wait_ms(2); thread_sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event); TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_RX_TIMEOUT; received_event = EV_RX_TIMEOUT;
TEST_ASSERT_EQUAL(osOK, event_sem.release()); TEST_ASSERT_EQUAL(osOK, event_sem.release());
@ -93,7 +93,7 @@ static void rx_timeout()
static void rx_error() static void rx_error()
{ {
wait_ms(2); thread_sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event); TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_RX_ERROR; received_event = EV_RX_ERROR;
TEST_ASSERT_EQUAL(osOK, event_sem.release()); TEST_ASSERT_EQUAL(osOK, event_sem.release());

View File

@ -103,7 +103,7 @@ static cmd_status_t handle_command(const char *key, const char *value)
if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_NVIC) == 0) { if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_NVIC) == 0) {
greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK); greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK);
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. thread_sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
NVIC_SystemReset(); NVIC_SystemReset();
TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected."); TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected.");
return CMD_STATUS_ERROR; return CMD_STATUS_ERROR;
@ -112,13 +112,13 @@ static cmd_status_t handle_command(const char *key, const char *value)
#if DEVICE_WATCHDOG #if DEVICE_WATCHDOG
if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) { if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) {
greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK); greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK);
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. thread_sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS }; watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS };
if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) { if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) {
TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error."); TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error.");
return CMD_STATUS_ERROR; return CMD_STATUS_ERROR;
} }
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value. thread_sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
return CMD_STATUS_ERROR; return CMD_STATUS_ERROR;
} }

View File

@ -451,7 +451,7 @@ void test_functional_count()
set_time(CUSTOM_TIME_2); set_time(CUSTOM_TIME_2);
/* Wait 10 sec. */ /* Wait 10 sec. */
wait_ms(DELAY_10_SEC * MS_PER_SEC); thread_sleep_for(DELAY_10_SEC * MS_PER_SEC);
/* Get time. */ /* Get time. */
seconds = time(NULL); seconds = time(NULL);

View File

@ -94,7 +94,7 @@ void test_stop()
TEST_ASSERT_TRUE(watchdog.stop()); TEST_ASSERT_TRUE(watchdog.stop());
TEST_ASSERT_FALSE(watchdog.is_running()); TEST_ASSERT_FALSE(watchdog.is_running());
// Make sure that a disabled watchdog does not reset the core. // Make sure that a disabled watchdog does not reset the core.
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value. thread_sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
TEST_ASSERT_FALSE(watchdog.stop()); TEST_ASSERT_FALSE(watchdog.stop());
} }
@ -173,7 +173,7 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
} }
greentea_send_kv(MSG_KEY_DEVICE_RESET, CASE_INDEX_START + CASE_INDEX_CURRENT); greentea_send_kv(MSG_KEY_DEVICE_RESET, CASE_INDEX_START + CASE_INDEX_CURRENT);
utest_printf("The device will now restart.\n"); utest_printf("The device will now restart.\n");
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. thread_sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
NVIC_SystemReset(); NVIC_SystemReset();
return status; // Reset is instant so this line won't be reached. return status; // Reset is instant so this line won't be reached.
} }

View File

@ -98,7 +98,7 @@ static cmd_status_t handle_command(const char *key, const char *value)
if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_NVIC) == 0) { if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_NVIC) == 0) {
greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK); greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK);
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. thread_sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
NVIC_SystemReset(); NVIC_SystemReset();
TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected."); TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected.");
return CMD_STATUS_ERROR; return CMD_STATUS_ERROR;
@ -107,13 +107,13 @@ static cmd_status_t handle_command(const char *key, const char *value)
#if DEVICE_WATCHDOG #if DEVICE_WATCHDOG
if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) { if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) {
greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK); greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK);
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. thread_sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS }; watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS };
if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) { if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) {
TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error."); TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error.");
return CMD_STATUS_ERROR; return CMD_STATUS_ERROR;
} }
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value. thread_sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
return CMD_STATUS_ERROR; return CMD_STATUS_ERROR;
} }

View File

@ -61,9 +61,9 @@ void rtc_sleep_test_support(bool deepsleep_mode)
* to allow for hardware serial buffers to completely flush. * to allow for hardware serial buffers to completely flush.
* This should be replaced with a better function that checks if the * This should be replaced with a better function that checks if the
* hardware buffers are empty. However, such an API does not exist now, * hardware buffers are empty. However, such an API does not exist now,
* so we'll use the wait_ms() function for now. * so we'll use the thread_sleep_for() function for now.
*/ */
wait_ms(10); thread_sleep_for(10);
rtc_init(); rtc_init();

View File

@ -187,7 +187,7 @@ void test_set_time_twice()
TEST_ASSERT_EQUAL(true, (current_time == NEW_TIME)); TEST_ASSERT_EQUAL(true, (current_time == NEW_TIME));
/* Wait 2 seconds */ /* Wait 2 seconds */
wait_ms(2000); thread_sleep_for(2000);
/* set the time to NEW_TIME again and check it */ /* set the time to NEW_TIME again and check it */
set_time(NEW_TIME); set_time(NEW_TIME);

View File

@ -100,7 +100,7 @@ void test_stop()
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_init(&WDG_CONFIG_DEFAULT)); TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_init(&WDG_CONFIG_DEFAULT));
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_stop()); TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_stop());
// Make sure that a disabled watchdog does not reset the core. // Make sure that a disabled watchdog does not reset the core.
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value. thread_sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_stop()); TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_stop());
} }
@ -170,7 +170,7 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
} }
greentea_send_kv(MSG_KEY_DEVICE_RESET, CASE_INDEX_START + CASE_INDEX_CURRENT); greentea_send_kv(MSG_KEY_DEVICE_RESET, CASE_INDEX_START + CASE_INDEX_CURRENT);
utest_printf("The device will now restart.\n"); utest_printf("The device will now restart.\n");
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. thread_sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
NVIC_SystemReset(); NVIC_SystemReset();
return status; // Reset is instant so this line won't be reached. return status; // Reset is instant so this line won't be reached.
} }

View File

@ -127,11 +127,11 @@ void fpga_pwm_period_fill_test(PinName pin, uint32_t period_ms, uint32_t fill_pr
break; break;
} }
wait(PERIOD_FLOAT(period_ms)); thread_sleep_for(period_ms);
tester.io_metrics_start(); tester.io_metrics_start();
wait(NUM_OF_PERIODS * PERIOD_FLOAT(period_ms)); thread_sleep_for(NUM_OF_PERIODS * period_ms);
tester.io_metrics_stop(); tester.io_metrics_stop();
core_util_critical_section_exit(); core_util_critical_section_exit();

View File

@ -56,14 +56,14 @@ void test_notify_one()
t1.start(increment_on_signal); t1.start(increment_on_signal);
t2.start(increment_on_signal); t2.start(increment_on_signal);
wait_ms(TEST_DELAY); ThisThread::sleep_for(TEST_DELAY);
TEST_ASSERT_EQUAL(0, change_counter); TEST_ASSERT_EQUAL(0, change_counter);
mutex.lock(); mutex.lock();
cond.notify_one(); cond.notify_one();
mutex.unlock(); mutex.unlock();
wait_ms(TEST_DELAY); ThisThread::sleep_for(TEST_DELAY);
TEST_ASSERT_EQUAL(1, change_counter); TEST_ASSERT_EQUAL(1, change_counter);
mutex.lock(); mutex.lock();
@ -83,14 +83,14 @@ void test_notify_all()
t1.start(increment_on_signal); t1.start(increment_on_signal);
t2.start(increment_on_signal); t2.start(increment_on_signal);
wait_ms(TEST_DELAY); ThisThread::sleep_for(TEST_DELAY);
TEST_ASSERT_EQUAL(0, change_counter); TEST_ASSERT_EQUAL(0, change_counter);
mutex.lock(); mutex.lock();
cond.notify_all(); cond.notify_all();
mutex.unlock(); mutex.unlock();
wait_ms(TEST_DELAY); ThisThread::sleep_for(TEST_DELAY);
TEST_ASSERT_EQUAL(2, change_counter); TEST_ASSERT_EQUAL(2, change_counter);
t1.join(); t1.join();

View File

@ -155,7 +155,7 @@ void test_dual_thread_nolock(void)
thread.start(callback(F, &mutex)); thread.start(callback(F, &mutex));
wait_ms(TEST_DELAY); ThisThread::sleep_for(TEST_DELAY);
} }
void test_dual_thread_lock_unlock_thread(Mutex *mutex) void test_dual_thread_lock_unlock_thread(Mutex *mutex)
@ -184,7 +184,7 @@ void test_dual_thread_lock_unlock(void)
mutex.unlock(); mutex.unlock();
wait_ms(TEST_DELAY); ThisThread::sleep_for(TEST_DELAY);
} }
void test_dual_thread_lock_trylock_thread(Mutex *mutex) void test_dual_thread_lock_trylock_thread(Mutex *mutex)
@ -228,7 +228,7 @@ void test_dual_thread_lock(void)
thread.start(callback(F, &mutex)); thread.start(callback(F, &mutex));
wait_ms(TEST_LONG_DELAY); ThisThread::sleep_for(TEST_LONG_DELAY);
mutex.unlock(); mutex.unlock();
} }

View File

@ -303,9 +303,9 @@ void test_deepsleep(void)
* This should be replaced with a better function that checks if the * This should be replaced with a better function that checks if the
* hardware buffers are empty. However, such an API does not exist now, * hardware buffers are empty. However, such an API does not exist now,
* so we'll use the wait_ms() function for now. * so we'll use the ThisThread::sleep_for() function for now.
*/ */
wait_ms(10); ThisThread::sleep_for(10);
// Regular Timer might be disabled during deepsleep. // Regular Timer might be disabled during deepsleep.
LowPowerTimer lptimer; LowPowerTimer lptimer;
SysTimerTest<TEST_TICK_US> st; SysTimerTest<TEST_TICK_US> st;

View File

@ -233,7 +233,7 @@ void ep_test_data_correctness()
// Wait for host before terminating // Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG #if EP_DBG
wait_ms(100); thread_sleep_for(100);
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf()); printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf()); printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out()); printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@ -270,7 +270,7 @@ void ep_test_halt()
// Wait for host before terminating // Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG #if EP_DBG
wait_ms(100); thread_sleep_for(100);
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf()); printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf()); printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out()); printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@ -307,7 +307,7 @@ void ep_test_parallel_transfers()
// Wait for host before terminating // Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG #if EP_DBG
wait_ms(100); thread_sleep_for(100);
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf()); printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf()); printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out()); printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@ -345,7 +345,7 @@ void ep_test_parallel_transfers_ctrl()
// Wait for host before terminating // Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG #if EP_DBG
wait_ms(100); thread_sleep_for(100);
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf()); printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf()); printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out()); printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@ -381,7 +381,7 @@ void ep_test_abort()
greentea_send_kv("ep_test_abort", serial.get_serial_desc_string()); greentea_send_kv("ep_test_abort", serial.get_serial_desc_string());
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG #if EP_DBG
wait_ms(100); thread_sleep_for(100);
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf()); printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf()); printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out()); printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@ -420,7 +420,7 @@ void ep_test_data_toggle()
greentea_send_kv("ep_test_data_toggle", serial.get_serial_desc_string()); greentea_send_kv("ep_test_data_toggle", serial.get_serial_desc_string());
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG #if EP_DBG
wait_ms(100); thread_sleep_for(100);
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf()); printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf()); printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out()); printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@ -566,7 +566,7 @@ void device_suspend_resume_test()
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
printf("[2] suspend_count: %d resume_count: %d\n", serial.get_suspend_count(), serial.get_resume_count()); printf("[2] suspend_count: %d resume_count: %d\n", serial.get_suspend_count(), serial.get_resume_count());
TEST_ASSERT_EQUAL_STRING("pass", _key); TEST_ASSERT_EQUAL_STRING("pass", _key);
wait_ms(5000); thread_sleep_for(5000);
printf("[3] suspend_count: %d resume_count: %d\n", serial.get_suspend_count(), serial.get_resume_count()); printf("[3] suspend_count: %d resume_count: %d\n", serial.get_suspend_count(), serial.get_resume_count());
} }
} }

View File

@ -440,7 +440,7 @@ void mount_unmount_and_data_test(BlockDevice *bd, FileSystem *fs)
TEST_ASSERT_EQUAL_STRING("passed", _key); TEST_ASSERT_EQUAL_STRING("passed", _key);
do { do {
wait_ms(1); thread_sleep_for(1);
} while (test_files_exist(fs_root)); } while (test_files_exist(fs_root));
TEST_ASSERT_EQUAL(false, test_files_exist(fs_root)); TEST_ASSERT_EQUAL(false, test_files_exist(fs_root));

View File

@ -296,7 +296,7 @@ void test_cdc_usb_reconnect()
usb_cdc.connect(); usb_cdc.connect();
// Wait for the USB enumeration to complete. // Wait for the USB enumeration to complete.
while (!usb_cdc.configured()) { while (!usb_cdc.configured()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_cdc.configured()); TEST_ASSERT_TRUE(usb_cdc.configured());
TEST_ASSERT_FALSE(usb_cdc.ready()); TEST_ASSERT_FALSE(usb_cdc.ready());
@ -305,7 +305,7 @@ void test_cdc_usb_reconnect()
// Wait for the host to open the port. // Wait for the host to open the port.
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_cdc.wait_ready(); usb_cdc.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_cdc.wait_ready(); usb_cdc.wait_ready();
TEST_ASSERT_TRUE(usb_cdc.configured()); TEST_ASSERT_TRUE(usb_cdc.configured());
@ -316,12 +316,12 @@ void test_cdc_usb_reconnect()
TEST_ASSERT_FALSE(usb_cdc.configured()); TEST_ASSERT_FALSE(usb_cdc.configured());
TEST_ASSERT_FALSE(usb_cdc.ready()); TEST_ASSERT_FALSE(usb_cdc.ready());
wait_ms(USB_RECONNECT_DELAY_MS); thread_sleep_for(USB_RECONNECT_DELAY_MS);
// Connect the USB device again. // Connect the USB device again.
usb_cdc.connect(); usb_cdc.connect();
// Wait for the USB enumeration to complete. // Wait for the USB enumeration to complete.
while (!usb_cdc.configured()) { while (!usb_cdc.configured()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_cdc.configured()); TEST_ASSERT_TRUE(usb_cdc.configured());
TEST_ASSERT_FALSE(usb_cdc.ready()); TEST_ASSERT_FALSE(usb_cdc.ready());
@ -330,7 +330,7 @@ void test_cdc_usb_reconnect()
// Wait for the host to open the port again. // Wait for the host to open the port again.
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_cdc.wait_ready(); usb_cdc.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_cdc.wait_ready(); usb_cdc.wait_ready();
TEST_ASSERT_TRUE(usb_cdc.configured()); TEST_ASSERT_TRUE(usb_cdc.configured());
@ -355,7 +355,7 @@ void test_cdc_rx_single_bytes()
greentea_send_kv(MSG_KEY_SEND_BYTES_SINGLE, MSG_VALUE_DUMMY); greentea_send_kv(MSG_KEY_SEND_BYTES_SINGLE, MSG_VALUE_DUMMY);
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_cdc.wait_ready(); usb_cdc.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_cdc.wait_ready(); usb_cdc.wait_ready();
uint8_t buff = 0x01; uint8_t buff = 0x01;
@ -369,7 +369,7 @@ void test_cdc_rx_single_bytes()
} }
// Wait for the host to close its port. // Wait for the host to close its port.
while (usb_cdc.ready()) { while (usb_cdc.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
usb_cdc.disconnect(); usb_cdc.disconnect();
} }
@ -380,7 +380,7 @@ void tx_thread_fun(USBCDC *usb_cdc)
uint8_t buff[TX_BUFF_SIZE] = { 0 }; uint8_t buff[TX_BUFF_SIZE] = { 0 };
while (event_flags.get() & EF_SEND) { while (event_flags.get() & EF_SEND) {
if (!usb_cdc->send(buff, TX_BUFF_SIZE)) { if (!usb_cdc->send(buff, TX_BUFF_SIZE)) {
wait_ms(1); thread_sleep_for(1);
continue; continue;
} }
buff_val++; buff_val++;
@ -402,7 +402,7 @@ void test_cdc_rx_single_bytes_concurrent()
greentea_send_kv(MSG_KEY_SEND_BYTES_SINGLE, MSG_VALUE_DUMMY); greentea_send_kv(MSG_KEY_SEND_BYTES_SINGLE, MSG_VALUE_DUMMY);
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_cdc.wait_ready(); usb_cdc.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_cdc.wait_ready(); usb_cdc.wait_ready();
Thread tx_thread; Thread tx_thread;
@ -421,7 +421,7 @@ void test_cdc_rx_single_bytes_concurrent()
tx_thread.join(); tx_thread.join();
// Wait for the host to close its port. // Wait for the host to close its port.
while (usb_cdc.ready()) { while (usb_cdc.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
usb_cdc.disconnect(); usb_cdc.disconnect();
} }
@ -439,7 +439,7 @@ void test_cdc_rx_multiple_bytes()
greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, HOST_RX_BUFF_SIZE_RATIO); greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, HOST_RX_BUFF_SIZE_RATIO);
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_cdc.wait_ready(); usb_cdc.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_cdc.wait_ready(); usb_cdc.wait_ready();
uint8_t buff[RX_BUFF_SIZE] = { 0 }; uint8_t buff[RX_BUFF_SIZE] = { 0 };
@ -460,7 +460,7 @@ void test_cdc_rx_multiple_bytes()
} }
// Wait for the host to close its port. // Wait for the host to close its port.
while (usb_cdc.ready()) { while (usb_cdc.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
usb_cdc.disconnect(); usb_cdc.disconnect();
} }
@ -479,7 +479,7 @@ void test_cdc_rx_multiple_bytes_concurrent()
greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, HOST_RX_BUFF_SIZE_RATIO); greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, HOST_RX_BUFF_SIZE_RATIO);
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_cdc.wait_ready(); usb_cdc.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_cdc.wait_ready(); usb_cdc.wait_ready();
Thread tx_thread; Thread tx_thread;
@ -505,7 +505,7 @@ void test_cdc_rx_multiple_bytes_concurrent()
tx_thread.join(); tx_thread.join();
// Wait for the host to close its port. // Wait for the host to close its port.
while (usb_cdc.ready()) { while (usb_cdc.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
usb_cdc.disconnect(); usb_cdc.disconnect();
} }
@ -524,7 +524,7 @@ void test_cdc_loopback()
greentea_send_kv(MSG_KEY_LOOPBACK, MSG_VALUE_DUMMY); greentea_send_kv(MSG_KEY_LOOPBACK, MSG_VALUE_DUMMY);
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_cdc.wait_ready(); usb_cdc.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_cdc.wait_ready(); usb_cdc.wait_ready();
uint8_t rx_buff, tx_buff; uint8_t rx_buff, tx_buff;
@ -537,7 +537,7 @@ void test_cdc_loopback()
} }
// Wait for the host to close its port. // Wait for the host to close its port.
while (usb_cdc.ready()) { while (usb_cdc.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
usb_cdc.disconnect(); usb_cdc.disconnect();
} }
@ -559,7 +559,7 @@ void test_serial_usb_reconnect()
usb_serial.connect(); usb_serial.connect();
// Wait for the USB enumeration to complete. // Wait for the USB enumeration to complete.
while (!usb_serial.configured()) { while (!usb_serial.configured()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_serial.configured()); TEST_ASSERT_TRUE(usb_serial.configured());
TEST_ASSERT_FALSE(usb_serial.connected()); TEST_ASSERT_FALSE(usb_serial.connected());
@ -569,10 +569,10 @@ void test_serial_usb_reconnect()
// Wait for the host to open the port. // Wait for the host to open the port.
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_serial.wait_ready(); usb_serial.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
while (!usb_serial.connected()) { while (!usb_serial.connected()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_serial.configured()); TEST_ASSERT_TRUE(usb_serial.configured());
TEST_ASSERT_TRUE(usb_serial.connected()); TEST_ASSERT_TRUE(usb_serial.connected());
@ -584,12 +584,12 @@ void test_serial_usb_reconnect()
TEST_ASSERT_FALSE(usb_serial.connected()); TEST_ASSERT_FALSE(usb_serial.connected());
TEST_ASSERT_EQUAL_INT(0, usb_serial.readable()); TEST_ASSERT_EQUAL_INT(0, usb_serial.readable());
wait_ms(USB_RECONNECT_DELAY_MS); thread_sleep_for(USB_RECONNECT_DELAY_MS);
// Connect the USB device again. // Connect the USB device again.
usb_serial.connect(); usb_serial.connect();
// Wait for the USB enumeration to complete. // Wait for the USB enumeration to complete.
while (!usb_serial.configured()) { while (!usb_serial.configured()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_serial.configured()); TEST_ASSERT_TRUE(usb_serial.configured());
TEST_ASSERT_FALSE(usb_serial.connected()); TEST_ASSERT_FALSE(usb_serial.connected());
@ -599,10 +599,10 @@ void test_serial_usb_reconnect()
// Wait for the host to open the port again. // Wait for the host to open the port again.
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_serial.wait_ready(); usb_serial.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
while (!usb_serial.connected()) { while (!usb_serial.connected()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_serial.configured()); TEST_ASSERT_TRUE(usb_serial.configured());
TEST_ASSERT_TRUE(usb_serial.connected()); TEST_ASSERT_TRUE(usb_serial.connected());
@ -629,10 +629,10 @@ void test_serial_term_reopen()
// Wait for the host to open the terminal. // Wait for the host to open the terminal.
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_serial.wait_ready(); usb_serial.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
while (!usb_serial.connected()) { while (!usb_serial.connected()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_serial.configured()); TEST_ASSERT_TRUE(usb_serial.configured());
TEST_ASSERT_TRUE(usb_serial.ready()); TEST_ASSERT_TRUE(usb_serial.ready());
@ -641,7 +641,7 @@ void test_serial_term_reopen()
// Wait for the host to close the terminal. // Wait for the host to close the terminal.
while (usb_serial.ready()) { while (usb_serial.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_serial.configured()); TEST_ASSERT_TRUE(usb_serial.configured());
TEST_ASSERT_FALSE(usb_serial.ready()); TEST_ASSERT_FALSE(usb_serial.ready());
@ -652,10 +652,10 @@ void test_serial_term_reopen()
// Wait for the host to open the terminal again. // Wait for the host to open the terminal again.
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_serial.wait_ready(); usb_serial.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
while (!usb_serial.connected()) { while (!usb_serial.connected()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_serial.configured()); TEST_ASSERT_TRUE(usb_serial.configured());
TEST_ASSERT_TRUE(usb_serial.ready()); TEST_ASSERT_TRUE(usb_serial.ready());
@ -664,7 +664,7 @@ void test_serial_term_reopen()
// Wait for the host to close the terminal again. // Wait for the host to close the terminal again.
while (usb_serial.ready()) { while (usb_serial.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
TEST_ASSERT_TRUE(usb_serial.configured()); TEST_ASSERT_TRUE(usb_serial.configured());
TEST_ASSERT_FALSE(usb_serial.ready()); TEST_ASSERT_FALSE(usb_serial.ready());
@ -687,7 +687,7 @@ void test_serial_getc()
greentea_send_kv(MSG_KEY_SEND_BYTES_SINGLE, MSG_VALUE_DUMMY); greentea_send_kv(MSG_KEY_SEND_BYTES_SINGLE, MSG_VALUE_DUMMY);
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_serial.wait_ready(); usb_serial.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_serial.wait_ready(); usb_serial.wait_ready();
for (int expected = 0xff; expected >= 0; expected--) { for (int expected = 0xff; expected >= 0; expected--) {
@ -698,7 +698,7 @@ void test_serial_getc()
} }
// Wait for the host to close its port. // Wait for the host to close its port.
while (usb_serial.ready()) { while (usb_serial.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
usb_serial.disconnect(); usb_serial.disconnect();
} }
@ -719,7 +719,7 @@ void test_serial_printf_scanf()
greentea_send_kv(MSG_KEY_LOOPBACK, MSG_VALUE_DUMMY); greentea_send_kv(MSG_KEY_LOOPBACK, MSG_VALUE_DUMMY);
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_serial.wait_ready(); usb_serial.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_serial.wait_ready(); usb_serial.wait_ready();
static const char fmt[] = "Formatted\nstring %i."; static const char fmt[] = "Formatted\nstring %i.";
@ -735,7 +735,7 @@ void test_serial_printf_scanf()
} }
// Wait for the host to close its port. // Wait for the host to close its port.
while (usb_serial.ready()) { while (usb_serial.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
usb_serial.disconnect(); usb_serial.disconnect();
} }
@ -764,7 +764,7 @@ void test_serial_line_coding_change()
greentea_send_kv(MSG_KEY_CHANGE_LINE_CODING, MSG_VALUE_DUMMY); greentea_send_kv(MSG_KEY_CHANGE_LINE_CODING, MSG_VALUE_DUMMY);
#if LINUX_HOST_DTR_FIX #if LINUX_HOST_DTR_FIX
usb_serial.wait_ready(); usb_serial.wait_ready();
wait_ms(LINUX_HOST_DTR_FIX_DELAY_MS); thread_sleep_for(LINUX_HOST_DTR_FIX_DELAY_MS);
#endif #endif
usb_serial.wait_ready(); usb_serial.wait_ready();
usb_serial.attach(line_coding_changed_cb); usb_serial.attach(line_coding_changed_cb);
@ -805,7 +805,7 @@ void test_serial_line_coding_change()
} }
// Wait for the host to close its port. // Wait for the host to close its port.
while (usb_serial.ready()) { while (usb_serial.ready()) {
wait_ms(1); thread_sleep_for(1);
} }
usb_serial.disconnect(); usb_serial.disconnect();
} }

View File

@ -17,14 +17,6 @@
#include "mbed_wait_api.h" #include "mbed_wait_api.h"
void wait(float s)
{
}
void wait_ms(int ms)
{
}
void wait_us(int us) void wait_us(int us)
{ {
} }

View File

@ -22,8 +22,6 @@
extern "C" { extern "C" {
#endif #endif
void wait_ms(int ms);
void wait_us(int us); void wait_us(int us);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -59,7 +59,7 @@
* int toggle = 0; * int toggle = 0;
* while (1) { * while (1) {
* tester.gpio_write(MbedTester::LogicalPinGPIO0, toggle, true); * tester.gpio_write(MbedTester::LogicalPinGPIO0, toggle, true);
* wait(0.5); * thread_sleep_for(500);
* toggle = !toggle; * toggle = !toggle;
* } * }
* } * }

View File

@ -154,7 +154,7 @@ public:
* printf("Message received: %d\n\n", msg.data[0]); * printf("Message received: %d\n\n", msg.data[0]);
* led2 = !led2; * led2 = !led2;
* } * }
* wait(0.2); * thread_sleep_for(200);
* } * }
* } * }
* *

View File

@ -46,7 +46,7 @@ namespace mbed {
* if(enable) { * if(enable) {
* led = !led; * led = !led;
* } * }
* wait(0.25); * thread_sleep_for(250);
* } * }
* } * }
* @endcode * @endcode

View File

@ -41,7 +41,7 @@ namespace mbed {
* int main() { * int main() {
* while(1) { * while(1) {
* led = !led; * led = !led;
* wait(0.2); * thread_sleep_for(200);
* } * }
* } * }
* @endcode * @endcode

View File

@ -66,7 +66,7 @@ namespace mbed {
* // set up configuration register (at 0x01) * // set up configuration register (at 0x01)
* i2c.write(addr8bit, cmd, 2); * i2c.write(addr8bit, cmd, 2);
* *
* wait(0.5); * thread_sleep_for(500);
* *
* // read temperature register * // read temperature register
* cmd[0] = 0x00; * cmd[0] = 0x00;

View File

@ -57,7 +57,7 @@ namespace mbed {
* event.rise(&trigger); * event.rise(&trigger);
* while(1) { * while(1) {
* led = !led; * led = !led;
* wait(0.25); * thread_sleep_for(250);
* } * }
* } * }
* @endcode * @endcode

View File

@ -48,9 +48,9 @@ namespace mbed {
* int main() { * int main() {
* while(1) { * while(1) {
* ledport = LED_MASK; * ledport = LED_MASK;
* wait(1); * thread_sleep_for(1000);
* ledport = 0; * ledport = 0;
* wait(1); * thread_sleep_for(1000);
* } * }
* } * }
* @endcode * @endcode

View File

@ -43,7 +43,7 @@ namespace mbed {
* int main() { * int main() {
* while(1) { * while(1) {
* led = led + 0.01; * led = led + 0.01;
* wait(0.2); * thread_sleep_for(200);
* if(led == 1.0) { * if(led == 1.0) {
* led = 0; * led = 0;
* } * }

View File

@ -61,7 +61,7 @@ namespace mbed {
* } else { * } else {
* led2 = !led2; * led2 = !led2;
* } * }
* wait(0.2); * thread_sleep_for(200);
* } * }
* } * }
* @endcode * @endcode

View File

@ -52,7 +52,7 @@ namespace mbed {
* timeout.attach(&attimeout, 5); * timeout.attach(&attimeout, 5);
* while(on) { * while(on) {
* led = !led; * led = !led;
* wait(0.2); * thread_sleep_for(200);
* } * }
* } * }
* @endcode * @endcode

View File

@ -93,7 +93,7 @@ enum FUNCTION_KEY {
* { * {
* while (1) { * while (1) {
* key.printf("Hello World\r\n"); * key.printf("Hello World\r\n");
* wait(1); * thread_sleep_for(1000);
* } * }
* } * }
* *

View File

@ -49,9 +49,9 @@
* while (1) { * while (1) {
* for(int i=48; i<83; i++) { // send some messages! * for(int i=48; i<83; i++) { // send some messages!
* midi.write(MIDIMessage::NoteOn(i)); * midi.write(MIDIMessage::NoteOn(i));
* wait(0.25); * thread_sleep_for(250);
* midi.write(MIDIMessage::NoteOff(i)); * midi.write(MIDIMessage::NoteOff(i));
* wait(0.5); * thread_sleep_for(500);
* } * }
* } * }
* } * }

View File

@ -69,7 +69,7 @@ enum MOUSE_TYPE {
* while (1) * while (1)
* { * {
* mouse.move(20, 0); * mouse.move(20, 0);
* wait(0.5); * thread_sleep_for(500);
* } * }
* } * }
* *
@ -102,7 +102,7 @@ enum MOUSE_TYPE {
* *
* mouse.move(x_screen, y_screen); * mouse.move(x_screen, y_screen);
* angle += 3; * angle += 3;
* wait(0.01); * thread_sleep_for(10);
* } * }
* } * }
* *

View File

@ -49,7 +49,7 @@
* { * {
* key_mouse.move(20, 0); * key_mouse.move(20, 0);
* key_mouse.printf("Hello From MBED\r\n"); * key_mouse.printf("Hello From MBED\r\n");
* wait(1); * thread_sleep_for(1000);
* } * }
* } * }
* @endcode * @endcode
@ -68,7 +68,7 @@
* { * {
* key_mouse.move(X_MAX_ABS/2, Y_MAX_ABS/2); * key_mouse.move(X_MAX_ABS/2, Y_MAX_ABS/2);
* key_mouse.printf("Hello from MBED\r\n"); * key_mouse.printf("Hello from MBED\r\n");
* wait(1); * thread_sleep_for(1000);
* } * }
* } * }
* @endcode * @endcode

View File

@ -43,7 +43,7 @@
* while(1) * while(1)
* { * {
* serial.printf("I am a virtual serial port\n"); * serial.printf("I am a virtual serial port\n");
* wait(1); * thread_sleep_for(1000);
* } * }
* } * }
* @endcode * @endcode

View File

@ -150,9 +150,9 @@ void ble::vendor::odin_w2::HCIDriver::do_initialize()
hci_rts = 1; // Flow Control is OFF hci_rts = 1; // Flow Control is OFF
shutdown = 0; // BT Power is OFF shutdown = 0; // BT Power is OFF
wait_ms(20); thread_sleep_for(20);
shutdown = 1; // BT Power is ON shutdown = 1; // BT Power is ON
wait_ms(500); thread_sleep_for(500);
hci_rts = 0; // Flow Control is ON hci_rts = 0; // Flow Control is ON

View File

@ -96,13 +96,13 @@ public:
output_mode(bt_device_wake_name, 0); output_mode(bt_device_wake_name, 0);
output_mode(bt_power_name, 1); output_mode(bt_power_name, 1);
wait_ms(500); thread_sleep_for(500);
bt_device_wake = 0; bt_device_wake = 0;
wait_ms(500); thread_sleep_for(500);
bt_power = 1; bt_power = 1;
wait_ms(500); thread_sleep_for(500);
} }
virtual void do_terminate() { } virtual void do_terminate() { }
@ -312,7 +312,7 @@ private:
service_pack_next = NULL; service_pack_next = NULL;
service_pack_index = 0; service_pack_index = 0;
service_pack_transfered = true; service_pack_transfered = true;
wait_ms(1000); thread_sleep_for(1000);
set_sleep_mode(); set_sleep_mode();
} }

View File

@ -64,7 +64,7 @@ struct timeval {
* strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
* printf("Time as a custom formatted string = %s", buffer); * printf("Time as a custom formatted string = %s", buffer);
* *
* wait(1); * thread_sleep_for(1000);
* } * }
* } * }
* @endcode * @endcode

View File

@ -41,59 +41,26 @@ extern "C" {
* @code * @code
* #include "mbed.h" * #include "mbed.h"
* *
* DigitalOut heartbeat(LED1); * // Blinking rate in milliseconds
* #define BLINKING_RATE_MS 500
* DigitalOut led(LED2);
* InterruptIn button(SW2);
*
* void blink_led() {
* led = 1;
* wait_us(BLINKING_RATE_MS * 1000);
* led = 0;
* }
* *
* int main() { * int main() {
* while (1) { * button.fall(&blink_led);
* heartbeat = 1; * while(1) {
* wait(0.5); * // Do nothing
* heartbeat = 0;
* wait(0.5);
* } * }
* } * }
* @endcode * @endcode
*/ */
/** Waits for a number of seconds, with microsecond resolution (within
* the accuracy of single precision floating point).
*
* @param s number of seconds to wait
*
* @note
* If the RTOS is present, this function spins to get the exact number of microseconds for
* microsecond precision up to 10 milliseconds. If delay is larger than 10 milliseconds and not in ISR, it is the same as
* `wait_ms`. We recommend `wait_us` and `wait_ms` over `wait`.
*
* @deprecated
* 'wait' is deprecated in favor of explicit sleep functions. To sleep, 'wait' should be replaced by
* 'ThisThread::sleep_for' (C++) or 'thread_sleep_for' (C). If you wish to wait (without sleeping), call
* 'wait_us'. 'wait_us' is safe to call from ISR context.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.14",
"'wait' is deprecated in favor of explicit sleep functions. To sleep, 'wait' should be replaced by "
"'ThisThread::sleep_for' (C++) or 'thread_sleep_for' (C). If you wish to wait (without sleeping), call "
"'wait_us'. 'wait_us' is safe to call from ISR context.")
void wait(float s);
/** Waits a number of milliseconds.
*
* @param ms the whole number of milliseconds to wait
*
* @note
* If the RTOS is present, it calls ThisThread::sleep_for(), which is same as CMSIS osDelay().
* You can't call this from interrupts, and it doesn't lock hardware sleep.
*
* @deprecated
* 'wait_ms' is deprecated in favor of explicit sleep functions. To sleep, 'wait_ms' should be replaced by
* 'ThisThread::sleep_for' (C++) or 'thread_sleep_for' (C). If you wish to wait (without sleeping), call
* 'wait_us'. 'wait_us' is safe to call from ISR context.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.14",
"'wait_ms' is deprecated in favor of explicit sleep functions. To sleep, 'wait_ms' should be replaced by "
"'ThisThread::sleep_for' (C++) or 'thread_sleep_for' (C). If you wish to wait (without sleeping), call "
"'wait_us'. 'wait_us' is safe to call from ISR context.")
void wait_ms(int ms);
/** Waits a number of microseconds. /** Waits a number of microseconds.
* *
* @param us the whole number of microseconds to wait * @param us the whole number of microseconds to wait

View File

@ -23,28 +23,6 @@
#include "hal/us_ticker_api.h" #include "hal/us_ticker_api.h"
#include "hal/ticker_api.h" #include "hal/ticker_api.h"
// This implementation of the wait functions will be compiled only
// if the RTOS is not present.
#ifndef MBED_CONF_RTOS_PRESENT
void wait(float s)
{
wait_ms(s * 1000.0f);
}
void wait_ms(int ms)
{
#if DEVICE_LPTICKER
const ticker_data_t *const ticker = get_lp_ticker_data();
uint32_t start = ticker_read(ticker);
while ((ticker_read(ticker) - start) < (uint32_t)(ms * 1000));
#else
wait_us(ms * 1000);
#endif
}
#endif // #ifndef MBED_CONF_RTOS_PRESENT
// This wait_us is used by both RTOS and non-RTOS builds // This wait_us is used by both RTOS and non-RTOS builds
/* The actual time delay may be 1 less usec */ /* The actual time delay may be 1 less usec */

View File

@ -1,68 +0,0 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2019 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This implementation of the wait functions will be compiled only
// if the RTOS is present. Note that we still use these old
// bare metal versions of wait and wait_ms rather than using
// thread_sleep_for for backwards compatibility. People should
// be prompted to shift via their deprecation.
#ifdef MBED_CONF_RTOS_PRESENT
#include "platform/mbed_wait_api.h"
#include "hal/us_ticker_api.h"
#include "rtos/ThisThread.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_power_mgmt.h"
#include "platform/mbed_error.h"
void wait(float s)
{
if ((s >= 0.01f) && core_util_are_interrupts_enabled()) {
rtos::ThisThread::sleep_for(s * 1000.0f);
return;
}
uint32_t us = (s * 1000000.0f);
const ticker_data_t *const ticker = get_us_ticker_data();
uint32_t start = ticker_read(ticker);
if ((us >= 1000) && core_util_are_interrupts_enabled()) {
// Use the RTOS to wait for millisecond delays if possible
sleep_manager_lock_deep_sleep();
rtos::ThisThread::sleep_for((uint32_t)us / 1000);
sleep_manager_unlock_deep_sleep();
}
// Use busy waiting for sub-millisecond delays, or for the whole
// interval if interrupts are not enabled
while ((ticker_read(ticker) - start) < (uint32_t)us);
}
/* The actual time delay may be up to one timer tick less - 1 msec */
void wait_ms(int ms)
{
if (core_util_is_isr_active() || !core_util_are_interrupts_enabled()) {
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_INVALID_OPERATION),
"Deprecated behavior: milli-sec delay should not be used in interrupt.\n");
#else
wait_us(ms * 1000);
#endif
} else {
rtos::ThisThread::sleep_for(ms);
}
}
#endif // #if MBED_CONF_RTOS_PRESENT

View File

@ -140,7 +140,7 @@ struct Waiter;
* // Mutex must be unlocked before the worker thread can acquire it. * // Mutex must be unlocked before the worker thread can acquire it.
* mutex.unlock(); * mutex.unlock();
* *
* wait(1.0); * thread_sleep_for(1000);
* } * }
* *
* // Change done and notify waiters of this. * // Change done and notify waiters of this.

View File

@ -59,14 +59,14 @@ namespace rtos {
* void blink(DigitalOut *led) { * void blink(DigitalOut *led) {
* while (running) { * while (running) {
* *led = !*led; * *led = !*led;
* wait(1); * ThisThread::sleep_for(1000);
* } * }
* } * }
* *
* // Spawns a thread to run blink for 5 seconds * // Spawns a thread to run blink for 5 seconds
* int main() { * int main() {
* thread.start(callback(blink, &led1)); * thread.start(callback(blink, &led1));
* wait(5); * ThisThread::sleep_for(5000);
* running = false; * running = false;
* thread.join(); * thread.join();
* } * }