nucho
/
RTno_digitalInOut
Diff: main.cpp
- Revision:
- 1:b96a6ff9bb6f
- Parent:
- 0:b14546a3cfab
diff -r b14546a3cfab -r b96a6ff9bb6f main.cpp --- a/main.cpp Fri Jul 29 11:23:06 2011 +0000 +++ b/main.cpp Mon Aug 01 14:45:58 2011 +0000 @@ -23,7 +23,7 @@ #include "mbed.h" #include "RTno.h" - +#include "Serial.h" DigitalIn inPorts[] = {(p5), (p6),(p7),(p8),(p9),(p10)}; DigitalOut outPorts[] = {(p15),(p16),(p17),(p18),(p19),(p20)}; DigitalOut leds[] = {(LED1),(LED2),(LED3),(LED4)}; @@ -54,6 +54,7 @@ * Please refer following comments. If you need to use some ports, * uncomment the line you want to declare. **/ + TimedLongSeq led; InPort ledIn("led", led); @@ -63,6 +64,7 @@ TimedLongSeq out0; OutPort out0Out("out0", out0); + ////////////////////////////////////////// // on_initialize // @@ -123,6 +125,7 @@ /* * Input digital data */ + if (ledIn.isNew()) { ledIn.read(); for (int i = 0; i < led.data.length() && i < 4; i++) { @@ -130,20 +133,21 @@ } } - if (in0In.isNew()) { - in0In.read(); - for (int i = 0; i < in0.data.length() && i < 6; i++) { - outPorts[i] =in0.data[i]; + + if (in0In.isNew()) { + in0In.read(); + for (int i = 0; i < in0.data.length() && i < 6; i++) { + outPorts[i] =in0.data[i]; + } } - } - + /* * Output digital data in Voltage unit. */ out0.data.length(6); for (int i = 0; i < 6; i++) { - out0.data[i] = inPorts[i]; + out0.data[i] = inPorts[i]; } out0Out.write();