Maxim nexpaq / nexpaq_dev
Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 /* mbed Microcontroller Library
nexpaq 0:6c56fb4bc5f0 2 * Copyright (c) 2006-2013 ARM Limited
nexpaq 0:6c56fb4bc5f0 3 *
nexpaq 0:6c56fb4bc5f0 4 * Licensed under the Apache License, Version 2.0 (the "License");
nexpaq 0:6c56fb4bc5f0 5 * you may not use this file except in compliance with the License.
nexpaq 0:6c56fb4bc5f0 6 * You may obtain a copy of the License at
nexpaq 0:6c56fb4bc5f0 7 *
nexpaq 0:6c56fb4bc5f0 8 * http://www.apache.org/licenses/LICENSE-2.0
nexpaq 0:6c56fb4bc5f0 9 *
nexpaq 0:6c56fb4bc5f0 10 * Unless required by applicable law or agreed to in writing, software
nexpaq 0:6c56fb4bc5f0 11 * distributed under the License is distributed on an "AS IS" BASIS,
nexpaq 0:6c56fb4bc5f0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 0:6c56fb4bc5f0 13 * See the License for the specific language governing permissions and
nexpaq 0:6c56fb4bc5f0 14 * limitations under the License.
nexpaq 0:6c56fb4bc5f0 15 */
nexpaq 0:6c56fb4bc5f0 16 #ifndef MBED_CLASSES_H
nexpaq 0:6c56fb4bc5f0 17 #define MBED_CLASSES_H
nexpaq 0:6c56fb4bc5f0 18
nexpaq 0:6c56fb4bc5f0 19 #include "rpc.h"
nexpaq 0:6c56fb4bc5f0 20
nexpaq 0:6c56fb4bc5f0 21 namespace mbed {
nexpaq 0:6c56fb4bc5f0 22
nexpaq 0:6c56fb4bc5f0 23 class RpcDigitalOut : public RPC {
nexpaq 0:6c56fb4bc5f0 24 public:
nexpaq 0:6c56fb4bc5f0 25 RpcDigitalOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
nexpaq 0:6c56fb4bc5f0 26
nexpaq 0:6c56fb4bc5f0 27 void write(int a0) {o.write(a0);}
nexpaq 0:6c56fb4bc5f0 28 int read(void) {return o.read();}
nexpaq 0:6c56fb4bc5f0 29
nexpaq 0:6c56fb4bc5f0 30 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 31 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 32 {"write", rpc_method_caller<RpcDigitalOut, int, &RpcDigitalOut::write>},
nexpaq 0:6c56fb4bc5f0 33 {"read", rpc_method_caller<int, RpcDigitalOut, &RpcDigitalOut::read>},
nexpaq 0:6c56fb4bc5f0 34 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 35 };
nexpaq 0:6c56fb4bc5f0 36 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 37 }
nexpaq 0:6c56fb4bc5f0 38 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 39 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 40 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalOut, PinName, const char*> >},
nexpaq 0:6c56fb4bc5f0 41 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 42 };
nexpaq 0:6c56fb4bc5f0 43 static rpc_class c = {"DigitalOut", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 44 return &c;
nexpaq 0:6c56fb4bc5f0 45 }
nexpaq 0:6c56fb4bc5f0 46 private:
nexpaq 0:6c56fb4bc5f0 47 DigitalOut o;
nexpaq 0:6c56fb4bc5f0 48 };
nexpaq 0:6c56fb4bc5f0 49
nexpaq 0:6c56fb4bc5f0 50 class RpcDigitalIn : public RPC {
nexpaq 0:6c56fb4bc5f0 51 public:
nexpaq 0:6c56fb4bc5f0 52 RpcDigitalIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
nexpaq 0:6c56fb4bc5f0 53
nexpaq 0:6c56fb4bc5f0 54 int read(void) {return o.read();}
nexpaq 0:6c56fb4bc5f0 55
nexpaq 0:6c56fb4bc5f0 56 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 57 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 58 {"read", rpc_method_caller<int, RpcDigitalIn, &RpcDigitalIn::read>},
nexpaq 0:6c56fb4bc5f0 59 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 60 };
nexpaq 0:6c56fb4bc5f0 61 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 62 }
nexpaq 0:6c56fb4bc5f0 63 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 64 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 65 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalIn, PinName, const char*> >},
nexpaq 0:6c56fb4bc5f0 66 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 67 };
nexpaq 0:6c56fb4bc5f0 68 static rpc_class c = {"DigitalIn", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 69 return &c;
nexpaq 0:6c56fb4bc5f0 70 }
nexpaq 0:6c56fb4bc5f0 71 private:
nexpaq 0:6c56fb4bc5f0 72 DigitalIn o;
nexpaq 0:6c56fb4bc5f0 73 };
nexpaq 0:6c56fb4bc5f0 74
nexpaq 0:6c56fb4bc5f0 75 class RpcDigitalInOut : public RPC {
nexpaq 0:6c56fb4bc5f0 76 public:
nexpaq 0:6c56fb4bc5f0 77 RpcDigitalInOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
nexpaq 0:6c56fb4bc5f0 78
nexpaq 0:6c56fb4bc5f0 79 int read(void) {return o.read();}
nexpaq 0:6c56fb4bc5f0 80 void write(int a0) {o.write(a0);}
nexpaq 0:6c56fb4bc5f0 81 void input(void) {o.input();}
nexpaq 0:6c56fb4bc5f0 82 void output(void) {o.output();}
nexpaq 0:6c56fb4bc5f0 83
nexpaq 0:6c56fb4bc5f0 84 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 85 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 86 {"read", rpc_method_caller<int, RpcDigitalInOut, &RpcDigitalInOut::read>},
nexpaq 0:6c56fb4bc5f0 87 {"write", rpc_method_caller<RpcDigitalInOut, int, &RpcDigitalInOut::write>},
nexpaq 0:6c56fb4bc5f0 88 {"input", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::input>},
nexpaq 0:6c56fb4bc5f0 89 {"output", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::output>},
nexpaq 0:6c56fb4bc5f0 90 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 91 };
nexpaq 0:6c56fb4bc5f0 92 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 93 }
nexpaq 0:6c56fb4bc5f0 94 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 95 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 96 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalInOut, PinName, const char*> >},
nexpaq 0:6c56fb4bc5f0 97 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 98 };
nexpaq 0:6c56fb4bc5f0 99 static rpc_class c = {"DigitalInOut", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 100 return &c;
nexpaq 0:6c56fb4bc5f0 101 }
nexpaq 0:6c56fb4bc5f0 102 private:
nexpaq 0:6c56fb4bc5f0 103 DigitalInOut o;
nexpaq 0:6c56fb4bc5f0 104 };
nexpaq 0:6c56fb4bc5f0 105
nexpaq 0:6c56fb4bc5f0 106 #if DEVICE_ANALOGIN
nexpaq 0:6c56fb4bc5f0 107 class RpcAnalogIn : public RPC {
nexpaq 0:6c56fb4bc5f0 108 public:
nexpaq 0:6c56fb4bc5f0 109 RpcAnalogIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
nexpaq 0:6c56fb4bc5f0 110
nexpaq 0:6c56fb4bc5f0 111 float read(void) {return o.read();}
nexpaq 0:6c56fb4bc5f0 112 unsigned short read_u16(void) {return o.read_u16();}
nexpaq 0:6c56fb4bc5f0 113
nexpaq 0:6c56fb4bc5f0 114 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 115 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 116 {"read", rpc_method_caller<float, RpcAnalogIn, &RpcAnalogIn::read>},
nexpaq 0:6c56fb4bc5f0 117 {"read_u16", rpc_method_caller<unsigned short, RpcAnalogIn, &RpcAnalogIn::read_u16>},
nexpaq 0:6c56fb4bc5f0 118 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 119 };
nexpaq 0:6c56fb4bc5f0 120 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 121 }
nexpaq 0:6c56fb4bc5f0 122 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 123 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 124 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogIn, PinName, const char*> >},
nexpaq 0:6c56fb4bc5f0 125 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 126 };
nexpaq 0:6c56fb4bc5f0 127 static rpc_class c = {"AnalogIn", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 128 return &c;
nexpaq 0:6c56fb4bc5f0 129 }
nexpaq 0:6c56fb4bc5f0 130 private:
nexpaq 0:6c56fb4bc5f0 131 AnalogIn o;
nexpaq 0:6c56fb4bc5f0 132 };
nexpaq 0:6c56fb4bc5f0 133 #endif
nexpaq 0:6c56fb4bc5f0 134
nexpaq 0:6c56fb4bc5f0 135 #if DEVICE_ANALOGOUT
nexpaq 0:6c56fb4bc5f0 136 class RpcAnalogOut : public RPC {
nexpaq 0:6c56fb4bc5f0 137 public:
nexpaq 0:6c56fb4bc5f0 138 RpcAnalogOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
nexpaq 0:6c56fb4bc5f0 139
nexpaq 0:6c56fb4bc5f0 140 float read(void) {return o.read();}
nexpaq 0:6c56fb4bc5f0 141 void write(float a0) {o.write(a0);}
nexpaq 0:6c56fb4bc5f0 142 void write_u16(unsigned short a0) {o.write_u16(a0);}
nexpaq 0:6c56fb4bc5f0 143
nexpaq 0:6c56fb4bc5f0 144 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 145 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 146 {"read", rpc_method_caller<float, RpcAnalogOut, &RpcAnalogOut::read>},
nexpaq 0:6c56fb4bc5f0 147 {"write", rpc_method_caller<RpcAnalogOut, float, &RpcAnalogOut::write>},
nexpaq 0:6c56fb4bc5f0 148 {"write_u16", rpc_method_caller<RpcAnalogOut, unsigned short, &RpcAnalogOut::write_u16>},
nexpaq 0:6c56fb4bc5f0 149 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 150 };
nexpaq 0:6c56fb4bc5f0 151 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 152 }
nexpaq 0:6c56fb4bc5f0 153 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 154 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 155 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogOut, PinName, const char*> >},
nexpaq 0:6c56fb4bc5f0 156 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 157 };
nexpaq 0:6c56fb4bc5f0 158 static rpc_class c = {"AnalogOut", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 159 return &c;
nexpaq 0:6c56fb4bc5f0 160 }
nexpaq 0:6c56fb4bc5f0 161 private:
nexpaq 0:6c56fb4bc5f0 162 AnalogOut o;
nexpaq 0:6c56fb4bc5f0 163 };
nexpaq 0:6c56fb4bc5f0 164 #endif
nexpaq 0:6c56fb4bc5f0 165
nexpaq 0:6c56fb4bc5f0 166 #if DEVICE_PWMOUT
nexpaq 0:6c56fb4bc5f0 167 class RpcPwmOut : public RPC {
nexpaq 0:6c56fb4bc5f0 168 public:
nexpaq 0:6c56fb4bc5f0 169 RpcPwmOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
nexpaq 0:6c56fb4bc5f0 170
nexpaq 0:6c56fb4bc5f0 171 float read(void) {return o.read();}
nexpaq 0:6c56fb4bc5f0 172 void write(float a0) {o.write(a0);}
nexpaq 0:6c56fb4bc5f0 173 void period(float a0) {o.period(a0);}
nexpaq 0:6c56fb4bc5f0 174 void period_ms(int a0) {o.period_ms(a0);}
nexpaq 0:6c56fb4bc5f0 175 void pulsewidth(float a0) {o.pulsewidth(a0);}
nexpaq 0:6c56fb4bc5f0 176 void pulsewidth_ms(int a0) {o.pulsewidth_ms(a0);}
nexpaq 0:6c56fb4bc5f0 177
nexpaq 0:6c56fb4bc5f0 178 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 179 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 180 {"read", rpc_method_caller<float, RpcPwmOut, &RpcPwmOut::read>},
nexpaq 0:6c56fb4bc5f0 181 {"write", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::write>},
nexpaq 0:6c56fb4bc5f0 182 {"period", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::period>},
nexpaq 0:6c56fb4bc5f0 183 {"period_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::period_ms>},
nexpaq 0:6c56fb4bc5f0 184 {"pulsewidth", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::pulsewidth>},
nexpaq 0:6c56fb4bc5f0 185 {"pulsewidth_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::pulsewidth_ms>},
nexpaq 0:6c56fb4bc5f0 186 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 187 };
nexpaq 0:6c56fb4bc5f0 188 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 189 }
nexpaq 0:6c56fb4bc5f0 190 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 191 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 192 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcPwmOut, PinName, const char*> >},
nexpaq 0:6c56fb4bc5f0 193 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 194 };
nexpaq 0:6c56fb4bc5f0 195 static rpc_class c = {"PwmOut", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 196 return &c;
nexpaq 0:6c56fb4bc5f0 197 }
nexpaq 0:6c56fb4bc5f0 198 private:
nexpaq 0:6c56fb4bc5f0 199 PwmOut o;
nexpaq 0:6c56fb4bc5f0 200 };
nexpaq 0:6c56fb4bc5f0 201 #endif
nexpaq 0:6c56fb4bc5f0 202
nexpaq 0:6c56fb4bc5f0 203 #if DEVICE_SPI
nexpaq 0:6c56fb4bc5f0 204 class RpcSPI : public RPC {
nexpaq 0:6c56fb4bc5f0 205 public:
nexpaq 0:6c56fb4bc5f0 206 RpcSPI(PinName a0, PinName a1, PinName a2, const char *name=NULL) : RPC(name), o(a0, a1, a2) {}
nexpaq 0:6c56fb4bc5f0 207
nexpaq 0:6c56fb4bc5f0 208 void format(int a0, int a1) {o.format(a0, a1);}
nexpaq 0:6c56fb4bc5f0 209 void frequency(int a0) {o.frequency(a0);}
nexpaq 0:6c56fb4bc5f0 210 int write(int a0) {return o.write(a0);}
nexpaq 0:6c56fb4bc5f0 211
nexpaq 0:6c56fb4bc5f0 212 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 213 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 214 {"format", rpc_method_caller<RpcSPI, int, int, &RpcSPI::format>},
nexpaq 0:6c56fb4bc5f0 215 {"frequency", rpc_method_caller<RpcSPI, int, &RpcSPI::frequency>},
nexpaq 0:6c56fb4bc5f0 216 {"write", rpc_method_caller<int, RpcSPI, int, &RpcSPI::write>},
nexpaq 0:6c56fb4bc5f0 217 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 218 };
nexpaq 0:6c56fb4bc5f0 219 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 220 }
nexpaq 0:6c56fb4bc5f0 221 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 222 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 223 {"new", rpc_function_caller<const char*, PinName, PinName, PinName, const char*, &RPC::construct<RpcSPI, PinName, PinName, PinName, const char*> >},
nexpaq 0:6c56fb4bc5f0 224 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 225 };
nexpaq 0:6c56fb4bc5f0 226 static rpc_class c = {"SPI", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 227 return &c;
nexpaq 0:6c56fb4bc5f0 228 }
nexpaq 0:6c56fb4bc5f0 229 private:
nexpaq 0:6c56fb4bc5f0 230 SPI o;
nexpaq 0:6c56fb4bc5f0 231 };
nexpaq 0:6c56fb4bc5f0 232 #endif
nexpaq 0:6c56fb4bc5f0 233
nexpaq 0:6c56fb4bc5f0 234 #if DEVICE_SERIAL
nexpaq 0:6c56fb4bc5f0 235 class RpcSerial : public RPC {
nexpaq 0:6c56fb4bc5f0 236 public:
nexpaq 0:6c56fb4bc5f0 237 RpcSerial(PinName a0, PinName a1, const char *name=NULL) : RPC(name), o(a0, a1) {}
nexpaq 0:6c56fb4bc5f0 238
nexpaq 0:6c56fb4bc5f0 239 void baud(int a0) {o.baud(a0);}
nexpaq 0:6c56fb4bc5f0 240 int readable(void) {return o.readable();}
nexpaq 0:6c56fb4bc5f0 241 int writeable(void) {return o.writeable();}
nexpaq 0:6c56fb4bc5f0 242 int putc(int a0) {return o.putc(a0);}
nexpaq 0:6c56fb4bc5f0 243 int getc(void) {return o.getc();}
nexpaq 0:6c56fb4bc5f0 244 int puts(const char * a0) {return o.puts(a0);}
nexpaq 0:6c56fb4bc5f0 245
nexpaq 0:6c56fb4bc5f0 246 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 247 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 248 {"baud", rpc_method_caller<RpcSerial, int, &RpcSerial::baud>},
nexpaq 0:6c56fb4bc5f0 249 {"readable", rpc_method_caller<int, RpcSerial, &RpcSerial::readable>},
nexpaq 0:6c56fb4bc5f0 250 {"writeable", rpc_method_caller<int, RpcSerial, &RpcSerial::writeable>},
nexpaq 0:6c56fb4bc5f0 251 {"putc", rpc_method_caller<int, RpcSerial, int, &RpcSerial::putc>},
nexpaq 0:6c56fb4bc5f0 252 {"getc", rpc_method_caller<int, RpcSerial, &RpcSerial::getc>},
nexpaq 0:6c56fb4bc5f0 253 {"puts", rpc_method_caller<int, RpcSerial, const char *, &RpcSerial::puts>},
nexpaq 0:6c56fb4bc5f0 254 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 255 };
nexpaq 0:6c56fb4bc5f0 256 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 257 }
nexpaq 0:6c56fb4bc5f0 258 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 259 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 260 {"new", rpc_function_caller<const char*, PinName, PinName, const char*, &RPC::construct<RpcSerial, PinName, PinName, const char*> >},
nexpaq 0:6c56fb4bc5f0 261 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 262 };
nexpaq 0:6c56fb4bc5f0 263 static rpc_class c = {"Serial", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 264 return &c;
nexpaq 0:6c56fb4bc5f0 265 }
nexpaq 0:6c56fb4bc5f0 266 private:
nexpaq 0:6c56fb4bc5f0 267 Serial o;
nexpaq 0:6c56fb4bc5f0 268 };
nexpaq 0:6c56fb4bc5f0 269 #endif
nexpaq 0:6c56fb4bc5f0 270
nexpaq 0:6c56fb4bc5f0 271 class RpcTimer : public RPC {
nexpaq 0:6c56fb4bc5f0 272 public:
nexpaq 0:6c56fb4bc5f0 273 RpcTimer(const char *name=NULL) : RPC(name), o() {}
nexpaq 0:6c56fb4bc5f0 274
nexpaq 0:6c56fb4bc5f0 275 void start(void) {o.start();}
nexpaq 0:6c56fb4bc5f0 276 void stop(void) {o.stop();}
nexpaq 0:6c56fb4bc5f0 277 void reset(void) {o.reset();}
nexpaq 0:6c56fb4bc5f0 278 float read(void) {return o.read();}
nexpaq 0:6c56fb4bc5f0 279 int read_ms(void) {return o.read_ms();}
nexpaq 0:6c56fb4bc5f0 280 int read_us(void) {return o.read_us();}
nexpaq 0:6c56fb4bc5f0 281
nexpaq 0:6c56fb4bc5f0 282 virtual const struct rpc_method *get_rpc_methods() {
nexpaq 0:6c56fb4bc5f0 283 static const rpc_method rpc_methods[] = {
nexpaq 0:6c56fb4bc5f0 284 {"start", rpc_method_caller<RpcTimer, &RpcTimer::start>},
nexpaq 0:6c56fb4bc5f0 285 {"stop", rpc_method_caller<RpcTimer, &RpcTimer::stop>},
nexpaq 0:6c56fb4bc5f0 286 {"reset", rpc_method_caller<RpcTimer, &RpcTimer::reset>},
nexpaq 0:6c56fb4bc5f0 287 {"read", rpc_method_caller<float, RpcTimer, &RpcTimer::read>},
nexpaq 0:6c56fb4bc5f0 288 {"read_ms", rpc_method_caller<int, RpcTimer, &RpcTimer::read_ms>},
nexpaq 0:6c56fb4bc5f0 289 {"read_us", rpc_method_caller<int, RpcTimer, &RpcTimer::read_us>},
nexpaq 0:6c56fb4bc5f0 290 RPC_METHOD_SUPER(RPC)
nexpaq 0:6c56fb4bc5f0 291 };
nexpaq 0:6c56fb4bc5f0 292 return rpc_methods;
nexpaq 0:6c56fb4bc5f0 293 }
nexpaq 0:6c56fb4bc5f0 294 static struct rpc_class *get_rpc_class() {
nexpaq 0:6c56fb4bc5f0 295 static const rpc_function funcs[] = {
nexpaq 0:6c56fb4bc5f0 296 {"new", rpc_function_caller<const char*, const char*, &RPC::construct<RpcTimer, const char*> >},
nexpaq 0:6c56fb4bc5f0 297 RPC_METHOD_END
nexpaq 0:6c56fb4bc5f0 298 };
nexpaq 0:6c56fb4bc5f0 299 static rpc_class c = {"Timer", funcs, NULL};
nexpaq 0:6c56fb4bc5f0 300 return &c;
nexpaq 0:6c56fb4bc5f0 301 }
nexpaq 0:6c56fb4bc5f0 302 private:
nexpaq 0:6c56fb4bc5f0 303 Timer o;
nexpaq 0:6c56fb4bc5f0 304 };
nexpaq 0:6c56fb4bc5f0 305
nexpaq 0:6c56fb4bc5f0 306 }
nexpaq 0:6c56fb4bc5f0 307
nexpaq 0:6c56fb4bc5f0 308 #endif