example serial interface for python and LPC11U24 - analogin and pwm working
Fork of RPC_Serial_new by
main.cpp@6:f83b71016626, 2014-07-27 (annotated)
- Committer:
- bhavik
- Date:
- Sun Jul 27 15:44:59 2014 +0000
- Revision:
- 6:f83b71016626
- Parent:
- 5:1caee8f66e14
analogin working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MichaelW | 0:78952cd3935b | 1 | #include "mbed.h" |
bhavik | 3:726cfc72fe9a | 2 | #include "mbed_rpc.h" |
bhavik | 2:fadccef926e4 | 3 | |
MichaelW | 0:78952cd3935b | 4 | Serial pc(USBTX, USBRX); |
bhavik | 2:fadccef926e4 | 5 | |
MichaelW | 0:78952cd3935b | 6 | int main() { |
MichaelW | 1:de34af25056a | 7 | // setup the classes that can be created dynamically |
bhavik | 6:f83b71016626 | 8 | RPC::add_rpc_class<RpcAnalogIn>(); |
bhavik | 6:f83b71016626 | 9 | |
bhavik | 3:726cfc72fe9a | 10 | RPC::add_rpc_class<RpcDigitalIn>(); |
bhavik | 4:726b4e996614 | 11 | RPC::add_rpc_class<RpcDigitalOut>(); |
bhavik | 5:1caee8f66e14 | 12 | |
bhavik | 6:f83b71016626 | 13 | RPC::add_rpc_class<RpcPwmOut>(); |
bhavik | 6:f83b71016626 | 14 | |
bhavik | 6:f83b71016626 | 15 | RpcAnalogIn rpc_ain(p19, "ain"); |
bhavik | 5:1caee8f66e14 | 16 | RpcDigitalOut rpc_led(LED1, "led"); |
bhavik | 6:f83b71016626 | 17 | RpcPwmOut rpc_pwmout(p10, "pwmout"); |
bhavik | 3:726cfc72fe9a | 18 | |
MichaelW | 1:de34af25056a | 19 | // receive commands, and send back the responses |
bhavik | 3:726cfc72fe9a | 20 | char buf[256], outbuf[256]; |
bhavik | 3:726cfc72fe9a | 21 | |
MichaelW | 0:78952cd3935b | 22 | while(1) { |
MichaelW | 0:78952cd3935b | 23 | pc.gets(buf, 256); |
bhavik | 3:726cfc72fe9a | 24 | RPC::call(buf, outbuf); |
MichaelW | 0:78952cd3935b | 25 | pc.printf("%s\n", outbuf); |
MichaelW | 0:78952cd3935b | 26 | } |
MichaelW | 0:78952cd3935b | 27 | } |
bhavik | 6:f83b71016626 | 28 | /* |
bhavik | 6:f83b71016626 | 29 | void myRPCAnalogIn(Arguments* input, Reply* output){ |
bhavik | 6:f83b71016626 | 30 | output->putData(ain.read()); |
bhavik | 6:f83b71016626 | 31 | led3 = 1; |
bhavik | 6:f83b71016626 | 32 | wait(2); |
bhavik | 6:f83b71016626 | 33 | led3 = 0; |
bhavik | 6:f83b71016626 | 34 | } |
bhavik | 6:f83b71016626 | 35 | */ |