Interface to Analog devices AD5258 digital I2C potentiometer
AD5258.h@0:8920c7d857d8, 2013-11-11 (annotated)
- Committer:
- RodColeman
- Date:
- Mon Nov 11 11:00:35 2013 +0000
- Revision:
- 0:8920c7d857d8
- Child:
- 1:64570234d7b5
Initial untested version
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:8920c7d857d8 | 24 | /** Write to the IO pins |
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 | 0:8920c7d857d8 | 29 | |
RodColeman | 0:8920c7d857d8 | 30 | private: |
RodColeman | 0:8920c7d857d8 | 31 | I2C _i2c; |
RodColeman | 0:8920c7d857d8 | 32 | int _address; |
RodColeman | 0:8920c7d857d8 | 33 | }; |
RodColeman | 0:8920c7d857d8 | 34 | |
RodColeman | 0:8920c7d857d8 | 35 | #endif |