Skip to content

Commit 7fce7f5

Browse files
authored
Merge pull request #12572 from rajkan01/waitapi_remove_deprecated
Remove mbed wait deprecated APIs
2 parents 71c9780 + 3d128e8 commit 7fce7f5

File tree

47 files changed

+136
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+136
-265
lines changed

TESTS/lorawan/loraradio/main.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -61,39 +61,39 @@ static volatile event_t received_event;
6161

6262
static void tx_done()
6363
{
64-
wait_ms(2);
64+
ThisThread::sleep_for(2);
6565
TEST_ASSERT_EQUAL(EV_NONE, received_event);
6666
received_event = EV_TX_DONE;
6767
TEST_ASSERT_EQUAL(osOK, event_sem.release());
6868
}
6969

7070
static void tx_timeout()
7171
{
72-
wait_ms(2);
72+
ThisThread::sleep_for(2);
7373
TEST_ASSERT_EQUAL(EV_NONE, received_event);
7474
received_event = EV_TX_TIMEOUT;
7575
TEST_ASSERT_EQUAL(osOK, event_sem.release());
7676
}
7777

7878
static void rx_done(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
7979
{
80-
wait_ms(2);
80+
ThisThread::sleep_for(2);
8181
TEST_ASSERT_EQUAL(EV_NONE, received_event);
8282
received_event = EV_RX_DONE;
8383
TEST_ASSERT_EQUAL(osOK, event_sem.release());
8484
}
8585

8686
static void rx_timeout()
8787
{
88-
wait_ms(2);
88+
ThisThread::sleep_for(2);
8989
TEST_ASSERT_EQUAL(EV_NONE, received_event);
9090
received_event = EV_RX_TIMEOUT;
9191
TEST_ASSERT_EQUAL(osOK, event_sem.release());
9292
}
9393

9494
static void rx_error()
9595
{
96-
wait_ms(2);
96+
ThisThread::sleep_for(2);
9797
TEST_ASSERT_EQUAL(EV_NONE, received_event);
9898
received_event = EV_RX_ERROR;
9999
TEST_ASSERT_EQUAL(osOK, event_sem.release());

TESTS/mbed_drivers/reset_reason/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static cmd_status_t handle_command(const char *key, const char *value)
103103

104104
if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_NVIC) == 0) {
105105
greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK);
106-
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
106+
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
107107
NVIC_SystemReset();
108108
TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected.");
109109
return CMD_STATUS_ERROR;
@@ -112,13 +112,13 @@ static cmd_status_t handle_command(const char *key, const char *value)
112112
#if DEVICE_WATCHDOG
113113
if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) {
114114
greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK);
115-
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
115+
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
116116
watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS };
117117
if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) {
118118
TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error.");
119119
return CMD_STATUS_ERROR;
120120
}
121-
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
121+
ThisThread::sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
122122
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
123123
return CMD_STATUS_ERROR;
124124
}

TESTS/mbed_drivers/rtc/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void test_functional_count()
451451
set_time(CUSTOM_TIME_2);
452452

453453
/* Wait 10 sec. */
454-
wait_ms(DELAY_10_SEC * MS_PER_SEC);
454+
ThisThread::sleep_for(DELAY_10_SEC * MS_PER_SEC);
455455

456456
/* Get time. */
457457
seconds = time(NULL);

TESTS/mbed_drivers/watchdog/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void test_stop()
9494
TEST_ASSERT_TRUE(watchdog.stop());
9595
TEST_ASSERT_FALSE(watchdog.is_running());
9696
// Make sure that a disabled watchdog does not reset the core.
97-
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
97+
ThisThread::sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
9898

9999
TEST_ASSERT_FALSE(watchdog.stop());
100100
}
@@ -173,7 +173,7 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
173173
}
174174
greentea_send_kv(MSG_KEY_DEVICE_RESET, CASE_INDEX_START + CASE_INDEX_CURRENT);
175175
utest_printf("The device will now restart.\n");
176-
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
176+
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
177177
NVIC_SystemReset();
178178
return status; // Reset is instant so this line won't be reached.
179179
}

