Skip to content

update examplea replace deprecated wait and wait_ms api #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- run: |
cd sinppet/TESTS
wget https://github.com/ARMmbed/mbed-os/raw/master/.astylerc
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
git diff --exit-code --diff-filter=d --color
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
git diff --exit-code --diff-filter=dr --color

### Compile Tests ###
- run: mv sinppet/TESTS/mbed-os.lib .
Expand Down
2 changes: 1 addition & 1 deletion APIs_Drivers/QSPI/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static bool mem_ready()
if (QSPI_STATUS_OK != qspi_device.command_transfer(CMD_RDSR, -1, NULL, 0, status_value, STATUS_REG_SIZE)) {
printf("Reading Status Register failed \n");
}
wait_ms(1);
ThisThread::sleep_for(1);
} while ((status_value[0] & BIT_WIP) != 0 && retries);

if ((status_value[0] & BIT_WIP) != 0) {
Expand Down
4 changes: 2 additions & 2 deletions APIs_RTOS/EventFlags/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ int main()
worker_thread.start(mbed::callback(worker_thread_fun));

while (true) {
wait(1.0);
ThisThread::sleep_for(1000);
event_flags.set(SAMPLE_FLAG1);
wait(0.5);
ThisThread::sleep_for(500);
event_flags.set(SAMPLE_FLAG2);
}
}
2 changes: 1 addition & 1 deletion APIs_RTOS/Queue/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void send_thread(void)
message->current = (i * 0.1) * 11;
message->counter = i;
queue.put(message);
wait(1);
ThisThread::sleep_for(1000);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Tutorials_UsingAPIs/Alarm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ int main()

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

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

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

// Attach the low power ticker with the configured alarm delay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main()
while (1) {
if (BUTTON_PRESS == button) {
led = !led;
wait(1);
ThisThread::sleep_for(1000);
}
}
}
4 changes: 2 additions & 2 deletions Tutorials_UsingAPIs/Flow-Control-Busy-Wait/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ int main()
while (1) {
myled = 1;
// printf("LED On\r\n");
wait(0.2);
wait_us(200000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, no need to busy wait.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per previous comment, I propose that this is the only example that uses wait_us. Let's emphasize further by adding a comment

wait_us(200000); // Busy wait

When updating the tutorial, we should add a forth option : "sleep" option.

myled = 0;
// printf("LED Off \r\n");
wait(0.2);
wait_us(200000);
}
}
2 changes: 1 addition & 1 deletion Tutorials_UsingAPIs/Flow-Control-Interrupt-Button/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ int main()
button.rise(&toggle); // call toggle function on the rising edge
while (1) { // wait around, interrupts will interrupt this!
heartbeat = !heartbeat;
wait(0.25);
ThisThread::sleep_for(250);
}
}
4 changes: 2 additions & 2 deletions Tutorials_UsingAPIs/Flow-Control-Thread/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void led2_thread()
{
while (true) {
led2 = !led2;
wait(1);
ThisThread::sleep_for(1000);
}
}

Expand All @@ -20,6 +20,6 @@ int main()

while (true) {
led1 = !led1;
wait(0.5);
ThisThread::sleep_for(500);
}
}
2 changes: 1 addition & 1 deletion Tutorials_UsingAPIs/Flow-Control-Ticker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ int main()
// spin in a main loop. flipper will interrupt it to call flip
while (1) {
led1 = !led1;
wait(0.2);
ThisThread::sleep_for(200);
}
}