Simple wrapper object for LTC2606 1CH 16Bit DAC. Instantiate DacLtc2606 object instance passing reference to mbed.I2C object instance. Call write() method on DacLtc2606 instance passing 16Bit integer (0 [Off] to 32767/-32768 [Half-On] to -1 [Full-On]) to set DAC output.

Committer:
rkimble
Date:
Thu Sep 13 23:10:35 2012 +0000
Revision:
1:5924632f3344
Parent:
0:896aaf4b80d0
Child:
2:d101ca4ae85e
Initial Release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rkimble 1:5924632f3344 1 /* mbed LTC2606 1CH 16Bit DAC Library
rkimble 1:5924632f3344 2 * Copyright (c) 2012 Reed Kimble, MIT License
rkimble 1:5924632f3344 3 *
rkimble 1:5924632f3344 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
rkimble 1:5924632f3344 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
rkimble 1:5924632f3344 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
rkimble 1:5924632f3344 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
rkimble 1:5924632f3344 8 * furnished to do so, subject to the following conditions:
rkimble 1:5924632f3344 9 *
rkimble 1:5924632f3344 10 * The above copyright notice and this permission notice shall be included in all copies or
rkimble 1:5924632f3344 11 * substantial portions of the Software.
rkimble 1:5924632f3344 12 *
rkimble 1:5924632f3344 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
rkimble 1:5924632f3344 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
rkimble 1:5924632f3344 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
rkimble 1:5924632f3344 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
rkimble 1:5924632f3344 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
rkimble 1:5924632f3344 18 */
rkimble 1:5924632f3344 19
rkimble 1:5924632f3344 20 #ifndef MBED_DACLTC2606_H
rkimble 1:5924632f3344 21 #define MBED_DACLTC2606_H
rkimble 1:5924632f3344 22
rkimble 1:5924632f3344 23 #include "mbed.h"
rkimble 1:5924632f3344 24
rkimble 1:5924632f3344 25 /* I2C DAC controller class
rkimble 1:5924632f3344 26 */
rkimble 1:5924632f3344 27 class DacLtc2606 {
rkimble 1:5924632f3344 28 public:
rkimble 1:5924632f3344 29 /** Create a DacLtc2606 object using to the specified I2C object
rkimble 1:5924632f3344 30 *
rkimble 1:5924632f3344 31 * @param i2c The I2C object to communicate with
rkimble 1:5924632f3344 32 */
rkimble 1:5924632f3344 33 DacLtc2606(I2C i2c);
rkimble 1:5924632f3344 34
rkimble 1:5924632f3344 35 /** Set the DAC output to the specifed integer value
rkimble 1:5924632f3344 36 *
rkimble 1:5924632f3344 37 * @param value The 16 bit integer to write (0 to 32767 to -32768 to -1)
rkimble 1:5924632f3344 38 */
rkimble 1:5924632f3344 39 bool write(int value);
rkimble 1:5924632f3344 40
rkimble 1:5924632f3344 41 /** Set the DAC output to the specified percentage of max
rkimble 1:5924632f3344 42 *
rkimble 1:5924632f3344 43 * @param percent A double from 0.0 to 1.0 representing the percent of max output power on the DAC
rkimble 1:5924632f3344 44 */
rkimble 1:5924632f3344 45 bool write(double percent);
rkimble 1:5924632f3344 46
rkimble 1:5924632f3344 47 private:
rkimble 1:5924632f3344 48 static const char _slave = 0xE4;
rkimble 1:5924632f3344 49 static const char _command = 0x30;
rkimble 1:5924632f3344 50 I2C _i2c;
rkimble 1:5924632f3344 51 };
rkimble 1:5924632f3344 52
rkimble 0:896aaf4b80d0 53 #endif