Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
AD5258.h
00001 /* Copyright 2013 Rod Coleman 00002 00003 This program is free software: you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation, either version 3 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 */ 00016 00017 #include "mbed.h" 00018 00019 #ifndef MBED_AD5258_H 00020 #define MBED_AD5258_H 00021 00022 // Interface to the AD5258 I2C 64-step (0x00 to 0x3F)6-Bit digital Potentiometer 00023 00024 // measure reference voltage on the pin6 of U3 LM293 00025 // be sure to remove R11, and check R4 is 220 00026 00027 /*Examples: RDAC = 00028 0x00, Vref=1,0V 00029 0x03, Vref=1,1V 00030 0x05, Vref=1,2V 00031 0x0F, Vref=1,5V 00032 0x20, Vref=1,82V // default 00033 0x30, Vref=2,0V 00034 0x3F, Vref=2,2V 00035 */ 00036 00037 00038 class AD5258 { 00039 public: 00040 /** Create an instance of the AD5258 connected to specfied I2C pins, with the specified address. 00041 * 00042 * @param sda The I2C data pin 00043 * @param scl The I2C clock pin 00044 * @param address The I2C address for this AD5258 00045 */ 00046 AD5258(PinName sda, PinName scl, int address); 00047 00048 /** Read the RDAC value 00049 * 00050 * @return The 6-bit value read 00051 */ 00052 int read(); 00053 00054 /** Write to the RDAC 00055 * 00056 * @param data The 6-bits value: 0x00 to 0x3F to write to the pots RDAC 00057 */ 00058 void write(int data); 00059 00060 // READ and WRITE EEPROM 00061 00062 /** Read the EEPROM value 00063 * 00064 * @return The 6-bit value read 00065 */ 00066 int readEE(); 00067 00068 /** Write to the RDAC 00069 * 00070 * @param data The 6-bits value: 0x00 to 0x3F to write to the pots RDAC 00071 */ 00072 void writeEE(int data); 00073 00074 00075 00076 00077 // STORE and RESTORE: 00078 00079 /** store the RDAC value into the EEPROM, for nonvolatile keeping of the value 00080 * 00081 */ 00082 void store(void); 00083 00084 /** restore to the RDAC the value from the EEPROM. NOP issued afterward, to put back into low-power idle mode 00085 * 00086 */ 00087 void restore(void); 00088 00089 00090 /** update write protect bit 00091 * 00092 * @param enable: TRUE to SET WP, FALSE to lift WP 00093 */ 00094 00095 void writeProtect(bool enable); 00096 00097 // TODO: tolerance register access 00098 00099 00100 00101 private: 00102 I2C _i2c; 00103 int _address; 00104 }; 00105 00106 #endif
Generated on Wed Jul 27 2022 13:18:50 by
1.7.2