Skip to content

Commit a522dcf

Browse files
committed
Replace deprecated wait calls
1 parent fc8e8f6 commit a522dcf

File tree

37 files changed

+113
-110
lines changed

37 files changed

+113
-110
lines changed

TESTS/mbed_drivers/timeout/timeout_tests.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ void test_deepsleep(void)
313313
314314
* This should be replaced with a better function that checks if the
315315
* hardware buffers are empty. However, such an API does not exist now,
316-
* so we'll use the wait_ms() function for now.
316+
* so we'll use the ThisThread::sleep_for() function for now.
317317
*/
318-
wait_ms(20);
318+
ThisThread::sleep_for(20);
319319

320320
timer.start();
321321
timeout.attach_callback(mbed::callback(sem_callback, &sem), delay_us);

TESTS/mbed_hal/rtc/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void rtc_persist_test()
125125
rtc_write(start);
126126
rtc_free();
127127

128-
wait(WAIT_TIME);
128+
ThisThread::sleep_for(WAIT_TIME * 1000);
129129

130130
rtc_init();
131131
const uint32_t stop = rtc_read();
@@ -167,7 +167,7 @@ void rtc_range_test()
167167
for (uint32_t i = 0; i < sizeof(starts) / sizeof(starts[0]); i++) {
168168
const uint32_t start = starts[i];
169169
rtc_write(start);
170-
wait(WAIT_TIME);
170+
ThisThread::sleep_for(WAIT_TIME * 1000);
171171
const uint32_t stop = rtc_read();
172172
TEST_ASSERT_UINT32_WITHIN(WAIT_TOLERANCE, WAIT_TIME, stop - start);
173173
}

TESTS/mbed_platform/error_handling/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void test_error_logging_multithread()
228228
errThread[i] = new Thread(osPriorityNormal1, THREAD_STACK_SIZE, NULL, NULL);
229229
errThread[i]->start(callback(err_thread_func, &error_status[i]));
230230
}
231-
wait(2.0);
231+
ThisThread::sleep_for(2000);
232232
for (i = 0; i < NUM_TEST_THREADS; i++) {
233233
errThread[i]->join();
234234
}

TESTS/netsocket/dns/asynchronous_dns_cancel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ void ASYNCHRONOUS_DNS_CANCEL()
8181

8282
delete[] data;
8383

84-
wait(5.0);
84+
ThisThread::sleep_for(5000);
8585
}

TESTS/netsocket/dns/asynchronous_dns_external_event_queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE()
7979
TEST_ASSERT_EQUAL(0, result_exp_timeout);
8080

8181
// Give event queue time to finalise before destructors
82-
wait(2.0);
82+
ThisThread::sleep_for(2000);
8383

8484
nsapi_dns_call_in_set(0);
8585
}

TESTS/netsocket/dns/asynchronous_dns_timeouts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void ASYNCHRONOUS_DNS_TIMEOUTS()
7474
TEST_ASSERT(result_exp_timeout > 0);
7575

7676
// Give event queue time to finalise before destructors
77-
wait(2.0);
77+
ThisThread::sleep_for(2000);
7878

7979
nsapi_dns_call_in_set(0);
8080
}

TESTS/netsocket/udp/udpsocket_echotest_burst.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void UDPSOCKET_ECHOTEST_BURST()
110110
} else if (recvd < 0) {
111111
pkg_fail += BURST_PKTS - j; // Assume all the following packets of the burst to be lost
112112
printf("[%02d] network error %d\n", i, recvd);
113-
wait(recv_timeout);
113+
ThisThread::sleep_for(recv_timeout * 1000);
114114
recv_timeout *= 2; // Back off,
115115
break;
116116
} else if (temp_addr != udp_addr) {

TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void UDPSOCKET_SENDTO_REPEAT()
4545
break;
4646
}
4747
oom_earlier = true;
48-
wait(1);
48+
ThisThread::sleep_for(1000);
4949
continue;
5050
}
5151
oom_earlier = false;

TESTS/network/interface/networkinterface_status.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void NETWORKINTERFACE_STATUS_GET()
153153
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
154154

155155
while (net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) {
156-
wait(0.5);
156+
ThisThread::sleep_for(500);
157157
}
158158

159159
err = net->disconnect();

TEST_APPS/device/socket_app/cmd_socket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ static void bg_traffic_thread(SInfo *info)
944944
tr_err("Background sent: \"%s\"", sbuffer);
945945
tr_err("Background received: \"%s\"", rbuffer);
946946
}
947-
wait_ms(10);
947+
ThisThread::sleep_for(10);
948948
}
949949
}
950950

components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,14 @@ static void rf_if_reset_radio(void)
525525
#endif
526526
rf->IRQ.rise(0);
527527
rf->RST = 1;
528-
wait_ms(1);
528+
ThisThread::sleep_for(2);
529529
rf->RST = 0;
530-
wait_ms(10);
530+
ThisThread::sleep_for(10);
531531
CS_RELEASE();
532532
rf->SLP_TR = 0;
533-
wait_ms(10);
533+
ThisThread::sleep_for(10);
534534
rf->RST = 1;
535-
wait_ms(10);
535+
ThisThread::sleep_for(10);
536536

537537
rf->IRQ.rise(&rf_if_interrupt_handler);
538538
}
@@ -883,15 +883,16 @@ static uint8_t rf_if_read_rnd(void)
883883
rf_if_write_register(TRX_RPC, RX_RPC_CTRL | TRX_RPC_RSVD_1);
884884
}
885885

886-
wait_ms(1);
886+
887+
wait_ns(1000);
887888
temp = ((rf_if_read_register(PHY_RSSI) >> 5) << 6);
888-
wait_ms(1);
889+
wait_ns(1000);
889890
temp |= ((rf_if_read_register(PHY_RSSI) >> 5) << 4);
890-
wait_ms(1);
891+
wait_ns(1000);
891892
temp |= ((rf_if_read_register(PHY_RSSI) >> 5) << 2);
892-
wait_ms(1);
893+
wait_ns(1000);
893894
temp |= ((rf_if_read_register(PHY_RSSI) >> 5));
894-
wait_ms(1);
895+
wait_ns(1000);
895896
if (rf_part_num == PART_AT86RF233) {
896897
rf_if_write_register(TRX_RPC, tmp_rpc_val);
897898
}

components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,10 +1083,10 @@ static void rf_reset(void)
10831083
{
10841084
// Shutdown
10851085
rf->SDN = 1;
1086-
wait_ms(10);
1086+
ThisThread::sleep_for(10);
10871087
// Wake up
10881088
rf->SDN = 0;
1089-
wait_ms(10);
1089+
ThisThread::sleep_for(10);
10901090
}
10911091

10921092
static void rf_init(void)

components/cellular/COMPONENT_STMOD_CELLULAR/STModCellular.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
#include "STModCellular.h"
19-
#include "mbed_wait_api.h"
19+
#include "rtos/ThisThread.h"
2020
#include "mbed_trace.h"
2121

2222
#define TRACE_GROUP "CELL"
@@ -38,14 +38,14 @@ STModCellular::STModCellular(FileHandle *fh) : STMOD_CELLULAR_MODEM(fh),
3838
// start with modem disabled
3939
m_powerkey.write(0);
4040
m_reset.write(1);
41-
wait_ms(200);
41+
rtos::ThisThread::sleep_for(200);
4242
m_reset.write(0);
43-
wait_ms(150);
43+
rtos::ThisThread::sleep_for(150);
4444

45-
wait_ms(50);
45+
rtos::ThisThread::sleep_for(50);
4646
m_simsel0.write(MBED_CONF_STMOD_CELLULAR_SIM_SELECTION & 0x01);
4747
m_simsel1.write(MBED_CONF_STMOD_CELLULAR_SIM_SELECTION & 0x02);
48-
wait_ms(50);
48+
rtos::ThisThread::sleep_for(50);
4949
}
5050

5151
STModCellular::~STModCellular()
@@ -59,28 +59,28 @@ nsapi_error_t STModCellular::soft_power_on()
5959
#if (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_UG96)
6060
tr_debug("Booting UG96\r\n");
6161
m_reset.write(1);
62-
wait_ms(200);
62+
rtos::ThisThread::sleep_for(200);
6363
m_reset.write(0);
64-
wait_ms(150);
64+
rtos::ThisThread::sleep_for(150);
6565
m_powerkey.write(1);
66-
wait_ms(150);
66+
rtos::ThisThread::sleep_for(150);
6767
m_powerkey.write(0);
6868
/* Because modem status is not available on STMOD+ connector,
6969
* let's wait for Modem complete boot */
70-
wait_ms(2300);
70+
rtos::ThisThread::sleep_for(2300);
7171
#endif
7272
#if (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_BG96)
7373
tr_debug("Booting BG96\r\n");
7474
m_powerkey.write(1);
7575
m_reset.write(1);
76-
wait_ms(150);
76+
rtos::ThisThread::sleep_for(150);
7777
m_powerkey.write(0);
7878
m_reset.write(0);
79-
wait_ms(100);
79+
rtos::ThisThread::sleep_for(100);
8080
m_powerkey.write(1);
81-
wait_ms(200);
81+
rtos::ThisThread::sleep_for(200);
8282
m_powerkey.write(0);
83-
wait_ms(5000);
83+
rtos::ThisThread::sleep_for(5000);
8484
#endif
8585

8686
nsapi_error_t err = STMOD_CELLULAR_MODEM::soft_power_on();
@@ -133,7 +133,7 @@ nsapi_error_t STModCellular::soft_power_on()
133133
}
134134
#endif
135135

136-
wait_ms(500);
136+
rtos::ThisThread::sleep_for(500);
137137

138138
#if MBED_CONF_CELLULAR_DEBUG_AT
139139
_at->lock();
@@ -150,7 +150,7 @@ nsapi_error_t STModCellular::soft_power_off()
150150
{
151151
_at->cmd_start("AT+QPOWD");
152152
_at->cmd_stop();
153-
wait_ms(1000);
153+
rtos::ThisThread::sleep_for(1000);
154154
// should wait for POWERED DOWN with a time out up to 65 second according to the manual.
155155
// we cannot afford such a long wait though.
156156
return STMOD_CELLULAR_MODEM::soft_power_off();

components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@ int DataFlashBlockDevice::_sync(void)
661661
break;
662662
/* wait the typical write period before trying again */
663663
} else {
664-
DEBUG_PRINTF("wait_ms: %d\r\n", DATAFLASH_TIMING_ERASE_PROGRAM_PAGE);
665-
wait_ms(DATAFLASH_TIMING_ERASE_PROGRAM_PAGE);
664+
DEBUG_PRINTF("sleep_for: %d\r\n", DATAFLASH_TIMING_ERASE_PROGRAM_PAGE);
665+
rtos::ThisThread::sleep_for(DATAFLASH_TIMING_ERASE_PROGRAM_PAGE);
666666
}
667667
}
668668

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "QSPIFBlockDevice.h"
1818
#include <string.h>
19-
#include "mbed_wait_api.h"
19+
#include "rtos/ThisThread.h"
2020

2121
#ifndef MBED_CONF_MBED_TRACE_ENABLE
2222
#define MBED_CONF_MBED_TRACE_ENABLE 0
@@ -1146,7 +1146,7 @@ bool QSPIFBlockDevice::_is_mem_ready()
11461146
bool mem_ready = true;
11471147

11481148
do {
1149-
wait_ms(1);
1149+
rtos::ThisThread::sleep_for(1);
11501150
retries++;
11511151
//Read the Status Register from device
11521152
memset(status_value, 0xFF, QSPI_MAX_STATUS_REGISTER_SIZE);

components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
#include "SPIFReducedBlockDevice.h"
18-
#include "mbed_wait_api.h"
18+
#include "rtos/ThisThread.h"
1919

2020
using namespace mbed;
2121

@@ -224,7 +224,7 @@ int SPIFReducedBlockDevice::_sync()
224224
return 0;
225225
}
226226

227-
wait_ms(1);
227+
rtos::ThisThread::sleep_for(1);
228228
}
229229

230230
return BD_ERROR_DEVICE_ERROR;
@@ -244,7 +244,7 @@ int SPIFReducedBlockDevice::_wren()
244244
return 0;
245245
}
246246

247-
wait_ms(1);
247+
rtos::ThisThread::sleep_for(1);
248248
}
249249

250250
return BD_ERROR_DEVICE_ERROR;
@@ -278,7 +278,7 @@ int SPIFReducedBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_
278278
addr += chunk;
279279
size -= chunk;
280280

281-
wait_ms(1);
281+
rtos::ThisThread::sleep_for(1);
282282

