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