Interface to Analog devices AD5258 digital I2C potentiometer

Committer:
RodColeman
Date:
Mon Nov 11 13:08:08 2013 +0000
Revision:
1:64570234d7b5
Parent:
0:8920c7d857d8
Child:
2:8a71db02417b
Add EEPROM access modes, and store/restore

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RodColeman 0:8920c7d857d8 1 #include "mbed.h"
RodColeman 0:8920c7d857d8 2
RodColeman 0:8920c7d857d8 3 #ifndef MBED_AD5258_H
RodColeman 0:8920c7d857d8 4 #define MBED_AD5258_H
RodColeman 0:8920c7d857d8 5
RodColeman 0:8920c7d857d8 6 // Interface to the AD5258 I2C 6-Bit digital Potentiometer
RodColeman 0:8920c7d857d8 7
RodColeman 0:8920c7d857d8 8 class AD5258 {
RodColeman 0:8920c7d857d8 9 public:
RodColeman 0:8920c7d857d8 10 /** Create an instance of the AD5258 connected to specfied I2C pins, with the specified address.
RodColeman 0:8920c7d857d8 11 *
RodColeman 0:8920c7d857d8 12 * @param sda The I2C data pin
RodColeman 0:8920c7d857d8 13 * @param scl The I2C clock pin
RodColeman 0:8920c7d857d8 14 * @param address The I2C address for this AD5258
RodColeman 0:8920c7d857d8 15 */
RodColeman 0:8920c7d857d8 16 AD5258(PinName sda, PinName scl, int address);
RodColeman 0:8920c7d857d8 17
RodColeman 0:8920c7d857d8 18 /** Read the RDAC value
RodColeman 0:8920c7d857d8 19 *
RodColeman 0:8920c7d857d8 20 * @return The 6-bit value read
RodColeman 0:8920c7d857d8 21 */
RodColeman 0:8920c7d857d8 22 int read();
RodColeman 0:8920c7d857d8 23
RodColeman 1:64570234d7b5 24 /** Write to the RDAC
RodColeman 0:8920c7d857d8 25 *
RodColeman 0:8920c7d857d8 26 * @param data The 6-bits value: 0x00 to 0x3F to write to the pots RDAC
RodColeman 0:8920c7d857d8 27 */
RodColeman 0:8920c7d857d8 28 void write(int data);
RodColeman 1:64570234d7b5 29
RodColeman 1:64570234d7b5 30 // READ and WRITE EEPROM
RodColeman 1:64570234d7b5 31
RodColeman 1:64570234d7b5 32 /** Read the EEPROM value
RodColeman 1:64570234d7b5 33 *
RodColeman 1:64570234d7b5 34 * @return The 6-bit value read
RodColeman 1:64570234d7b5 35 */
RodColeman 1:64570234d7b5 36 int readEE();
RodColeman 1:64570234d7b5 37
RodColeman 1:64570234d7b5 38 /** Write to the RDAC
RodColeman 1:64570234d7b5 39 *
RodColeman 1:64570234d7b5 40 * @param data The 6-bits value: 0x00 to 0x3F to write to the pots RDAC
RodColeman 1:64570234d7b5 41 */
RodColeman 1:64570234d7b5 42 void writeEE(int data);
RodColeman 1:64570234d7b5 43
RodColeman 1:64570234d7b5 44
RodColeman 1:64570234d7b5 45
RodColeman 1:64570234d7b5 46
RodColeman 1:64570234d7b5 47 // STORE and RESTORE:
RodColeman 1:64570234d7b5 48
RodColeman 1:64570234d7b5 49 /** store the RDAC value into the EEPROM, for nonvolatile keeping of the value
RodColeman 1:64570234d7b5 50 *
RodColeman 1:64570234d7b5 51 */
RodColeman 1:64570234d7b5 52 void store(void);
RodColeman 1:64570234d7b5 53
RodColeman 1:64570234d7b5 54 /** restore to the RDAC the value from the EEPROM. NOP issued afterward, to put back into low-power idle mode
RodColeman 1:64570234d7b5 55 *
RodColeman 1:64570234d7b5 56 */
RodColeman 1:64570234d7b5 57 void restore(void);
RodColeman 1:64570234d7b5 58
RodColeman 0:8920c7d857d8 59
RodColeman 0:8920c7d857d8 60 private:
RodColeman 0:8920c7d857d8 61 I2C _i2c;
RodColeman 0:8920c7d857d8 62 int _address;
RodColeman 0:8920c7d857d8 63 };
RodColeman 0:8920c7d857d8 64
RodColeman 0:8920c7d857d8 65 #endif