code to access the AT30TSE75x temperature and E-prom device
Dependents: AT30TSE752TST AT30TSE752TST2
Diff: AT30TSE75x.h
- Revision:
- 0:7cb648bc5c2a
- Child:
- 1:c0db18a0c56b
diff -r 000000000000 -r 7cb648bc5c2a AT30TSE75x.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AT30TSE75x.h Fri Jan 13 12:11:55 2017 +0000 @@ -0,0 +1,55 @@ +#ifndef AT30TSE75x_H +#define AT30TSE75x_H +#include "getVersion.h" + +#include "stdbool.h" + + +#include "dev_interface_def.h" +#include "I2CInterface.h" + + +#define VERSION_AT30TSE75x_HDR "0.80" + +/** AT30TSE75x class. + * Used for interfacing with a AT30TSE75x temperature sensor and ee-prom + * For version 0.1 inital + * It has to be used with the https://developer.mbed.org/users/wbeaumont/code/DevInterfaces/ package + * This includes the "virtual" I2CInterface class that is the interface to the I2C device + * An implementation of the I2Cinterface class for the MBED can be found at + * https://developer.mbed.org/users/wbeaumont/code/I2Cinterfaces/ + * ee-prom set / read not tested / implemented. + * version 0.8 : read of temperature 12 bits, fixed configuration + * read /write ee-prom + * this code is only tested with the AT30TSE752 version ( 2 KBit version) + * processor for the testing : FRDM-KL25Z + * + * (C) Wim Beaumont Universiteit Antwerpen 2016, 2017 + * + */ +class AT30TSE75x : public virtual getVersion { + uint8_t buffer[4]; + int Taddr, Eaddr; // base address for temperature and eeprom + int Esize; + int resolution; + protected: + /** pointer to the I2C interface driver. */ + I2CInterface* _i2c; + public: + AT30TSE75x (I2CInterface* i2cinterface, int device_address_bits, int eepromsize=2); + int getTaddr(){ return Taddr;}; + int getEaddr(){ return Eaddr;}; + float get_temperature(int *error = 0); + int set_config( int Nonvolatille=0 ); + int read_config( int Nonvolatille=0, int *error = 0 ); + // max lenght =16 for 1 page. If word =0 + int read_eeprompage(char *data, uint8_t length, uint8_t word_addr, uint8_t page); + int write_eeprompage(char *data, uint8_t length, uint8_t word_addr, uint8_t page); + // read a single byte from ee prom + int read_eeprombyte(char &data, uint8_t word_addr, uint8_t page); + int write_eeprombyte(char data, uint8_t word_addr, uint8_t page); + + + }; + + #endif \ No newline at end of file