code to access the AT30TSE75x temperature and E-prom device

Dependents:   AT30TSE752TST AT30TSE752TST2

AT30TSE75x.h

Committer:
wbeaumont
Date:
2017-01-17
Revision:
1:c0db18a0c56b
Parent:
0:7cb648bc5c2a
Child:
2:91836ad02096

File content as of revision 1:c0db18a0c56b:

#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.86"

/** 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 
 *  version 0.86 : added ee-prom write protect mode tested  ( un-protect not tested)
 *  this code is only tested with the AT30TSE752  version ( 2 KBit version) 
 * 
 *  processor board  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);
    // set ee-prom in read only  mode special voltage on A0 is needed  and A1 and A2 shoud be low.
    int protect_eeprom(void);
    // set ee-prom in read only  mode special voltage on A0 and  A1 should be high , A2 should be low
    int unprotect_eeprom(void);
    // returns I2C err ( NACK) in case protected  , else ACK ( no error =0) 
    int get_eeprom_protec(void);
    
 };
 
 #endif