export commit

Committer:
rcflyair
Date:
Tue Nov 27 15:54:07 2018 +0000
Revision:
17:5434a91ea334
Parent:
1:6919289a5946
pinout change for stm32f303k8

Who changed what in which revision?

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