SD card interface

Committer:
lharoon
Date:
Mon Oct 08 11:14:07 2012 +0000
Revision:
0:22612ae617a0
1st edition

Who changed what in which revision?

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