283283
err = _sync();
284284
if (err) {

components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@
139139
#if DEVICE_SPI
140140

141141
#include "SDBlockDevice.h"
142+
#include "rtos/ThisThread.h"
142143
#include "platform/mbed_debug.h"
143-
#include "platform/mbed_wait_api.h"
144144
#ifndef __STDC_FORMAT_MACROS
145145
#define __STDC_FORMAT_MACROS
146146
#endif
@@ -872,7 +872,7 @@ uint32_t SDBlockDevice::_go_idle_state()
872872
if (R1_IDLE_STATE == response) {
873873
break;
874874
}
875-
wait_ms(1);
875+
rtos::ThisThread::sleep_for(1);
876876
}
877877
return response;
878878
}

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/MbedTester.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "MbedTester.h"
1919
#include "fpga_config.h"
2020
#include "BlockDevice.h"
21+
#include "rtos/ThisThread.h"
2122
#include "platform/mbed_wait_api.h"
2223
#include "platform/mbed_error.h"
2324
#include "drivers/MbedCRC.h"
@@ -1733,7 +1734,7 @@ uint8_t MbedTester::get_pwm_cycles_high()
17331734

17341735
uint16_t MbedTester::get_analogmuxin_measurement()
17351736
{
1736-
wait_ms(1);//wait for value to stabalize
1737+
rtos::ThisThread::sleep_for(1);//wait for value to stabalize
17371738
//take snapshot of conversion value to make safe for reading
17381739
set_snapshot();
17391740
uint16_t an_mux_analogin_measurement = 0;

components/wifi/esp8266-driver/ESP8266Interface.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "platform/Callback.h"
2929
#include "platform/mbed_atomic.h"
3030
#include "platform/mbed_debug.h"
31-
#include "platform/mbed_wait_api.h"
31+
#include "rtos/ThisThread.h"
3232

3333
#ifndef MBED_CONF_ESP8266_DEBUG
3434
#define MBED_CONF_ESP8266_DEBUG false
@@ -49,6 +49,7 @@
4949
#define TRACE_GROUP "ESPI" // ESP8266 Interface
5050

5151
using namespace mbed;
52+
using namespace rtos;
5253

5354
#if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX
5455
ESP8266Interface::ESP8266Interface()
@@ -459,7 +460,7 @@ nsapi_error_t ESP8266Interface::_reset()
459460
_rst_pin.rst_assert();
460461
// If you happen to use Pin7 CH_EN as reset pin, not needed otherwise
461462
// https://www.espressif.com/sites/default/files/documentation/esp8266_hardware_design_guidelines_en.pdf
462-
wait_ms(2); // Documentation says 200 us should have been enough, but experimentation shows that 1ms was not enough
463+
ThisThread::sleep_for(2); // Documentation says 200 us; need 2 ticks to get minimum 1 ms.
463464
_esp.flush();
464465
_rst_pin.rst_deassert();
465466
} else {

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
2525
#include "UARTSerial.h"
2626
#endif // #if DEVICE_SERIAL
27-
#include "mbed_wait_api.h"
27+
#include "ThisThread.h"
2828

2929
#define NETWORK_TIMEOUT 30 * 60 * 1000 // 30 minutes
3030
#define DEVICE_TIMEOUT 5 * 60 * 1000 // 5 minutes
@@ -45,6 +45,7 @@
4545

4646
using namespace mbed_cellular_util;
4747
using namespace mbed;
48+
using namespace rtos;
4849

4950
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, bool cp_req, bool nonip_req) :
5051
AT_CellularBase(at), _is_connected(false), _current_op(OP_INVALID), _fh(0), _cp_req(cp_req),
@@ -891,7 +892,7 @@ void AT_CellularContext::cellular_callback(nsapi_event_t ev, intptr_t ptr)
891892
_cb_data.error == NSAPI_ERROR_OK) {
892893
if (!_apn) {
893894
char imsi[MAX_IMSI_LENGTH + 1];
894-
wait(1); // need to wait to access SIM in some modems
895+
ThisThread::sleep_for(1000); // need to wait to access SIM in some modems
895896
_cb_data.error = _device->open_information()->get_imsi(imsi, sizeof(imsi));
896897
if (_cb_data.error == NSAPI_ERROR_OK) {
897898
const char *apn_config = apnconfig(imsi);

0 commit comments

Comments
 (0)