TESTS/mbed_hal/reset_reason/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static cmd_status_t handle_command(const char *key, const char *value)
9898

9999
if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_NVIC) == 0) {
100100
greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK);
101-
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
101+
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
102102
NVIC_SystemReset();
103103
TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected.");
104104
return CMD_STATUS_ERROR;
@@ -107,13 +107,13 @@ static cmd_status_t handle_command(const char *key, const char *value)
107107
#if DEVICE_WATCHDOG
108108
if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) {
109109
greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK);
110-
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
110+
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
111111
watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS };
112112
if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) {
113113
TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error.");
114114
return CMD_STATUS_ERROR;
115115
}
116-
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
116+
ThisThread::sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
117117
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
118118
return CMD_STATUS_ERROR;
119119
}

TESTS/mbed_hal/rtc/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ void rtc_sleep_test_support(bool deepsleep_mode)
6161
* to allow for hardware serial buffers to completely flush.
6262
* This should be replaced with a better function that checks if the
6363
* hardware buffers are empty. However, such an API does not exist now,
64-
* so we'll use the wait_ms() function for now.
64+
* so we'll use the ThisThread::sleep_for() function for now.
6565
*/
66-
wait_ms(10);
66+
ThisThread::sleep_for(10);
6767

6868
rtc_init();
6969

TESTS/mbed_hal/rtc_time/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void test_set_time_twice()
187187
TEST_ASSERT_EQUAL(true, (current_time == NEW_TIME));
188188

189189
/* Wait 2 seconds */
190-
wait_ms(2000);
190+
ThisThread::sleep_for(2000);
191191

192192
/* set the time to NEW_TIME again and check it */
193193
set_time(NEW_TIME);

TESTS/mbed_hal/watchdog/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void test_stop()
100100
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_init(&WDG_CONFIG_DEFAULT));
101101
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_stop());
102102
// Make sure that a disabled watchdog does not reset the core.
103-
wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
103+
ThisThread::sleep_for(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value.
104104

105105
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_stop());
106106
}
@@ -170,7 +170,7 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
170170
}
171171
greentea_send_kv(MSG_KEY_DEVICE_RESET, CASE_INDEX_START + CASE_INDEX_CURRENT);
172172
utest_printf("The device will now restart.\n");
173-
wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
173+
ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush.
174174
NVIC_SystemReset();
175175
return status; // Reset is instant so this line won't be reached.
176176
}

TESTS/mbed_hal_fpga_ci_test_shield/pwm/main.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ void fpga_pwm_period_fill_test(PinName pin, uint32_t period_ms, uint32_t fill_pr
127127
break;
128128
}
129129

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

132133
tester.io_metrics_start();
133134

134-
wait(NUM_OF_PERIODS * PERIOD_FLOAT(period_ms));
135+
wait_us(NUM_OF_PERIODS * PERIOD_US(period_ms));
135136

136137
tester.io_metrics_stop();
137138
core_util_critical_section_exit();

TESTS/mbedmicro-rtos-mbed/condition_variable/main.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ void test_notify_one()
5656
t1.start(increment_on_signal);
5757
t2.start(increment_on_signal);
5858

59-
wait_ms(TEST_DELAY);
59+
ThisThread::sleep_for(TEST_DELAY);
6060
TEST_ASSERT_EQUAL(0, change_counter);
6161

6262
mutex.lock();
6363
cond.notify_one();
6464
mutex.unlock();
6565

66-
wait_ms(TEST_DELAY);
66+
ThisThread::sleep_for(TEST_DELAY);
6767
TEST_ASSERT_EQUAL(1, change_counter);
6868

6969
mutex.lock();
@@ -83,14 +83,14 @@ void test_notify_all()
8383
t1.start(increment_on_signal);
8484
t2.start(increment_on_signal);
8585

86-
wait_ms(TEST_DELAY);
86+
ThisThread::sleep_for(TEST_DELAY);
8787
TEST_ASSERT_EQUAL(0, change_counter);
8888

8989
mutex.lock();
9090
cond.notify_all();
9191
mutex.unlock();
9292

