2013-10-15 14:18:00 -04:00
|
|
|
//
|
|
|
|
// FILE: AD524X.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2016-04-10 14:23:28 -04:00
|
|
|
// VERSION: 0.1.03
|
2013-10-15 15:42:24 -04:00
|
|
|
// PURPOSE: I2C digital PotentioMeter AD5241 AD5242
|
2013-10-15 14:18:00 -04:00
|
|
|
// DATE: 2013-10-12
|
|
|
|
// URL:
|
|
|
|
//
|
|
|
|
// Released to the public domain
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef AD524X_h
|
|
|
|
#define AD524X_h
|
|
|
|
|
|
|
|
#if defined(ARDUINO) && ARDUINO >= 100
|
|
|
|
#include "Arduino.h"
|
|
|
|
#else
|
|
|
|
#include "WProgram.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <Wire.h>
|
|
|
|
|
2016-04-10 14:23:28 -04:00
|
|
|
#define AD524X_VERSION "0.1.03"
|
2013-10-15 14:18:00 -04:00
|
|
|
|
|
|
|
#define AS524X_OK 0
|
2016-04-10 14:23:28 -04:00
|
|
|
#define AS524X_ERROR 100
|
2013-10-15 14:18:00 -04:00
|
|
|
|
|
|
|
class AD524X
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// address
|
2016-04-10 14:23:28 -04:00
|
|
|
explicit AD524X(const uint8_t);
|
|
|
|
|
2013-10-15 15:42:24 -04:00
|
|
|
uint8_t zeroAll();
|
|
|
|
// rdac
|
2015-03-06 08:40:36 -05:00
|
|
|
uint8_t read(const uint8_t);
|
2016-04-10 14:23:28 -04:00
|
|
|
// for debugging
|
|
|
|
uint8_t readBackRegister(); // returns the last value written in register.
|
|
|
|
|
2013-10-15 14:18:00 -04:00
|
|
|
// rdac value
|
2015-03-06 08:40:36 -05:00
|
|
|
uint8_t write(const uint8_t, const uint8_t);
|
2013-10-15 14:18:00 -04:00
|
|
|
// rdac value O1 O2
|
2015-03-06 08:40:36 -05:00
|
|
|
uint8_t write(const uint8_t, const uint8_t, const uint8_t, const uint8_t);
|
2016-04-10 14:23:28 -04:00
|
|
|
|
2015-03-06 08:40:36 -05:00
|
|
|
uint8_t setO1(const uint8_t); // HIGH / LOW
|
|
|
|
uint8_t setO2(const uint8_t); // HIGH / LOW
|
2013-10-15 15:42:24 -04:00
|
|
|
uint8_t getO1();
|
|
|
|
uint8_t getO2();
|
2016-04-10 14:23:28 -04:00
|
|
|
|
2013-10-15 14:18:00 -04:00
|
|
|
// rdac
|
2015-03-06 08:40:36 -05:00
|
|
|
uint8_t midScaleReset(const uint8_t);
|
2013-10-15 14:18:00 -04:00
|
|
|
//
|
|
|
|
// uint8_t shutDown();
|
|
|
|
|
|
|
|
private:
|
2015-03-06 08:40:36 -05:00
|
|
|
uint8_t send(const uint8_t, const uint8_t); // cmd value
|
2013-10-15 14:18:00 -04:00
|
|
|
|
|
|
|
uint8_t _address;
|
|
|
|
uint8_t _lastValue[2];
|
|
|
|
uint8_t _O1;
|
|
|
|
uint8_t _O2;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// -- END OF FILE --
|