Skip to content

Commit 79b63b9

Browse files
author
Qinghao Shi
committed
update examplea replace deprecated wait and wait_ms api
1 parent 8b30e2c commit 79b63b9

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

APIs_Drivers/QSPI/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static bool mem_ready()
5353
if (QSPI_STATUS_OK != qspi_device.command_transfer(CMD_RDSR, -1, NULL, 0, status_value, STATUS_REG_SIZE)) {
5454
printf("Reading Status Register failed \n");
5555
}
56-
wait_ms(1);
56+
wait_us(1000);
5757
} while ((status_value[0] & BIT_WIP) != 0 && retries);
5858

5959
if ((status_value[0] & BIT_WIP) != 0) {

APIs_RTOS/EventFlags/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ int main()
2121
worker_thread.start(mbed::callback(worker_thread_fun));
2222

2323
while (true) {
24-
wait(1.0);
24+
ThisThread::sleep_for(1000);
2525
event_flags.set(SAMPLE_FLAG1);
26-
wait(0.5);
26+
ThisThread::sleep_for(1000);
2727
event_flags.set(SAMPLE_FLAG2);
2828
}
2929
}

APIs_RTOS/Queue/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void send_thread (void) {
2020
message->current = (i * 0.1) * 11;
2121
message->counter = i;
2222
queue.put(message);
23-
wait(1);
23+
ThisThread::sleep_for(1000);
2424
}
2525
}
2626

APIs_USB/USBCDC_ECM/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ int main()
3838
{
3939
while (true) {
4040
ecm.send((uint8_t *)&packet, sizeof(packet));
41-
wait(1.0);
41+
ThisThread::sleep_for(1000);
4242
}
4343
}

Tutorials_UsingAPIs/Alarm/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ int main() {
8686
inc_time.rise(inc_delay);
8787

8888
// Sleep while waiting for user input to set the desired delay
89-
while (select_state < 2) { wait_ms(10); }
89+
while (select_state < 2) { ThisThread::sleep_for(10); }
9090

9191
// Once the delay has been input, blink back the configured hours and
9292
// minutes selected
9393
for (uint8_t i = 0; i < hour_count * 2; i++) {
9494
hour_led = !hour_led;
95-
wait(0.25f);
95+
ThisThread::sleep_for(250);
9696
}
9797

9898
for (uint8_t i = 0; i < min_count * 2; i++) {
9999
min_led = !min_led;
100-
wait(0.25f);
100+
ThisThread::sleep_for(250);
101101
}
102102

103103
// Attach the low power ticker with the configured alarm delay

Tutorials_UsingAPIs/Flow-Control-Busy-Wait-Button/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int main() {
99
while(1) {
1010
if(BUTTON_PRESS == button){
1111
led = !led;
12-
wait(1);
12+
wait_us(1000000);
1313
}
1414
}
1515
}

Tutorials_UsingAPIs/Flow-Control-Busy-Wait/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ int main() {
66
while(1) {
77
myled = 1;
88
// printf("LED On\r\n");
9-
wait(0.2);
9+
wait_us(200000);
1010
myled = 0;
1111
// printf("LED Off \r\n");
12-
wait(0.2);
12+
wait_us(200000);
1313
}
1414
}

Tutorials_UsingAPIs/Flow-Control-Interrupt-Button/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ int main() {
1212
button.rise(&toggle); // call toggle function on the rising edge
1313
while(1) { // wait around, interrupts will interrupt this!
1414
heartbeat = !heartbeat;
15-
wait(0.25);
15+
wait_us(250000);
1616
}
1717
}

Tutorials_UsingAPIs/Flow-Control-Thread/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Thread thread;
77
void led2_thread() {
88
while (true) {
99
led2 = !led2;
10-
wait(1);
10+
ThisThread::sleep_for(1000);
1111
}
1212
}
1313

@@ -18,6 +18,6 @@ int main() {
1818

1919
while (true) {
2020
led1 = !led1;
21-
wait(0.5);
21+
ThisThread::sleep_for(500);
2222
}
2323
}

Tutorials_UsingAPIs/Flow-Control-Ticker/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ int main() {
1515
// spin in a main loop. flipper will interrupt it to call flip
1616
while(1) {
1717
led1 = !led1;
18-
wait(0.2);
18+
wait_us(200000);
1919
}
2020
}

0 commit comments

Comments
 (0)