strat des robots

Fork of CRAC-Strat_2017 by CRAC Team

Committer:
ClementBreteau
Date:
Fri May 19 17:14:07 2017 +0000
Revision:
17:d1594579eec6
Parent:
0:ad97421fb1fb
strat du robot, 19-05-2017, 19h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
antbig 0:ad97421fb1fb 1 /* mbed Microcontroller Library - AnalogOut
antbig 0:ad97421fb1fb 2 * Copyright (c) 2006-2011 ARM Limited. All rights reserved.
antbig 0:ad97421fb1fb 3 */
antbig 0:ad97421fb1fb 4
antbig 0:ad97421fb1fb 5 #ifndef MBED_ANALOGOUT_H
antbig 0:ad97421fb1fb 6 #define MBED_ANALOGOUT_H
antbig 0:ad97421fb1fb 7
antbig 0:ad97421fb1fb 8 #include "device.h"
antbig 0:ad97421fb1fb 9
antbig 0:ad97421fb1fb 10 #if DEVICE_ANALOGOUT
antbig 0:ad97421fb1fb 11
antbig 0:ad97421fb1fb 12 #include "platform.h"
antbig 0:ad97421fb1fb 13 #include "PinNames.h"
antbig 0:ad97421fb1fb 14 #include "PeripheralNames.h"
antbig 0:ad97421fb1fb 15 #include "Base.h"
antbig 0:ad97421fb1fb 16
antbig 0:ad97421fb1fb 17 namespace mbed {
antbig 0:ad97421fb1fb 18
antbig 0:ad97421fb1fb 19 /* Class: AnalogOut
antbig 0:ad97421fb1fb 20 * An analog output, used for setting the voltage on a pin
antbig 0:ad97421fb1fb 21 *
antbig 0:ad97421fb1fb 22 * Example:
antbig 0:ad97421fb1fb 23 * > // Make a sawtooth output
antbig 0:ad97421fb1fb 24 * >
antbig 0:ad97421fb1fb 25 * > #include "mbed.h"
antbig 0:ad97421fb1fb 26 * >
antbig 0:ad97421fb1fb 27 * > AnalogOut tri(p18);
antbig 0:ad97421fb1fb 28 * > int main() {
antbig 0:ad97421fb1fb 29 * > while(1) {
antbig 0:ad97421fb1fb 30 * > tri = tri + 0.01;
antbig 0:ad97421fb1fb 31 * > wait_us(1);
antbig 0:ad97421fb1fb 32 * > if(tri == 1) {
antbig 0:ad97421fb1fb 33 * > tri = 0;
antbig 0:ad97421fb1fb 34 * > }
antbig 0:ad97421fb1fb 35 * > }
antbig 0:ad97421fb1fb 36 * > }
antbig 0:ad97421fb1fb 37 */
antbig 0:ad97421fb1fb 38 class AnalogOut : public Base {
antbig 0:ad97421fb1fb 39
antbig 0:ad97421fb1fb 40 public:
antbig 0:ad97421fb1fb 41
antbig 0:ad97421fb1fb 42 /* Constructor: AnalogOut
antbig 0:ad97421fb1fb 43 * Create an AnalogOut connected to the specified pin
antbig 0:ad97421fb1fb 44 *
antbig 0:ad97421fb1fb 45 * Variables:
antbig 0:ad97421fb1fb 46 * pin - AnalogOut pin to connect to (18)
antbig 0:ad97421fb1fb 47 */
antbig 0:ad97421fb1fb 48 AnalogOut(PinName pin, const char *name = NULL);
antbig 0:ad97421fb1fb 49
antbig 0:ad97421fb1fb 50 /* Function: write
antbig 0:ad97421fb1fb 51 * Set the output voltage, specified as a percentage (float)
antbig 0:ad97421fb1fb 52 *
antbig 0:ad97421fb1fb 53 * Variables:
antbig 0:ad97421fb1fb 54 * percent - A floating-point value representing the output voltage,
antbig 0:ad97421fb1fb 55 * specified as a percentage. The value should lie between
antbig 0:ad97421fb1fb 56 * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
antbig 0:ad97421fb1fb 57 * Values outside this range will be saturated to 0.0f or 1.0f.
antbig 0:ad97421fb1fb 58 */
antbig 0:ad97421fb1fb 59 void write(float value);
antbig 0:ad97421fb1fb 60
antbig 0:ad97421fb1fb 61 /* Function: write_u16
antbig 0:ad97421fb1fb 62 * Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
antbig 0:ad97421fb1fb 63 *
antbig 0:ad97421fb1fb 64 * Variables:
antbig 0:ad97421fb1fb 65 * value - 16-bit unsigned short representing the output voltage,
antbig 0:ad97421fb1fb 66 * normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)
antbig 0:ad97421fb1fb 67 */
antbig 0:ad97421fb1fb 68 void write_u16(unsigned short value);
antbig 0:ad97421fb1fb 69
antbig 0:ad97421fb1fb 70 /* Function: read
antbig 0:ad97421fb1fb 71 * Return the current output voltage setting, measured as a percentage (float)
antbig 0:ad97421fb1fb 72 *
antbig 0:ad97421fb1fb 73 * Variables:
antbig 0:ad97421fb1fb 74 * returns - A floating-point value representing the current voltage being output on the pin,
antbig 0:ad97421fb1fb 75 * measured as a percentage. The returned value will lie between
antbig 0:ad97421fb1fb 76 * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
antbig 0:ad97421fb1fb 77 *
antbig 0:ad97421fb1fb 78 * Note:
antbig 0:ad97421fb1fb 79 * This value may not match exactly the value set by a previous <write>.
antbig 0:ad97421fb1fb 80 */
antbig 0:ad97421fb1fb 81 float read();
antbig 0:ad97421fb1fb 82
antbig 0:ad97421fb1fb 83
antbig 0:ad97421fb1fb 84 #ifdef MBED_OPERATORS
antbig 0:ad97421fb1fb 85 /* Function: operator=
antbig 0:ad97421fb1fb 86 * An operator shorthand for <write()>
antbig 0:ad97421fb1fb 87 */
antbig 0:ad97421fb1fb 88 AnalogOut& operator= (float percent);
antbig 0:ad97421fb1fb 89 AnalogOut& operator= (AnalogOut& rhs);
antbig 0:ad97421fb1fb 90
antbig 0:ad97421fb1fb 91 /* Function: operator float()
antbig 0:ad97421fb1fb 92 * An operator shorthand for <read()>
antbig 0:ad97421fb1fb 93 */
antbig 0:ad97421fb1fb 94 operator float();
antbig 0:ad97421fb1fb 95 #endif
antbig 0:ad97421fb1fb 96
antbig 0:ad97421fb1fb 97 #ifdef MBED_RPC
antbig 0:ad97421fb1fb 98 virtual const struct rpc_method *get_rpc_methods();
antbig 0:ad97421fb1fb 99 static struct rpc_class *get_rpc_class();
antbig 0:ad97421fb1fb 100 #endif
antbig 0:ad97421fb1fb 101
antbig 0:ad97421fb1fb 102 protected:
antbig 0:ad97421fb1fb 103
antbig 0:ad97421fb1fb 104 DACName _dac;
antbig 0:ad97421fb1fb 105
antbig 0:ad97421fb1fb 106 };
antbig 0:ad97421fb1fb 107
antbig 0:ad97421fb1fb 108 } // namespace mbed
antbig 0:ad97421fb1fb 109
antbig 0:ad97421fb1fb 110 #endif
antbig 0:ad97421fb1fb 111
antbig 0:ad97421fb1fb 112 #endif