David Taylor
/
DigitalOut
Simple digital out program, which works with the standard LabView libraries for the FRDM KL25Z platform.
main.cpp@0:10ec212e4043, 2014-04-09 (annotated)
- Committer:
- Bear05
- Date:
- Wed Apr 09 16:39:56 2014 +0000
- Revision:
- 0:10ec212e4043
LabView compatible sigital out on FRDM KL25Z platform;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bear05 | 0:10ec212e4043 | 1 | #include "mbed.h" |
Bear05 | 0:10ec212e4043 | 2 | #include "mbed_rpc.h" |
Bear05 | 0:10ec212e4043 | 3 | |
Bear05 | 0:10ec212e4043 | 4 | Serial pc(USBTX, USBRX); |
Bear05 | 0:10ec212e4043 | 5 | |
Bear05 | 0:10ec212e4043 | 6 | char buf[RPC_MAX_STRING], outbuf[RPC_MAX_STRING]; |
Bear05 | 0:10ec212e4043 | 7 | PwmOut led(LED3); |
Bear05 | 0:10ec212e4043 | 8 | |
Bear05 | 0:10ec212e4043 | 9 | int main() |
Bear05 | 0:10ec212e4043 | 10 | { |
Bear05 | 0:10ec212e4043 | 11 | led = 0.95; |
Bear05 | 0:10ec212e4043 | 12 | |
Bear05 | 0:10ec212e4043 | 13 | // define classes |
Bear05 | 0:10ec212e4043 | 14 | RPC::add_rpc_class<RpcDigitalOut>(); |
Bear05 | 0:10ec212e4043 | 15 | |
Bear05 | 0:10ec212e4043 | 16 | // define outputs |
Bear05 | 0:10ec212e4043 | 17 | RpcDigitalOut rpc_rtng1(PTE5, "one"); |
Bear05 | 0:10ec212e4043 | 18 | RpcDigitalOut rpc_rtng2(PTE3, "two"); |
Bear05 | 0:10ec212e4043 | 19 | RpcDigitalOut rpc_En1(PTE4, "Enable1"); |
Bear05 | 0:10ec212e4043 | 20 | RpcDigitalOut rpc_fan(PTB9, "three"); |
Bear05 | 0:10ec212e4043 | 21 | RpcDigitalOut rpc_En2(PTB8, "Enable2"); |
Bear05 | 0:10ec212e4043 | 22 | strcpy(buf, "/one/write 0"); |
Bear05 | 0:10ec212e4043 | 23 | RPC::call(buf, outbuf); |
Bear05 | 0:10ec212e4043 | 24 | strcpy(buf, "/two/write 0"); |
Bear05 | 0:10ec212e4043 | 25 | RPC::call(buf, outbuf); |
Bear05 | 0:10ec212e4043 | 26 | strcpy(buf, "/Enable1/write 0"); |
Bear05 | 0:10ec212e4043 | 27 | RPC::call(buf, outbuf); |
Bear05 | 0:10ec212e4043 | 28 | strcpy(buf, "/three/write 0"); |
Bear05 | 0:10ec212e4043 | 29 | RPC::call(buf, outbuf); |
Bear05 | 0:10ec212e4043 | 30 | strcpy(buf, "/Enable2/write 0"); |
Bear05 | 0:10ec212e4043 | 31 | RPC::call(buf, outbuf); |
Bear05 | 0:10ec212e4043 | 32 | |
Bear05 | 0:10ec212e4043 | 33 | // receive commands, and send back the responses |
Bear05 | 0:10ec212e4043 | 34 | while(1) { |
Bear05 | 0:10ec212e4043 | 35 | pc.gets(buf, 256); |
Bear05 | 0:10ec212e4043 | 36 | RPC::call(buf, outbuf); |
Bear05 | 0:10ec212e4043 | 37 | pc.printf("%s\n", outbuf); |
Bear05 | 0:10ec212e4043 | 38 | } |
Bear05 | 0:10ec212e4043 | 39 | } |