1 /* mbed Microcontroller Library - AnalogOut
2 * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
6 #ifndef MBED_ANALOGOUT_H
7 #define MBED_ANALOGOUT_H
11 #include "PeripheralNames.h"
17 * An analog output, used for setting the voltage on a pin
20 * > // Make a sawtooth output
24 * > AnalogOut tri(p18);
35 class AnalogOut : public Base {
39 /* Constructor: AnalogOut
40 * Create an AnalogOut connected to the specified pin
43 * pin - AnalogOut pin to connect to (18)
45 AnalogOut(PinName pin, const char *name = NULL);
48 * Set the output voltage, specified as a percentage (float)
51 * percent - A floating-point value representing the output voltage,
52 * specified as a percentage. The value should lie between
53 * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
54 * Values outside this range will be saturated to 0.0f or 1.0f.
56 void write(float value);
58 /* Function: write_u16
59 * Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
62 * value - 16-bit unsigned short representing the output voltage,
63 * normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)
65 void write_u16(unsigned short value);
68 * Return the current output voltage setting, measured as a percentage (float)
71 * returns - A floating-point value representing the current voltage being output on the pin,
72 * measured as a percentage. The returned value will lie between
73 * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
76 * This value may not match exactly the value set by a previous <write>.
82 /* Function: operator=
83 * An operator shorthand for <write()>
85 AnalogOut& operator= (float percent);
86 AnalogOut& operator= (AnalogOut& rhs);
88 /* Function: operator float()
89 * An operator shorthand for <read()>
95 virtual const struct rpc_method *get_rpc_methods();
96 static struct rpc_class *get_rpc_class();