Skip to content

Remove mbed wait deprecated APIs #12572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions TESTS/lorawan/loraradio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,39 @@ static volatile event_t received_event;

static void tx_done()
{
wait_ms(2);
ThisThread::sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_TX_DONE;
TEST_ASSERT_EQUAL(osOK, event_sem.release());
}

static void tx_timeout()
{
wait_ms(2);
ThisThread::sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_TX_TIMEOUT;
TEST_ASSERT_EQUAL(osOK, event_sem.release());
}

static void rx_done(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
{
wait_ms(2);
ThisThread::sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_RX_DONE;
TEST_ASSERT_EQUAL(osOK, event_sem.release());
}

static void rx_timeout()
{
wait_ms(2);
ThisThread::sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_RX_TIMEOUT;
TEST_ASSERT_EQUAL(osOK, event_sem.release());
}

static void rx_error()
{
wait_ms(2);
ThisThread::sleep_for(2);
TEST_ASSERT_EQUAL(EV_NONE, received_event);
received_event = EV_RX_ERROR;
TEST_ASSERT_EQUAL(osOK, event_sem.release());
Expand Down
6 changes: 3 additions & 3 deletions TESTS/mbed_drivers/reset_reason/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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.
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
NVIC_SystemReset();
TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected.");
return CMD_STATUS_ERROR;
Expand All @@ -112,13 +112,13 @@ static cmd_status_t handle_command(const char *key, const char *value)
#if DEVICE_WATCHDOG
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);
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS };
if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) {
TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error.");
return CMD_STATUS_ERROR;
}
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
ThisThread::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.");
return CMD_STATUS_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbed_drivers/rtc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void test_functional_count()
set_time(CUSTOM_TIME_2);

/* Wait 10 sec. */
wait_ms(DELAY_10_SEC * MS_PER_SEC);
ThisThread::sleep_for(DELAY_10_SEC * MS_PER_SEC);

/* Get time. */
seconds = time(NULL);
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbed_drivers/watchdog/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void test_stop()
TEST_ASSERT_TRUE(watchdog.stop());
TEST_ASSERT_FALSE(watchdog.is_running());
// 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.
ThisThread::sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.

TEST_ASSERT_FALSE(watchdog.stop());
}
Expand Down Expand Up @@ -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);
utest_printf("The device will now restart.\n");
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
NVIC_SystemReset();
return status; // Reset is instant so this line won't be reached.
}
Expand Down
6 changes: 3 additions & 3 deletions TESTS/mbed_hal/reset_reason/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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.
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
NVIC_SystemReset();
TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected.");
return CMD_STATUS_ERROR;
Expand All @@ -107,13 +107,13 @@ static cmd_status_t handle_command(const char *key, const char *value)
#if DEVICE_WATCHDOG
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);
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS };
if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) {
TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error.");
return CMD_STATUS_ERROR;
}
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
ThisThread::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.");
return CMD_STATUS_ERROR;
}
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbed_hal/rtc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ void rtc_sleep_test_support(bool deepsleep_mode)
* to allow for hardware serial buffers to completely flush.
* This should be replaced with a better function that checks if the
* 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);

rtc_init();

Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbed_hal/rtc_time/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void test_set_time_twice()
TEST_ASSERT_EQUAL(true, (current_time == NEW_TIME));

/* Wait 2 seconds */
wait_ms(2000);
ThisThread::sleep_for(2000);

/* set the time to NEW_TIME again and check it */
set_time(NEW_TIME);
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbed_hal/watchdog/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_stop());
// 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.
ThisThread::sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.

TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_stop());
}
Expand Down Expand Up @@ -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);
utest_printf("The device will now restart.\n");
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
NVIC_SystemReset();
return status; // Reset is instant so this line won't be reached.
}
Expand Down
5 changes: 3 additions & 2 deletions TESTS/mbed_hal_fpga_ci_test_shield/pwm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,12 @@ void fpga_pwm_period_fill_test(PinName pin, uint32_t period_ms, uint32_t fill_pr
break;
}

wait(PERIOD_FLOAT(period_ms));
// wait_us is safe to call as this test disable the IRQs on execution.
wait_us(PERIOD_US(period_ms));

tester.io_metrics_start();

wait(NUM_OF_PERIODS * PERIOD_FLOAT(period_ms));
wait_us(NUM_OF_PERIODS * PERIOD_US(period_ms));

