File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ # EventFlags example
2
+
3
+ EventFlags usage example for Mbed OS.
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
1
+ https://github.com/ARMmbed/mbed-os/#c53d51fe9220728bf8ed27afe7afc1ecc3f6f5d7
You can’t perform that action at this time.
0 commit comments