Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-rpc by
Diff: RpcClasses.h
- Revision:
- 6:be730ea7a82a
- Parent:
- 1:6919289a5946
- Child:
- 7:496c48896d9e
--- a/RpcClasses.h Mon Aug 19 18:37:40 2013 +0300
+++ b/RpcClasses.h Fri Jan 31 13:52:45 2014 +0000
@@ -20,6 +20,45 @@
namespace mbed {
+//zaza
+class RpcI2C : public RPC {
+public:
+ RpcI2C(PinName sda, PinName scl, const char *name=NULL) : RPC(name), o(sda, scl) {}
+
+ void frequency(int hz) {o.frequency(hz); }
+ int read(int address, char * data, int length, bool repeated) {return o.read(address, data, length, repeated); }
+ int read(int ack) {return o.read(ack); }
+ int write(int address, const char *data, int length, bool repeated) {return o.write(address, data, length, repeated); }
+ int write(int data) {return o.write(data); }
+ void start(void) {o.start(); }
+ void stop(void) {o.stop(); }
+
+ virtual const struct rpc_method *get_rpc_methods() {
+ static const rpc_method rpc_methods[] = {
+ {"frequency", rpc_method_caller < RpcI2C, int, &RpcI2C::frequency>},
+ {"read", rpc_method_caller <int, RpcI2C, int, char *, int, bool, &RpcI2C::read>},
+ {"read", rpc_method_caller <int, RpcI2C, int, &RpcI2C::read>},
+ {"write", rpc_method_caller <int, RpcI2C, int, const char *, int , bool, &RpcI2C::write>},
+ {"write", rpc_method_caller <int, RpcI2C, int, &RpcI2C::write>},
+ {"start", rpc_method_caller < RpcI2C, &RpcI2C::start>},
+ {"stop", rpc_method_caller < RpcI2C, &RpcI2C::stop>},
+ RPC_METHOD_SUPER(RPC)
+ };
+ return rpc_methods;
+ }
+ static struct rpc_class *get_rpc_class() {
+ static const rpc_function funcs[] = {
+ {"new", rpc_function_caller<const char*, PinName, PinName, const char*, &RPC::construct<RpcI2C, PinName, PinName, const char*> >},
+ RPC_METHOD_END
+ };
+ static rpc_class c = {"I2C", funcs, NULL};
+ return &c;
+ }
+private:
+ I2C o;
+};
+//zaza
+
class RpcDigitalOut : public RPC {
public:
RpcDigitalOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
