Read several IOs of a port at the same time.

Dependencies:   mbed

Committer:
arostm
Date:
Wed Jun 07 13:50:25 2017 +0000
Revision:
2:cf1ebdbc6c0a
Parent:
1:a33d077656dc
Adding new mbed library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:f7c4107b448c 1 #include "mbed.h"
svastm 1:a33d077656dc 2
svastm 1:a33d077656dc 3 #define IOS (0xA0) // PA_5 + PA_7
bcostm 0:f7c4107b448c 4
svastm 1:a33d077656dc 5 PortIn myIOs(PortA, IOS);
bcostm 0:f7c4107b448c 6
bcostm 0:f7c4107b448c 7 DigitalOut myled(LED1);
bcostm 0:f7c4107b448c 8
bcostm 0:f7c4107b448c 9 int main() {
svastm 1:a33d077656dc 10 while(1) {
svastm 1:a33d077656dc 11 if (myIOs.read() != IOS) { // Any of the 2 IOs is low
svastm 1:a33d077656dc 12 myled = !myled; // Toggle LED state
svastm 1:a33d077656dc 13 wait(0.2);
svastm 1:a33d077656dc 14 }
bcostm 0:f7c4107b448c 15 }
bcostm 0:f7c4107b448c 16 }
bcostm 0:f7c4107b448c 17