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