Nathan Yonkee
/
Nucleo_read_ios
copy of example for reading multiple IOs simultaneously
main.cpp@1:a43f62815aec, 2017-04-21 (annotated)
- Committer:
- tulanthoar
- Date:
- Fri Apr 21 19:53:34 2017 +0000
- Revision:
- 1:a43f62815aec
- Parent:
- 0:1313568875d2
switch to mbed-os
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tulanthoar | 0:1313568875d2 | 1 | #include "mbed.h" |
tulanthoar | 0:1313568875d2 | 2 | |
tulanthoar | 0:1313568875d2 | 3 | #define IOS (0xA0) // PA_5 + PA_7 |
tulanthoar | 0:1313568875d2 | 4 | |
tulanthoar | 0:1313568875d2 | 5 | PortIn myIOs(PortA, IOS); |
tulanthoar | 0:1313568875d2 | 6 | |
tulanthoar | 0:1313568875d2 | 7 | DigitalOut myled(LED1); |
tulanthoar | 0:1313568875d2 | 8 | |
tulanthoar | 0:1313568875d2 | 9 | int main() { |
tulanthoar | 0:1313568875d2 | 10 | while(1) { |
tulanthoar | 0:1313568875d2 | 11 | if (myIOs.read() != IOS) { // Any of the 2 IOs is low |
tulanthoar | 0:1313568875d2 | 12 | myled = !myled; // Toggle LED state |
tulanthoar | 0:1313568875d2 | 13 | wait(0.2); |
tulanthoar | 0:1313568875d2 | 14 | } |
tulanthoar | 0:1313568875d2 | 15 | } |
tulanthoar | 0:1313568875d2 | 16 | } |
tulanthoar | 0:1313568875d2 | 17 |