diff --git a/TESTS/mbed_drivers/timeout/timeout_tests.h b/TESTS/mbed_drivers/timeout/timeout_tests.h index fd71cb6a1b..534901c1fb 100644 --- a/TESTS/mbed_drivers/timeout/timeout_tests.h +++ b/TESTS/mbed_drivers/timeout/timeout_tests.h @@ -313,9 +313,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(20); + ThisThread::sleep_for(20); timer.start(); timeout.attach_callback(mbed::callback(sem_callback, &sem), delay_us); diff --git a/TESTS/mbed_hal/rtc/main.cpp b/TESTS/mbed_hal/rtc/main.cpp index bd65e38cd4..f56383dcb1 100644 --- a/TESTS/mbed_hal/rtc/main.cpp +++ b/TESTS/mbed_hal/rtc/main.cpp @@ -125,7 +125,7 @@ void rtc_persist_test() rtc_write(start); rtc_free(); - wait(WAIT_TIME); + ThisThread::sleep_for(WAIT_TIME * 1000); rtc_init(); const uint32_t stop = rtc_read(); @@ -167,7 +167,7 @@ void rtc_range_test() for (uint32_t i = 0; i < sizeof(starts) / sizeof(starts[0]); i++) { const uint32_t start = starts[i]; rtc_write(start); - wait(WAIT_TIME); + ThisThread::sleep_for(WAIT_TIME * 1000); const uint32_t stop = rtc_read(); TEST_ASSERT_UINT32_WITHIN(WAIT_TOLERANCE, WAIT_TIME, stop - start); } diff --git a/TESTS/mbed_platform/error_handling/main.cpp b/TESTS/mbed_platform/error_handling/main.cpp index a72c56bb25..f961edbf76 100644 --- a/TESTS/mbed_platform/error_handling/main.cpp +++ b/TESTS/mbed_platform/error_handling/main.cpp @@ -228,7 +228,7 @@ void test_error_logging_multithread() errThread[i] = new Thread(osPriorityNormal1, THREAD_STACK_SIZE, NULL, NULL); errThread[i]->start(callback(err_thread_func, &error_status[i])); } - wait(2.0); + ThisThread::sleep_for(2000); for (i = 0; i < NUM_TEST_THREADS; i++) { errThread[i]->join(); } diff --git a/TESTS/netsocket/dns/asynchronous_dns_cancel.cpp b/TESTS/netsocket/dns/asynchronous_dns_cancel.cpp index 28e75879d6..1f9c6f8436 100644 --- a/TESTS/netsocket/dns/asynchronous_dns_cancel.cpp +++ b/TESTS/netsocket/dns/asynchronous_dns_cancel.cpp @@ -81,5 +81,5 @@ void ASYNCHRONOUS_DNS_CANCEL() delete[] data; - wait(5.0); + ThisThread::sleep_for(5000); } diff --git a/TESTS/netsocket/dns/asynchronous_dns_external_event_queue.cpp b/TESTS/netsocket/dns/asynchronous_dns_external_event_queue.cpp index 2a2493a76d..41685a1ea6 100644 --- a/TESTS/netsocket/dns/asynchronous_dns_external_event_queue.cpp +++ b/TESTS/netsocket/dns/asynchronous_dns_external_event_queue.cpp @@ -79,7 +79,7 @@ void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE() TEST_ASSERT_EQUAL(0, result_exp_timeout); // Give event queue time to finalise before destructors - wait(2.0); + ThisThread::sleep_for(2000); nsapi_dns_call_in_set(0); } diff --git a/TESTS/netsocket/dns/asynchronous_dns_timeouts.cpp b/TESTS/netsocket/dns/asynchronous_dns_timeouts.cpp index 30b1ef537a..a22fb2fcf9 100644 --- a/TESTS/netsocket/dns/asynchronous_dns_timeouts.cpp +++ b/TESTS/netsocket/dns/asynchronous_dns_timeouts.cpp @@ -74,7 +74,7 @@ void ASYNCHRONOUS_DNS_TIMEOUTS() TEST_ASSERT(result_exp_timeout > 0); // Give event queue time to finalise before destructors - wait(2.0); + ThisThread::sleep_for(2000); nsapi_dns_call_in_set(0); } diff --git a/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp b/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp index aee4d74854..fc5bb14d28 100644 --- a/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp +++ b/TESTS/netsocket/udp/udpsocket_echotest_burst.cpp @@ -110,7 +110,7 @@ void UDPSOCKET_ECHOTEST_BURST() } else if (recvd < 0) { pkg_fail += BURST_PKTS - j; // Assume all the following packets of the burst to be lost printf("[%02d] network error %d\n", i, recvd); - wait(recv_timeout); + ThisThread::sleep_for(recv_timeout * 1000); recv_timeout *= 2; // Back off, break; } else if (temp_addr != udp_addr) { diff --git a/TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp b/TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp index 3983c97b0d..bd716e12ca 100644 --- a/TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp +++ b/TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp @@ -45,7 +45,7 @@ void UDPSOCKET_SENDTO_REPEAT() break; } oom_earlier = true; - wait(1); + ThisThread::sleep_for(1000); continue; } oom_earlier = false; diff --git a/TESTS/network/interface/networkinterface_status.cpp b/TESTS/network/interface/networkinterface_status.cpp index fbff8c551d..f4ebe5d9ad 100644 --- a/TESTS/network/interface/networkinterface_status.cpp +++ b/TESTS/network/interface/networkinterface_status.cpp @@ -153,7 +153,7 @@ void NETWORKINTERFACE_STATUS_GET() TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err); while (net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) { - wait(0.5); + ThisThread::sleep_for(500); } err = net->disconnect(); diff --git a/TEST_APPS/device/socket_app/cmd_socket.cpp b/TEST_APPS/device/socket_app/cmd_socket.cpp index d07c4e8f00..454bab8fa2 100644 --- a/TEST_APPS/device/socket_app/cmd_socket.cpp +++ b/TEST_APPS/device/socket_app/cmd_socket.cpp @@ -944,7 +944,7 @@ static void bg_traffic_thread(SInfo *info) tr_err("Background sent: \"%s\"", sbuffer); tr_err("Background received: \"%s\"", rbuffer); } - wait_ms(10); + ThisThread::sleep_for(10); } } diff --git a/components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp b/components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp index ff6bc0cc10..287d5023de 100644 --- a/components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp +++ b/components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp @@ -525,14 +525,14 @@ static void rf_if_reset_radio(void) #endif rf->IRQ.rise(0); rf->RST = 1; - wait_ms(1); + ThisThread::sleep_for(2); rf->RST = 0; - wait_ms(10); + ThisThread::sleep_for(10); CS_RELEASE(); rf->SLP_TR = 0; - wait_ms(10); + ThisThread::sleep_for(10); rf->RST = 1; - wait_ms(10); + ThisThread::sleep_for(10); rf->IRQ.rise(&rf_if_interrupt_handler); } @@ -883,15 +883,16 @@ static uint8_t rf_if_read_rnd(void) rf_if_write_register(TRX_RPC, RX_RPC_CTRL | TRX_RPC_RSVD_1); } - wait_ms(1); + + wait_ns(1000); temp = ((rf_if_read_register(PHY_RSSI) >> 5) << 6); - wait_ms(1); + wait_ns(1000); temp |= ((rf_if_read_register(PHY_RSSI) >> 5) << 4); - wait_ms(1); + wait_ns(1000); temp |= ((rf_if_read_register(PHY_RSSI) >> 5) << 2); - wait_ms(1); + wait_ns(1000); temp |= ((rf_if_read_register(PHY_RSSI) >> 5)); - wait_ms(1); + wait_ns(1000); if (rf_part_num == PART_AT86RF233) { rf_if_write_register(TRX_RPC, tmp_rpc_val); } diff --git a/components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp b/components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp index 1d88ba052c..435df3e4ae 100644 --- a/components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp +++ b/components/802.15.4_RF/stm-s2lp-rf-driver/source/NanostackRfPhys2lp.cpp @@ -1083,10 +1083,10 @@ static void rf_reset(void) { // Shutdown rf->SDN = 1; - wait_ms(10); + ThisThread::sleep_for(10); // Wake up rf->SDN = 0; - wait_ms(10); + ThisThread::sleep_for(10); } static void rf_init(void) diff --git a/components/cellular/COMPONENT_STMOD_CELLULAR/STModCellular.cpp b/components/cellular/COMPONENT_STMOD_CELLULAR/STModCellular.cpp index 3cb9525f3e..8e5c39caf4 100644 --- a/components/cellular/COMPONENT_STMOD_CELLULAR/STModCellular.cpp +++ b/components/cellular/COMPONENT_STMOD_CELLULAR/STModCellular.cpp @@ -16,7 +16,7 @@ */ #include "STModCellular.h" -#include "mbed_wait_api.h" +#include "rtos/ThisThread.h" #include "mbed_trace.h" #define TRACE_GROUP "CELL" @@ -38,14 +38,14 @@ STModCellular::STModCellular(FileHandle *fh) : STMOD_CELLULAR_MODEM(fh), // start with modem disabled m_powerkey.write(0); m_reset.write(1); - wait_ms(200); + rtos::ThisThread::sleep_for(200); m_reset.write(0); - wait_ms(150); + rtos::ThisThread::sleep_for(150); - wait_ms(50); + rtos::ThisThread::sleep_for(50); m_simsel0.write(MBED_CONF_STMOD_CELLULAR_SIM_SELECTION & 0x01); m_simsel1.write(MBED_CONF_STMOD_CELLULAR_SIM_SELECTION & 0x02); - wait_ms(50); + rtos::ThisThread::sleep_for(50); } STModCellular::~STModCellular() @@ -59,28 +59,28 @@ nsapi_error_t STModCellular::soft_power_on() #if (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_UG96) tr_debug("Booting UG96\r\n"); m_reset.write(1); - wait_ms(200); + rtos::ThisThread::sleep_for(200); m_reset.write(0); - wait_ms(150); + rtos::ThisThread::sleep_for(150); m_powerkey.write(1); - wait_ms(150); + rtos::ThisThread::sleep_for(150); m_powerkey.write(0); /* Because modem status is not available on STMOD+ connector, * let's wait for Modem complete boot */ - wait_ms(2300); + rtos::ThisThread::sleep_for(2300); #endif #if (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_BG96) tr_debug("Booting BG96\r\n"); m_powerkey.write(1); m_reset.write(1); - wait_ms(150); + rtos::ThisThread::sleep_for(150); m_powerkey.write(0); m_reset.write(0); - wait_ms(100); + rtos::ThisThread::sleep_for(100); m_powerkey.write(1); - wait_ms(200); + rtos::ThisThread::sleep_for(200); m_powerkey.write(0); - wait_ms(5000); + rtos::ThisThread::sleep_for(5000); #endif nsapi_error_t err = STMOD_CELLULAR_MODEM::soft_power_on(); @@ -133,7 +133,7 @@ nsapi_error_t STModCellular::soft_power_on() } #endif - wait_ms(500); + rtos::ThisThread::sleep_for(500); #if MBED_CONF_CELLULAR_DEBUG_AT _at->lock(); @@ -150,7 +150,7 @@ nsapi_error_t STModCellular::soft_power_off() { _at->cmd_start("AT+QPOWD"); _at->cmd_stop(); - wait_ms(1000); + rtos::ThisThread::sleep_for(1000); // should wait for POWERED DOWN with a time out up to 65 second according to the manual. // we cannot afford such a long wait though. return STMOD_CELLULAR_MODEM::soft_power_off(); diff --git a/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp index 281b9f8436..4309233fcf 100644 --- a/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp @@ -661,8 +661,8 @@ int DataFlashBlockDevice::_sync(void) break; /* wait the typical write period before trying again */ } else { - DEBUG_PRINTF("wait_ms: %d\r\n", DATAFLASH_TIMING_ERASE_PROGRAM_PAGE); - wait_ms(DATAFLASH_TIMING_ERASE_PROGRAM_PAGE); + DEBUG_PRINTF("sleep_for: %d\r\n", DATAFLASH_TIMING_ERASE_PROGRAM_PAGE); + rtos::ThisThread::sleep_for(DATAFLASH_TIMING_ERASE_PROGRAM_PAGE); } } diff --git a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp index e37c4b275b..7010b22cfb 100644 --- a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp @@ -16,7 +16,7 @@ #include "QSPIFBlockDevice.h" #include -#include "mbed_wait_api.h" +#include "rtos/ThisThread.h" #ifndef MBED_CONF_MBED_TRACE_ENABLE #define MBED_CONF_MBED_TRACE_ENABLE 0 @@ -1146,7 +1146,7 @@ bool QSPIFBlockDevice::_is_mem_ready() bool mem_ready = true; do { - wait_ms(1); + rtos::ThisThread::sleep_for(1); retries++; //Read the Status Register from device memset(status_value, 0xFF, QSPI_MAX_STATUS_REGISTER_SIZE); diff --git a/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.cpp index 2092f58e1e..721965dc30 100644 --- a/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ #include "SPIFReducedBlockDevice.h" -#include "mbed_wait_api.h" +#include "rtos/ThisThread.h" using namespace mbed; @@ -224,7 +224,7 @@ int SPIFReducedBlockDevice::_sync() return 0; } - wait_ms(1); + rtos::ThisThread::sleep_for(1); } return BD_ERROR_DEVICE_ERROR; @@ -244,7 +244,7 @@ int SPIFReducedBlockDevice::_wren() return 0; } - wait_ms(1); + rtos::ThisThread::sleep_for(1); } return BD_ERROR_DEVICE_ERROR; @@ -278,7 +278,7 @@ int SPIFReducedBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_ addr += chunk; size -= chunk; - wait_ms(1); + rtos::ThisThread::sleep_for(1); err = _sync(); if (err) { diff --git a/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp index f4c73a7d35..769fcfbbe3 100644 --- a/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp @@ -139,8 +139,8 @@ #if DEVICE_SPI #include "SDBlockDevice.h" +#include "rtos/ThisThread.h" #include "platform/mbed_debug.h" -#include "platform/mbed_wait_api.h" #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif @@ -872,7 +872,7 @@ uint32_t SDBlockDevice::_go_idle_state() if (R1_IDLE_STATE == response) { break; } - wait_ms(1); + rtos::ThisThread::sleep_for(1); } return response; } diff --git a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/MbedTester.cpp b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/MbedTester.cpp index fe7d4c8089..d9c51ad932 100644 --- a/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/MbedTester.cpp +++ b/components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/MbedTester.cpp @@ -18,6 +18,7 @@ #include "MbedTester.h" #include "fpga_config.h" #include "BlockDevice.h" +#include "rtos/ThisThread.h" #include "platform/mbed_wait_api.h" #include "platform/mbed_error.h" #include "drivers/MbedCRC.h" @@ -1733,7 +1734,7 @@ uint8_t MbedTester::get_pwm_cycles_high() uint16_t MbedTester::get_analogmuxin_measurement() { - wait_ms(1);//wait for value to stabalize + rtos::ThisThread::sleep_for(1);//wait for value to stabalize //take snapshot of conversion value to make safe for reading set_snapshot(); uint16_t an_mux_analogin_measurement = 0; diff --git a/components/wifi/esp8266-driver/ESP8266Interface.cpp b/components/wifi/esp8266-driver/ESP8266Interface.cpp index 6afa89dc54..7bb5ce7d76 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.cpp +++ b/components/wifi/esp8266-driver/ESP8266Interface.cpp @@ -28,7 +28,7 @@ #include "platform/Callback.h" #include "platform/mbed_atomic.h" #include "platform/mbed_debug.h" -#include "platform/mbed_wait_api.h" +#include "rtos/ThisThread.h" #ifndef MBED_CONF_ESP8266_DEBUG #define MBED_CONF_ESP8266_DEBUG false @@ -49,6 +49,7 @@ #define TRACE_GROUP "ESPI" // ESP8266 Interface using namespace mbed; +using namespace rtos; #if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX ESP8266Interface::ESP8266Interface() @@ -459,7 +460,7 @@ nsapi_error_t ESP8266Interface::_reset() _rst_pin.rst_assert(); // If you happen to use Pin7 CH_EN as reset pin, not needed otherwise // https://www.espressif.com/sites/default/files/documentation/esp8266_hardware_design_guidelines_en.pdf - wait_ms(2); // Documentation says 200 us should have been enough, but experimentation shows that 1ms was not enough + ThisThread::sleep_for(2); // Documentation says 200 us; need 2 ticks to get minimum 1 ms. _esp.flush(); _rst_pin.rst_deassert(); } else { diff --git a/features/cellular/framework/AT/AT_CellularContext.cpp b/features/cellular/framework/AT/AT_CellularContext.cpp index e39bbada6d..51f7f7ecb5 100644 --- a/features/cellular/framework/AT/AT_CellularContext.cpp +++ b/features/cellular/framework/AT/AT_CellularContext.cpp @@ -24,7 +24,7 @@ #if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #include "UARTSerial.h" #endif // #if DEVICE_SERIAL -#include "mbed_wait_api.h" +#include "ThisThread.h" #define NETWORK_TIMEOUT 30 * 60 * 1000 // 30 minutes #define DEVICE_TIMEOUT 5 * 60 * 1000 // 5 minutes @@ -45,6 +45,7 @@ using namespace mbed_cellular_util; using namespace mbed; +using namespace rtos; AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, bool cp_req, bool nonip_req) : 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) _cb_data.error == NSAPI_ERROR_OK) { if (!_apn) { char imsi[MAX_IMSI_LENGTH + 1]; - wait(1); // need to wait to access SIM in some modems + ThisThread::sleep_for(1000); // need to wait to access SIM in some modems _cb_data.error = _device->open_information()->get_imsi(imsi, sizeof(imsi)); if (_cb_data.error == NSAPI_ERROR_OK) { const char *apn_config = apnconfig(imsi); diff --git a/features/cellular/framework/AT/AT_CellularSMS.cpp b/features/cellular/framework/AT/AT_CellularSMS.cpp index aae8ab57de..b0b0187982 100644 --- a/features/cellular/framework/AT/AT_CellularSMS.cpp +++ b/features/cellular/framework/AT/AT_CellularSMS.cpp @@ -18,7 +18,7 @@ #include #include #include -#include "mbed_wait_api.h" +#include "ThisThread.h" #include "AT_CellularSMS.h" #include "CellularUtil.h" #include "CellularLog.h" @@ -26,6 +26,7 @@ using namespace mbed_cellular_util; using namespace mbed; using namespace std; +using namespace rtos; #define CTRL_Z "\x1a" #define ESC "\x1b" @@ -406,12 +407,12 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c int write_size = 0; int remove_plus_sign = (phone_number[0] == '+') ? 1 : 0; - wait_ms(_sim_wait_time); + ThisThread::sleep_for(_sim_wait_time); if (_mode == CellularSMSMmodeText) { _at.cmd_start_stop("+CMGS", "=", "%s", phone_number + remove_plus_sign); - wait_ms(_sim_wait_time); + ThisThread::sleep_for(_sim_wait_time); _at.resp_start("> ", true); if (_at.get_last_error() == NSAPI_ERROR_OK) { @@ -474,7 +475,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c _at.cmd_start_stop("+CMGS", "=", "%d", (pdu_len - 2) / 2); - wait_ms(_sim_wait_time); + ThisThread::sleep_for(_sim_wait_time); _at.resp_start("> ", true); if (_at.get_last_error() == NSAPI_ERROR_OK) { @@ -564,7 +565,7 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char *b /* * +CMGR: ,,,[,,,,,,,]OK */ - wait_ms(_sim_wait_time); + ThisThread::sleep_for(_sim_wait_time); _at.cmd_start_stop("+CMGR", "=", "%d", msg_index); // TODO: NOTE: If the selected can contain different types of SMs (e.g. SMS-DELIVERs, SMS-SUBMITs, SMS-STATUS-REPORTs and SMS-COMMANDs), @@ -621,7 +622,7 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t *sms, char *buf, char int pduSize; for (int i = 0; i < sms->parts; i++) { - wait_ms(_sim_wait_time); + ThisThread::sleep_for(_sim_wait_time); _at.cmd_start_stop("+CMGR", "=", "%d", sms->msg_index[i]); _at.resp_start("+CMGR:"); @@ -744,7 +745,7 @@ nsapi_size_or_error_t AT_CellularSMS::get_data_from_pdu(const char *pdu, sms_inf // read first the lower part of first octet as there is message type index++; tmp = hex_str_to_int(pdu + index, 1); - //wait_ms(200); + //ThisThread::sleep_for(200); if ((tmp & 0x03) == 0) {// SMS-DELIVER type, last two bits should be zero // UDH present? Check from first octets higher part tmp = hex_str_to_int(pdu + (--index), 1); @@ -1071,7 +1072,7 @@ AT_CellularSMS::sms_info_t *AT_CellularSMS::get_oldest_sms_index() nsapi_size_or_error_t err = 0; while (current) { if (_mode == CellularSMSMmodeText) { - wait_ms(_sim_wait_time); + ThisThread::sleep_for(_sim_wait_time); err = read_sms_from_index(current->msg_index[0], NULL, 0, NULL, current->date); if (err != 0) { return NULL; diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp index 32448fcf70..c2498e3d23 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp @@ -211,7 +211,7 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn, if (activated) { //If context is activated, exit while loop and return status break; } - wait_ms(5000); //Wait for 5 seconds and then try again + rtos::ThisThread::sleep_for(5000); //Wait for 5 seconds and then try again } t1.stop(); } diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.h b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.h index 3638559670..e7da23100b 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.h +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.h @@ -19,7 +19,7 @@ #include "AT_CellularStack.h" #include "CellularUtil.h" -#include "mbed_wait_api.h" +#include "rtos/ThisThread.h" #include "drivers/Timer.h" diff --git a/features/storage/nvstore/source/nvstore.cpp b/features/storage/nvstore/source/nvstore.cpp index 2e14109df3..5dc20fbb0b 100644 --- a/features/storage/nvstore/source/nvstore.cpp +++ b/features/storage/nvstore/source/nvstore.cpp @@ -25,7 +25,7 @@ #include "mbed_atomic.h" #include "mbed_assert.h" #include "mbed_error.h" -#include "mbed_wait_api.h" +#include "ThisThread.h" #include #include #include @@ -836,7 +836,7 @@ int NVStore::init() init_attempts_val = core_util_atomic_incr_u32(&_init_attempts, 1); if (init_attempts_val != 1) { while (!_init_done) { - wait_ms(1); + rtos::ThisThread::sleep_for(1); } return NVSTORE_SUCCESS; } diff --git a/rtos/RtosTimer.h b/rtos/RtosTimer.h index 168687281b..74e7c7ef86 100644 --- a/rtos/RtosTimer.h +++ b/rtos/RtosTimer.h @@ -62,7 +62,7 @@ namespace rtos { RtosTimer timer(&blink); int main() { timer.start(1000); // call blink every 1s - wait_ms(5000); + ThisThread::sleep_for(5000); timer.stop(); // stop after 5s } @endcode diff --git a/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/onboard_modem_api.c b/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/onboard_modem_api.c index 7849f78737..a4ef32a17c 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/onboard_modem_api.c +++ b/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/onboard_modem_api.c @@ -19,7 +19,7 @@ #include "cellular/onboard_modem_api.h" #include "ublox_low_level_api.h" #include "gpio_api.h" -#include "platform/mbed_wait_api.h" +#include "platform/mbed_thread.h" #include "PinNames.h" #if MODEM_ON_BOARD @@ -29,7 +29,7 @@ static void press_power_button(int time_ms) gpio_t gpio; gpio_init_out_ex(&gpio, MDMPWRON, 0); - wait_ms(time_ms); + thread_sleep_for(time_ms); gpio_write(&gpio, 1); } @@ -50,7 +50,7 @@ void onboard_modem_power_up() /* keep the power line low for 150 milisecond */ press_power_button(150); /* give modem a little time to respond */ - wait_ms(100); + thread_sleep_for(100); } void onboard_modem_power_down() diff --git a/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c b/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c index 7c623206a7..96ce54b7c3 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c +++ b/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c @@ -16,6 +16,7 @@ #include #include "hal/us_ticker_api.h" #include "platform/mbed_wait_api.h" +#include "platform/mbed_thread.h" #include "gpio_api.h" #include "ublox_low_level_api.h" @@ -39,12 +40,10 @@ void ublox_mdm_init(void) // led should be off gpio_init_out_ex(&gpio, LED, 0); - // Can't use wait_ms() as RTOS isn't initialised yet - //wait_ms(50); // when USB cable is inserted the interface chip issues + // Can't use thread_sleep_for() as RTOS isn't initialised yet + //thread_sleep_for(50); // when USB cable is inserted the interface chip issues // Here's the code from the non-RTOS version - us_ticker_init(); - uint32_t start = us_ticker_read(); - while ((us_ticker_read() - start) < 50000); + wait_us(50000); } // For forwards compatibility @@ -61,7 +60,7 @@ void ublox_mdm_powerOn(int usb) if (!modemOn) { // enable modem modemOn = true; gpio_init_out_ex(&gpio, MDMEN, 1); // LDOEN: 1=on - wait_ms(1); // wait until supply switched off + thread_sleep_for(1); // wait until supply switched off // now we can safely enable the level shifters gpio_init_out_ex(&gpio, MDMLVLOE, 0); // LVLEN: 0=enabled (uart/gpio) if (gpsOn) { @@ -97,7 +96,7 @@ void ublox_gps_powerOn(void) gpsOn = true; // switch on power supply gpio_init_out_ex(&gpio, GPSEN, 1); // LDOEN: 1=on - wait_ms(1); // wait until supply switched off + thread_sleep_for(1); // wait until supply switched off if (modemOn) { gpio_init_out_ex(&gpio, MDMILVLOE, 1); // ILVLEN: 1=enabled (i2c) } diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp b/targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp index 2ec69ccdbe..c3474191d5 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp +++ b/targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp @@ -19,7 +19,6 @@ #include #include "mbed_assert.h" #include "mbed_events.h" -#include "mbed_wait_api.h" #include "rtw_emac.h" #include "EMACMemoryManager.h" @@ -123,7 +122,7 @@ bool RTW_EMAC::link_out(emac_mem_buf_t *buf) bool RTW_EMAC::power_up() { wifi_on(RTW_MODE_STA); - wait_ms(1000); + rtos::ThisThread::sleep_for(1000); wlan_emac_link_change(true); return true; } diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTB_MTS_DRAGONFLY/onboard_modem_api.c b/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTB_MTS_DRAGONFLY/onboard_modem_api.c index 82e623e28e..a7e359d0ca 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTB_MTS_DRAGONFLY/onboard_modem_api.c +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTB_MTS_DRAGONFLY/onboard_modem_api.c @@ -18,7 +18,7 @@ #include "cellular/onboard_modem_api.h" #include "gpio_api.h" -#include "platform/mbed_wait_api.h" +#include "platform/mbed_thread.h" #include "PinNames.h" #if MODEM_ON_BOARD @@ -29,7 +29,7 @@ static void press_power_button(int time_ms) gpio_init_out_ex(&gpio, MDMPWRON, 1); gpio_write(&gpio, 0); - wait_ms(time_ms); + thread_sleep_for(time_ms); gpio_write(&gpio, 1); } @@ -47,7 +47,7 @@ void onboard_modem_power_up() /* keep the power line low for 200 milisecond */ press_power_button(200); /* give modem a little time to respond */ - wait_ms(100); + thread_sleep_for(100); } void onboard_modem_power_down() @@ -59,7 +59,7 @@ void onboard_modem_power_down() * If 3G_ON_OFF pin is kept low for more than a second, a controlled disconnect and shutdown takes * place, Due to the network disconnect, shut-off can take up to 30 seconds. However, we wait for 10 * seconds only */ - wait_ms(10 * 1000); + thread_sleep_for(10 * 1000); } #endif //MODEM_ON_BOARD #endif //MBED_CONF_NSAPI_PRESENT diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTS_DRAGONFLY_F411RE/onboard_modem_api.c b/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTS_DRAGONFLY_F411RE/onboard_modem_api.c index 82e623e28e..a7e359d0ca 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTS_DRAGONFLY_F411RE/onboard_modem_api.c +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTS_DRAGONFLY_F411RE/onboard_modem_api.c @@ -18,7 +18,7 @@ #include "cellular/onboard_modem_api.h" #include "gpio_api.h" -#include "platform/mbed_wait_api.h" +#include "platform/mbed_thread.h" #include "PinNames.h" #if MODEM_ON_BOARD @@ -29,7 +29,7 @@ static void press_power_button(int time_ms) gpio_init_out_ex(&gpio, MDMPWRON, 1); gpio_write(&gpio, 0); - wait_ms(time_ms); + thread_sleep_for(time_ms); gpio_write(&gpio, 1); } @@ -47,7 +47,7 @@ void onboard_modem_power_up() /* keep the power line low for 200 milisecond */ press_power_button(200); /* give modem a little time to respond */ - wait_ms(100); + thread_sleep_for(100); } void onboard_modem_power_down() @@ -59,7 +59,7 @@ void onboard_modem_power_down() * If 3G_ON_OFF pin is kept low for more than a second, a controlled disconnect and shutdown takes * place, Due to the network disconnect, shut-off can take up to 30 seconds. However, we wait for 10 * seconds only */ - wait_ms(10 * 1000); + thread_sleep_for(10 * 1000); } #endif //MODEM_ON_BOARD #endif //MBED_CONF_NSAPI_PRESENT diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/onboard_modem_api.c b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/onboard_modem_api.c index bdc475d7ab..6a0a89913d 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/onboard_modem_api.c +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/onboard_modem_api.c @@ -19,6 +19,7 @@ #include "onboard_modem_api.h" #include "gpio_api.h" #include "platform/mbed_wait_api.h" +#include "platform/mbed_thread.h" #include "PinNames.h" #if MODEM_ON_BOARD @@ -71,7 +72,7 @@ void onboard_modem_power_up() #endif /* give modem a little time to respond */ - wait_ms(100); + thread_sleep_for(100); } void onboard_modem_power_down() diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_MODULE_UBLOX_ODIN_W2/sdk/ublox-odin-w2-drivers/OdinWiFiInterface.cpp b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_MODULE_UBLOX_ODIN_W2/sdk/ublox-odin-w2-drivers/OdinWiFiInterface.cpp index 43ba87f768..36a0688ee3 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_MODULE_UBLOX_ODIN_W2/sdk/ublox-odin-w2-drivers/OdinWiFiInterface.cpp +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_MODULE_UBLOX_ODIN_W2/sdk/ublox-odin-w2-drivers/OdinWiFiInterface.cpp @@ -1081,7 +1081,7 @@ void OdinWiFiInterface::handle_user_scan(user_scan_s *user_scan) cbRTSL_Status status = cbSTATUS_ERROR; for(int i = 0; (i < 10) && (status != cbSTATUS_OK); i++) { if(i > 0) { - wait_ms(500); + rtos::ThisThread::sleep_for(500); } cbMAIN_driverLock(); diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/onboard_modem_api.c b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/onboard_modem_api.c index c103ad0602..0b6eeff1c2 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/onboard_modem_api.c +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/onboard_modem_api.c @@ -20,7 +20,7 @@ #include "cellular/onboard_modem_api.h" #include "gpio_api.h" -#include "platform/mbed_wait_api.h" +#include "platform/mbed_thread.h" #include "PinNames.h" #define WAIT_AFTER_POWR_CHANGED (1000) // [msec.] @@ -32,7 +32,7 @@ static void press_power_button(int time_ms) gpio_t gpio; gpio_init_out_ex(&gpio, PWRKEY, 1); - wait_ms(time_ms); + thread_sleep_for(time_ms); gpio_write(&gpio, 0); } @@ -50,7 +50,7 @@ void onboard_modem_init() // Main UART Interface gpio_init_out_ex(&gpio, MDMDTR, 0); - wait_ms(WAIT_AFTER_POWR_CHANGED); + thread_sleep_for(WAIT_AFTER_POWR_CHANGED); } void onboard_modem_deinit() @@ -59,7 +59,7 @@ void onboard_modem_deinit() // Power supply OFF gpio_init_out_ex(&gpio, M_POWR, 0); - wait_ms(WAIT_AFTER_POWR_CHANGED); + thread_sleep_for(WAIT_AFTER_POWR_CHANGED); } void onboard_modem_power_up() @@ -68,10 +68,10 @@ void onboard_modem_power_up() // Power supply ON gpio_init_out_ex(&gpio, M_POWR, 1); - wait_ms(WAIT_AFTER_POWR_CHANGED); + thread_sleep_for(WAIT_AFTER_POWR_CHANGED); // Turn on - wait_ms(100); + thread_sleep_for(100); press_power_button(200); } @@ -81,7 +81,7 @@ void onboard_modem_power_down() // Power supply OFF gpio_init_out_ex(&gpio, M_POWR, 0); - wait_ms(WAIT_AFTER_POWR_CHANGED); + thread_sleep_for(WAIT_AFTER_POWR_CHANGED); } #endif //MODEM_ON_BOARD diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_BG96/onboard_modem_api.c b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_BG96/onboard_modem_api.c index fa10e622e6..53d83ec2a6 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_BG96/onboard_modem_api.c +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_BG96/onboard_modem_api.c @@ -20,7 +20,7 @@ #include "cellular/onboard_modem_api.h" #include "gpio_api.h" -#include "platform/mbed_wait_api.h" +#include "platform/mbed_thread.h" #include "PinNames.h" #define WAIT_AFTER_POWR_CHANGED (1000) // [msec.] @@ -32,7 +32,7 @@ static void press_power_button(int time_ms) gpio_t gpio; gpio_init_out_ex(&gpio, PWRKEY, 1); - wait_ms(time_ms); + thread_sleep_for(time_ms); gpio_write(&gpio, 0); } @@ -50,7 +50,7 @@ void onboard_modem_init() // Main UART Interface gpio_init_out_ex(&gpio, MDMDTR, 0); - wait_ms(WAIT_AFTER_POWR_CHANGED); + thread_sleep_for(WAIT_AFTER_POWR_CHANGED); } void onboard_modem_deinit() @@ -64,10 +64,10 @@ void onboard_modem_power_up() // Power supply ON gpio_init_out_ex(&gpio, M_POWR, 1); - wait_ms(WAIT_AFTER_POWR_CHANGED); + thread_sleep_for(WAIT_AFTER_POWR_CHANGED); // Turn on - wait_ms(100); + thread_sleep_for(100); press_power_button(200); } @@ -77,7 +77,7 @@ void onboard_modem_power_down() // Power supply OFF gpio_init_out_ex(&gpio, M_POWR, 0); - wait_ms(WAIT_AFTER_POWR_CHANGED); + thread_sleep_for(WAIT_AFTER_POWR_CHANGED); } #endif //MODEM_ON_BOARD diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_MTS_DRAGONFLY_L471QG/onboard_modem_api.c b/targets/TARGET_STM/TARGET_STM32L4/TARGET_MTS_DRAGONFLY_L471QG/onboard_modem_api.c index 9edf48ffd9..24a3c5ad08 100755 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_MTS_DRAGONFLY_L471QG/onboard_modem_api.c +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_MTS_DRAGONFLY_L471QG/onboard_modem_api.c @@ -18,7 +18,7 @@ #include "onboard_modem_api.h" #include "gpio_api.h" -#include "platform/mbed_wait_api.h" +#include "platform/mbed_thread.h" #include "PinNames.h" #if MODEM_ON_BOARD @@ -69,7 +69,7 @@ void onboard_modem_power_up() while(i < 3) { press_power_button(150000); - wait_ms(250); + thread_sleep_for(250); if(gpio_read(&gpio)) { diff --git a/usb/device/USBHID/USBMouse.cpp b/usb/device/USBHID/USBMouse.cpp index 9240ffd5d6..bb60625ab5 100644 --- a/usb/device/USBHID/USBMouse.cpp +++ b/usb/device/USBHID/USBMouse.cpp @@ -17,9 +17,8 @@ #include "stdint.h" #include "USBMouse.h" -#include "PlatformMutex.h" +#include "ThisThread.h" #include "usb_phy_api.h" -#include "mbed_wait_api.h" USBMouse::USBMouse(bool connect_blocking, MOUSE_TYPE mouse_type, uint16_t vendor_id, uint16_t product_id, uint16_t product_release): @@ -157,7 +156,7 @@ bool USBMouse::double_click() _mutex.unlock(); return false; } - wait(0.1); + rtos::ThisThread::sleep_for(100); bool ret = click(MOUSE_LEFT); _mutex.unlock(); @@ -172,7 +171,7 @@ bool USBMouse::click(uint8_t button) _mutex.unlock(); return false; } - wait(0.01); + rtos::ThisThread::sleep_for(10); bool ret = update(0, 0, 0, 0); _mutex.unlock(); diff --git a/usb/device/USBHID/USBMouseKeyboard.cpp b/usb/device/USBHID/USBMouseKeyboard.cpp index b236e30753..acd540479b 100644 --- a/usb/device/USBHID/USBMouseKeyboard.cpp +++ b/usb/device/USBHID/USBMouseKeyboard.cpp @@ -18,7 +18,7 @@ #include "stdint.h" #include "USBMouseKeyboard.h" #include "usb_phy_api.h" -#include "mbed_wait_api.h" +#include "ThisThread.h" typedef struct { unsigned char usage; @@ -709,7 +709,7 @@ bool USBMouseKeyboard::doubleClick() _mutex.unlock(); return false; } - wait(0.1); + rtos::ThisThread::sleep_for(100); bool ret = click(MOUSE_LEFT); _mutex.unlock(); @@ -724,7 +724,7 @@ bool USBMouseKeyboard::click(uint8_t button) _mutex.unlock(); return false; } - wait(0.01); + rtos::ThisThread::sleep_for(10); bool ret = update(0, 0, 0, 0); _mutex.unlock();