Skip to content

Commit d5c93cd

Browse files
Qinghao Shifkjagodzinski
andauthored
update examplea replace deprecated wait and wait_ms api (#59)
* update examplea replace deprecated wait and wait_ms api * Update APIs_RTOS/EventFlags/main.cpp Co-Authored-By: Filip Jagodziński <[email protected]> * address github comments * rename example * update ci scripts to ignored renamed file * fix a typo Co-authored-by: Filip Jagodziński <[email protected]>
1 parent fad81ab commit d5c93cd

File tree

11 files changed

+16
-16
lines changed

11 files changed

+16
-16
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
- run: |
2121
cd sinppet/TESTS
2222
wget https://github.com/ARMmbed/mbed-os/raw/master/.astylerc
23-
git --no-pager diff --name-only --diff-filter=d HEAD $(git merge-base --fork-point origin/master) | ( grep '.\(c\|cpp\|h\|hpp\)$' || true ) | while read file; do astyle -n --options=.astylerc "${file}"; done
24-
git diff --exit-code --diff-filter=d --color
23+
git --no-pager diff --name-only --diff-filter=dr HEAD $(git merge-base --fork-point origin/master) | ( grep '.\(c\|cpp\|h\|hpp\)$' || true ) | while read file; do astyle -n --options=.astylerc "${file}"; done
24+
git diff --exit-code --diff-filter=dr --color
2525
2626
### Compile Tests ###
2727
- run: mv sinppet/TESTS/mbed-os.lib .

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+
ThisThread::sleep_for(1);
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(500);
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
@@ -25,7 +25,7 @@ void send_thread(void)
2525
message->current = (i * 0.1) * 11;
2626
message->counter = i;
2727
queue.put(message);
28-
wait(1);
28+
ThisThread::sleep_for(1000);
2929
}
3030
}
3131

Tutorials_UsingAPIs/Alarm/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ int main()
9292

9393
// Sleep while waiting for user input to set the desired delay
9494
while (select_state < 2) {
95-
wait_ms(10);
95+
ThisThread::sleep_for(10);
9696
}
9797

9898
// Once the delay has been input, blink back the configured hours and
9999
// minutes selected
100100
for (uint8_t i = 0; i < hour_count * 2; i++) {
101101
hour_led = !hour_led;
102-
wait(0.25f);
102+
ThisThread::sleep_for(250);
103103
}
104104

105105
for (uint8_t i = 0; i < min_count * 2; i++) {
106106
min_led = !min_led;
107-
wait(0.25f);
107+
ThisThread::sleep_for(250);
108108
}
109109

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

Tutorials_UsingAPIs/Flow-Control-Busy-Wait-Button/main.cpp renamed to Tutorials_UsingAPIs/Flow-Control-Active-Polling-Button/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int main()
1010
while (1) {
1111
if (BUTTON_PRESS == button) {
1212
led = !led;
13-
wait(1);
13+
ThisThread::sleep_for(1000);
1414
}
1515
}
1616
}

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ int main()
1414
button.rise(&toggle); // call toggle function on the rising edge
1515
while (1) { // wait around, interrupts will interrupt this!
1616
heartbeat = !heartbeat;
17-
wait(0.25);
17+
ThisThread::sleep_for(250);
1818
}
1919
}

Tutorials_UsingAPIs/Flow-Control-Thread/main.cpp

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

@@ -20,6 +20,6 @@ int main()
2020

2121
while (true) {
2222
led1 = !led1;
23-
wait(0.5);
23+
ThisThread::sleep_for(500);
2424
}
2525
}

Tutorials_UsingAPIs/Flow-Control-Ticker/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ int main()
1717
// spin in a main loop. flipper will interrupt it to call flip
1818
while (1) {
1919
led1 = !led1;
20-
wait(0.2);
20+
ThisThread::sleep_for(200);
2121
}
2222
}

0 commit comments

Comments
 (0)