tester.io_metrics_stop();
core_util_critical_section_exit();
Expand Down
8 changes: 4 additions & 4 deletions TESTS/mbedmicro-rtos-mbed/condition_variable/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ void test_notify_one()
t1.start(increment_on_signal);
t2.start(increment_on_signal);

wait_ms(TEST_DELAY);
ThisThread::sleep_for(TEST_DELAY);
TEST_ASSERT_EQUAL(0, change_counter);

mutex.lock();
cond.notify_one();
mutex.unlock();

wait_ms(TEST_DELAY);
ThisThread::sleep_for(TEST_DELAY);
TEST_ASSERT_EQUAL(1, change_counter);

mutex.lock();
Expand All @@ -83,14 +83,14 @@ void test_notify_all()
t1.start(increment_on_signal);
t2.start(increment_on_signal);

wait_ms(TEST_DELAY);
ThisThread::sleep_for(TEST_DELAY);
TEST_ASSERT_EQUAL(0, change_counter);

mutex.lock();
cond.notify_all();
mutex.unlock();

wait_ms(TEST_DELAY);
ThisThread::sleep_for(TEST_DELAY);
TEST_ASSERT_EQUAL(2, change_counter);

t1.join();
Expand Down
6 changes: 3 additions & 3 deletions TESTS/mbedmicro-rtos-mbed/mutex/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void test_dual_thread_nolock(void)

thread.start(callback(F, &mutex));

wait_ms(TEST_DELAY);
ThisThread::sleep_for(TEST_DELAY);
}

void test_dual_thread_lock_unlock_thread(Mutex *mutex)
Expand Down Expand Up @@ -184,7 +184,7 @@ void test_dual_thread_lock_unlock(void)

mutex.unlock();

wait_ms(TEST_DELAY);
ThisThread::sleep_for(TEST_DELAY);
}

void test_dual_thread_lock_trylock_thread(Mutex *mutex)
Expand Down Expand Up @@ -228,7 +228,7 @@ void test_dual_thread_lock(void)

thread.start(callback(F, &mutex));

wait_ms(TEST_LONG_DELAY);
ThisThread::sleep_for(TEST_LONG_DELAY);

mutex.unlock();
}
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/systimer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ void test_deepsleep(void)

* This should be replaced with a better function that checks if the
* 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.
LowPowerTimer lptimer;
SysTimerTest<TEST_TICK_US> st;
Expand Down
14 changes: 7 additions & 7 deletions TESTS/usb_device/basic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void ep_test_data_correctness()
// Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG
wait_ms(100);
ThisThread::sleep_for(100);
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_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
Expand Down Expand Up @@ -270,7 +270,7 @@ void ep_test_halt()
// Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG
wait_ms(100);
ThisThread::sleep_for(100);
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_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
Expand Down Expand Up @@ -307,7 +307,7 @@ void ep_test_parallel_transfers()
// Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG
wait_ms(100);
ThisThread::sleep_for(100);
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_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
Expand Down Expand Up @@ -345,7 +345,7 @@ void ep_test_parallel_transfers_ctrl()
// Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG
wait_ms(100);
ThisThread::sleep_for(100);
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_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
Expand Down Expand Up @@ -381,7 +381,7 @@ void ep_test_abort()
greentea_send_kv("ep_test_abort", serial.get_serial_desc_string());
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG
wait_ms(100);
ThisThread::sleep_for(100);
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_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
Expand Down Expand Up @@ -420,7 +420,7 @@ void ep_test_data_toggle()
greentea_send_kv("ep_test_data_toggle", serial.get_serial_desc_string());
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
#if EP_DBG
wait_ms(100);
ThisThread::sleep_for(100);
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_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
Expand Down Expand Up @@ -566,7 +566,7 @@ void device_suspend_resume_test()
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());
TEST_ASSERT_EQUAL_STRING("pass", _key);
wait_ms(5000);
ThisThread::sleep_for(5000);
printf("[3] suspend_count: %d resume_count: %d\n", serial.get_suspend_count(), serial.get_resume_count());
}
}
Expand Down
2 changes: 1 addition & 1 deletion TESTS/usb_device/msd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ void mount_unmount_and_data_test(BlockDevice *bd, FileSystem *fs)
TEST_ASSERT_EQUAL_STRING("passed", _key);

do {
wait_ms(1);
ThisThread::sleep_for(1);
} while (test_files_exist(fs_root));
TEST_ASSERT_EQUAL(false, test_files_exist(fs_root));

Expand Down
Loading