Bare-metal configuration with EventQueue for a Bluepill board.
Warning
It does not work with the Mbed Online Compiler.
Follow these steps to import and compile it with Mbed CLI:
mbed import https://os.mbed.com/users/hudakz/code/Baremetal_EventQue_Bluepill mbed compile -t GCC_ARM -m bluepill
main.cpp@3:f25880700bda, 2020-05-18 (annotated)
- Committer:
- hudakz
- Date:
- Mon May 18 15:26:33 2020 +0000
- Revision:
- 3:f25880700bda
- Parent:
- 1:96018ca8cb3f
Bare-metal with EventQueue on Bluepill.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 0:2cf53c219693 | 1 | #include "mbed.h" |
hudakz | 0:2cf53c219693 | 2 | |
hudakz | 3:f25880700bda | 3 | DigitalOut led1(LED1); |
hudakz | 0:2cf53c219693 | 4 | InterruptIn button(PA_8, PullUp); |
hudakz | 0:2cf53c219693 | 5 | EventQueue eventQueue; |
hudakz | 0:2cf53c219693 | 6 | |
hudakz | 0:2cf53c219693 | 7 | void onButtonFall(void) |
hudakz | 0:2cf53c219693 | 8 | { |
hudakz | 0:2cf53c219693 | 9 | printf("Button pushed\r\n"); |
hudakz | 0:2cf53c219693 | 10 | } |
hudakz | 0:2cf53c219693 | 11 | |
hudakz | 0:2cf53c219693 | 12 | void toggleLED() |
hudakz | 0:2cf53c219693 | 13 | { |
hudakz | 0:2cf53c219693 | 14 | led1 = !led1; |
hudakz | 0:2cf53c219693 | 15 | } |
hudakz | 0:2cf53c219693 | 16 | |
hudakz | 0:2cf53c219693 | 17 | int main() |
hudakz | 0:2cf53c219693 | 18 | { |
hudakz | 0:2cf53c219693 | 19 | button.fall(eventQueue.event(onButtonFall)); |
hudakz | 0:2cf53c219693 | 20 | eventQueue.call_every(500, toggleLED); |
hudakz | 0:2cf53c219693 | 21 | eventQueue.dispatch_forever(); |
hudakz | 0:2cf53c219693 | 22 | } |