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