Skip to content

Commit 72427b3

Browse files
author
Cruz Monrreal
authored
Merge pull request #6 from fkjagodzinski/docs_update-eventflags
Move & update EventFlags example from docs repo
2 parents 21d3505 + 145ee55 commit 72427b3

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

EventFlags/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# EventFlags example
2+
3+
EventFlags usage example for Mbed OS.

EventFlags/main.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "mbed.h"
2+
3+
#define SAMPLE_FLAG1 (1UL << 0)
4+
#define SAMPLE_FLAG2 (1UL << 9)
5+
6+
EventFlags event_flags;
7+
8+
void worker_thread_fun()
9+
{
10+
printf("Waiting for any flag from 0x%08lx.\r\n", SAMPLE_FLAG1 | SAMPLE_FLAG2);
11+
uint32_t flags_read = 0;
12+
while (true) {
13+
flags_read = event_flags.wait_any(SAMPLE_FLAG1 | SAMPLE_FLAG2);
14+
printf("Got: 0x%08lx\r\n", flags_read);
15+
}
16+
}
17+
18+
int main()
19+
{
20+
Thread worker_thread;
21+
worker_thread.start(mbed::callback(worker_thread_fun));
22+
23+
while (true) {
24+
wait(1.0);
25+
event_flags.set(SAMPLE_FLAG1);
26+
wait(0.5);
27+
event_flags.set(SAMPLE_FLAG2);
28+
}
29+
}

EventFlags/mbed-os.lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/ARMmbed/mbed-os/#c53d51fe9220728bf8ed27afe7afc1ecc3f6f5d7

0 commit comments

Comments
 (0)