Interface to Analog devices AD5258 digital I2C potentiometer
Revision 2:8a71db02417b, committed 2013-11-12
- Comitter:
- RodColeman
- Date:
- Tue Nov 12 12:57:07 2013 +0000
- Parent:
- 1:64570234d7b5
- Child:
- 3:f5b60d166896
- Commit message:
- v4.29: first release with RF Detect I2C trimmer (manual only)
Changed in this revision
| AD5258.cpp | Show annotated file Show diff for this revision Revisions of this file |
| AD5258.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/AD5258.cpp Mon Nov 11 13:08:08 2013 +0000
+++ b/AD5258.cpp Tue Nov 12 12:57:07 2013 +0000
@@ -54,4 +54,17 @@
foo[0] = 0xA0; // command to store RDAC to EE
foo[1] = 0x80; // NOP to restore low power mode
_i2c.write(_address, foo, 1);
+ }
+
+ // software write protect
+ void AD5258::writeProtect(bool enable) {
+ char foo[2];
+ foo[0] = 0x40; // command to store RDAC to EE
+ if (enable) {
+ foo[1] = 0x01; // SET WP
+ }
+ else {
+ foo[1] = 0x010; // RESET WP (enable writes)
+ }
+ _i2c.write(_address, foo, 2);
}
\ No newline at end of file
--- a/AD5258.h Mon Nov 11 13:08:08 2013 +0000
+++ b/AD5258.h Tue Nov 12 12:57:07 2013 +0000
@@ -3,7 +3,21 @@
#ifndef MBED_AD5258_H
#define MBED_AD5258_H
-// Interface to the AD5258 I2C 6-Bit digital Potentiometer
+// Interface to the AD5258 I2C 64-step (0x00 to 0x3F)6-Bit digital Potentiometer
+
+// measure reference voltage on the pin6 of U3 LM293
+// be sure to remove R11, and check R4 is 220
+
+/*Examples: RDAC =
+0x00, Vref=1,0V
+0x03, Vref=1,1V
+0x05, Vref=1,2V
+0x0F, Vref=1,5V
+0x20, Vref=1,82V // default
+0x30, Vref=2,0V
+0x3F, Vref=2,2V
+*/
+
class AD5258 {
public:
@@ -55,6 +69,17 @@
*
*/
void restore(void);
+
+
+ /** update write protect bit
+ *
+ * @param enable: TRUE to SET WP, FALSE to lift WP
+ */
+
+ void writeProtect(bool enable);
+
+ // TODO: tolerance register access
+
private: