An RPC program that reads data from an Accelerometer(MMA7660) on the Mbed developement board and sends it to the PC trough a serial connection

Dependencies:   MMA7660 RPCInterface mbed

Fork of RPC_Serial by Michael Walker

Committer:
sammekevremde
Date:
Mon Mar 10 11:49:35 2014 +0000
Revision:
2:c079ba242f7c
Parent:
1:de34af25056a
RPC program that reads data from the accelerometer on the development board and sends it to PC trough a serial connection

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MichaelW 0:78952cd3935b 1 #include "mbed.h"
MichaelW 0:78952cd3935b 2 #include "rpc.h"
sammekevremde 2:c079ba242f7c 3 #include "RPCVariable.h"
sammekevremde 2:c079ba242f7c 4 //#include "LM75B.h"
sammekevremde 2:c079ba242f7c 5 #include "MMA7660.h"
sammekevremde 2:c079ba242f7c 6
sammekevremde 2:c079ba242f7c 7
sammekevremde 2:c079ba242f7c 8
MichaelW 0:78952cd3935b 9 Serial pc(USBTX, USBRX);
sammekevremde 2:c079ba242f7c 10 AnalogIn pot1 (p19, "pot1");
sammekevremde 2:c079ba242f7c 11 //LM75B tmp(p28,p27);
sammekevremde 2:c079ba242f7c 12 MMA7660 MMA(p28, p27);
sammekevremde 2:c079ba242f7c 13
sammekevremde 2:c079ba242f7c 14 //float t1;
sammekevremde 2:c079ba242f7c 15 float x, tmpx;
sammekevremde 2:c079ba242f7c 16 float y;
sammekevremde 2:c079ba242f7c 17 float z;
sammekevremde 2:c079ba242f7c 18 //RPCVariable<float>RPCtemp(&t1,"t1");
sammekevremde 2:c079ba242f7c 19 RPCVariable<float>RPCx(&x,"x-as");
sammekevremde 2:c079ba242f7c 20 RPCVariable<float>RPCy(&y,"y-as");
sammekevremde 2:c079ba242f7c 21 RPCVariable<float>RPCz(&z,"z-as");
sammekevremde 2:c079ba242f7c 22
MichaelW 0:78952cd3935b 23 int main() {
sammekevremde 2:c079ba242f7c 24 pc.baud(57600);
MichaelW 1:de34af25056a 25 // setup the classes that can be created dynamically
MichaelW 0:78952cd3935b 26 Base::add_rpc_class<AnalogIn>();
MichaelW 0:78952cd3935b 27 Base::add_rpc_class<AnalogOut>();
MichaelW 0:78952cd3935b 28 Base::add_rpc_class<DigitalIn>();
MichaelW 0:78952cd3935b 29 Base::add_rpc_class<DigitalOut>();
MichaelW 0:78952cd3935b 30 Base::add_rpc_class<DigitalInOut>();
MichaelW 0:78952cd3935b 31 Base::add_rpc_class<PwmOut>();
MichaelW 0:78952cd3935b 32 Base::add_rpc_class<Timer>();
MichaelW 0:78952cd3935b 33 Base::add_rpc_class<SPI>();
MichaelW 0:78952cd3935b 34 Base::add_rpc_class<BusOut>();
MichaelW 0:78952cd3935b 35 Base::add_rpc_class<BusIn>();
MichaelW 0:78952cd3935b 36 Base::add_rpc_class<BusInOut>();
MichaelW 0:78952cd3935b 37 Base::add_rpc_class<Serial>();
MichaelW 1:de34af25056a 38 // receive commands, and send back the responses
MichaelW 0:78952cd3935b 39 char buf[256], outbuf[256];
MichaelW 0:78952cd3935b 40 while(1) {
sammekevremde 2:c079ba242f7c 41 //t1 = tmp.read();
sammekevremde 2:c079ba242f7c 42
sammekevremde 2:c079ba242f7c 43 x = MMA.x();
sammekevremde 2:c079ba242f7c 44 y = MMA.y();
sammekevremde 2:c079ba242f7c 45 z = MMA.z();
sammekevremde 2:c079ba242f7c 46
MichaelW 0:78952cd3935b 47 pc.gets(buf, 256);
MichaelW 0:78952cd3935b 48 rpc(buf, outbuf);
MichaelW 0:78952cd3935b 49 pc.printf("%s\n", outbuf);
MichaelW 0:78952cd3935b 50 }
MichaelW 0:78952cd3935b 51 }