93-
wait_ms(TEST_DELAY);
93+
ThisThread::sleep_for(TEST_DELAY);
9494
TEST_ASSERT_EQUAL(2, change_counter);
9595

9696
t1.join();

TESTS/mbedmicro-rtos-mbed/mutex/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void test_dual_thread_nolock(void)
155155

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

158-
wait_ms(TEST_DELAY);
158+
ThisThread::sleep_for(TEST_DELAY);
159159
}
160160

161161
void test_dual_thread_lock_unlock_thread(Mutex *mutex)
@@ -184,7 +184,7 @@ void test_dual_thread_lock_unlock(void)
184184

185185
mutex.unlock();
186186

187-
wait_ms(TEST_DELAY);
187+
ThisThread::sleep_for(TEST_DELAY);
188188
}
189189

190190
void test_dual_thread_lock_trylock_thread(Mutex *mutex)
@@ -228,7 +228,7 @@ void test_dual_thread_lock(void)
228228

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

231-
wait_ms(TEST_LONG_DELAY);
231+
ThisThread::sleep_for(TEST_LONG_DELAY);
232232

233233
mutex.unlock();
234234
}

TESTS/mbedmicro-rtos-mbed/systimer/main.cpp

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

TESTS/usb_device/basic/main.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void ep_test_data_correctness()
233233
// Wait for host before terminating
234234
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
235235
#if EP_DBG
236-
wait_ms(100);
236+
ThisThread::sleep_for(100);
237237
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
238238
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
239239
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@@ -270,7 +270,7 @@ void ep_test_halt()
270270
// Wait for host before terminating
271271
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
272272
#if EP_DBG
273-
wait_ms(100);
273+
ThisThread::sleep_for(100);
274274
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
275275
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
276276
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@@ -307,7 +307,7 @@ void ep_test_parallel_transfers()
307307
// Wait for host before terminating
308308
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
309309
#if EP_DBG
310-
wait_ms(100);
310+
ThisThread::sleep_for(100);
311311
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
312312
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
313313
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@@ -345,7 +345,7 @@ void ep_test_parallel_transfers_ctrl()
345345
// Wait for host before terminating
346346
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
347347
#if EP_DBG
348-
wait_ms(100);
348+
ThisThread::sleep_for(100);
349349
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
350350
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
351351
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@@ -381,7 +381,7 @@ void ep_test_abort()
381381
greentea_send_kv("ep_test_abort", serial.get_serial_desc_string());
382382
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
383383
#if EP_DBG
384-
wait_ms(100);
384+
ThisThread::sleep_for(100);
385385
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
386386
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
387387
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@@ -420,7 +420,7 @@ void ep_test_data_toggle()
420420
greentea_send_kv("ep_test_data_toggle", serial.get_serial_desc_string());
421421
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
422422
#if EP_DBG
423-
wait_ms(100);
423+
ThisThread::sleep_for(100);
424424
printf("cnt_cb_set_conf = %lu\r\n", serial.get_cnt_cb_set_conf());
425425
printf("cnt_cb_set_intf = %lu\r\n", serial.get_cnt_cb_set_intf());
426426
printf("cnt_cb_bulk_out = %lu\r\n", serial.get_cnt_cb_bulk_out());
@@ -566,7 +566,7 @@ void device_suspend_resume_test()
566566
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
567567
printf("[2] suspend_count: %d resume_count: %d\n", serial.get_suspend_count(), serial.get_resume_count());
568568
TEST_ASSERT_EQUAL_STRING("pass", _key);
569-
wait_ms(5000);
569+
ThisThread::sleep_for(5000);
570570
printf("[3] suspend_count: %d resume_count: %d\n", serial.get_suspend_count(), serial.get_resume_count());
571571
}
572572
}

TESTS/usb_device/msd/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ void mount_unmount_and_data_test(BlockDevice *bd, FileSystem *fs)
440440
TEST_ASSERT_EQUAL_STRING("passed", _key);
441441

442442
do {
443-
wait_ms(1);
443+
ThisThread::sleep_for(1);
444444
} while (test_files_exist(fs_root));
445445
TEST_ASSERT_EQUAL(false, test_files_exist(fs_root));
446446

0 commit comments

Comments
 (0)