/* * Copyright (c) 2014 by Bertrand VANDEPORTAELE * TLV5637 library for arduino. * * This file is free software; you can redistribute it and/or modify * it under the terms of either the GNU General Public License version 2 * or the GNU Lesser General Public License version 2.1, both as * published by the Free Software Foundation. */ // For details on the sensor, see: // www.ti.com/cn/lit/gpn/tlv5637 #ifndef _TLV5637_H_INCLUDED #define _TLV5637_H_INCLUDED #include #include #include // the sensor communicates using SPI, so include the library: #include #define REF_EXTERNAL_TLV5637 0 #define REF_1024MV_TLV5637 1 #define REF_2048MV_TLV5637 2 class TLV5637 { public: TLV5637(uint8_t PIN_CS_init,uint8_t REF_init); void powerOn(); //this method should be called before any other in order to initialize the SPI bus void powerOff(); void speedFast(); void speedSlow(); void setRef(uint8_t REF_init); void writeDACA(uint16_t Value); //also update DACB with value in the buffer void writeDACB(uint16_t Value); //also update buffer value void writeDACAB(uint16_t ValueA,uint16_t ValueB); private: void writetlv5637(uint8_t R, uint16_t Value); uint8_t SPD; uint8_t PWR; uint8_t REF; uint8_t PIN_CS; }; #endif