code to access the AT30TSE75x temperature and E-prom device
Dependents: AT30TSE752TST AT30TSE752TST2
AT30TSE75x.h@0:7cb648bc5c2a, 2017-01-13 (annotated)
- Committer:
- wbeaumont
- Date:
- Fri Jan 13 12:11:55 2017 +0000
- Revision:
- 0:7cb648bc5c2a
- Child:
- 1:c0db18a0c56b
read temperature / r/w eeprom
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wbeaumont | 0:7cb648bc5c2a | 1 | #ifndef AT30TSE75x_H |
wbeaumont | 0:7cb648bc5c2a | 2 | #define AT30TSE75x_H |
wbeaumont | 0:7cb648bc5c2a | 3 | #include "getVersion.h" |
wbeaumont | 0:7cb648bc5c2a | 4 | |
wbeaumont | 0:7cb648bc5c2a | 5 | #include "stdbool.h" |
wbeaumont | 0:7cb648bc5c2a | 6 | |
wbeaumont | 0:7cb648bc5c2a | 7 | |
wbeaumont | 0:7cb648bc5c2a | 8 | #include "dev_interface_def.h" |
wbeaumont | 0:7cb648bc5c2a | 9 | #include "I2CInterface.h" |
wbeaumont | 0:7cb648bc5c2a | 10 | |
wbeaumont | 0:7cb648bc5c2a | 11 | |
wbeaumont | 0:7cb648bc5c2a | 12 | #define VERSION_AT30TSE75x_HDR "0.80" |
wbeaumont | 0:7cb648bc5c2a | 13 | |
wbeaumont | 0:7cb648bc5c2a | 14 | /** AT30TSE75x class. |
wbeaumont | 0:7cb648bc5c2a | 15 | * Used for interfacing with a AT30TSE75x temperature sensor and ee-prom |
wbeaumont | 0:7cb648bc5c2a | 16 | * For version 0.1 inital |
wbeaumont | 0:7cb648bc5c2a | 17 | * It has to be used with the https://developer.mbed.org/users/wbeaumont/code/DevInterfaces/ package |
wbeaumont | 0:7cb648bc5c2a | 18 | * This includes the "virtual" I2CInterface class that is the interface to the I2C device |
wbeaumont | 0:7cb648bc5c2a | 19 | * An implementation of the I2Cinterface class for the MBED can be found at |
wbeaumont | 0:7cb648bc5c2a | 20 | * https://developer.mbed.org/users/wbeaumont/code/I2Cinterfaces/ |
wbeaumont | 0:7cb648bc5c2a | 21 | * ee-prom set / read not tested / implemented. |
wbeaumont | 0:7cb648bc5c2a | 22 | * version 0.8 : read of temperature 12 bits, fixed configuration |
wbeaumont | 0:7cb648bc5c2a | 23 | * read /write ee-prom |
wbeaumont | 0:7cb648bc5c2a | 24 | * this code is only tested with the AT30TSE752 version ( 2 KBit version) |
wbeaumont | 0:7cb648bc5c2a | 25 | * processor for the testing : FRDM-KL25Z |
wbeaumont | 0:7cb648bc5c2a | 26 | * |
wbeaumont | 0:7cb648bc5c2a | 27 | * (C) Wim Beaumont Universiteit Antwerpen 2016, 2017 |
wbeaumont | 0:7cb648bc5c2a | 28 | * |
wbeaumont | 0:7cb648bc5c2a | 29 | */ |
wbeaumont | 0:7cb648bc5c2a | 30 | class AT30TSE75x : public virtual getVersion { |
wbeaumont | 0:7cb648bc5c2a | 31 | uint8_t buffer[4]; |
wbeaumont | 0:7cb648bc5c2a | 32 | int Taddr, Eaddr; // base address for temperature and eeprom |
wbeaumont | 0:7cb648bc5c2a | 33 | int Esize; |
wbeaumont | 0:7cb648bc5c2a | 34 | int resolution; |
wbeaumont | 0:7cb648bc5c2a | 35 | protected: |
wbeaumont | 0:7cb648bc5c2a | 36 | /** pointer to the I2C interface driver. */ |
wbeaumont | 0:7cb648bc5c2a | 37 | I2CInterface* _i2c; |
wbeaumont | 0:7cb648bc5c2a | 38 | public: |
wbeaumont | 0:7cb648bc5c2a | 39 | AT30TSE75x (I2CInterface* i2cinterface, int device_address_bits, int eepromsize=2); |
wbeaumont | 0:7cb648bc5c2a | 40 | int getTaddr(){ return Taddr;}; |
wbeaumont | 0:7cb648bc5c2a | 41 | int getEaddr(){ return Eaddr;}; |
wbeaumont | 0:7cb648bc5c2a | 42 | float get_temperature(int *error = 0); |
wbeaumont | 0:7cb648bc5c2a | 43 | int set_config( int Nonvolatille=0 ); |
wbeaumont | 0:7cb648bc5c2a | 44 | int read_config( int Nonvolatille=0, int *error = 0 ); |
wbeaumont | 0:7cb648bc5c2a | 45 | // max lenght =16 for 1 page. If word =0 |
wbeaumont | 0:7cb648bc5c2a | 46 | int read_eeprompage(char *data, uint8_t length, uint8_t word_addr, uint8_t page); |
wbeaumont | 0:7cb648bc5c2a | 47 | int write_eeprompage(char *data, uint8_t length, uint8_t word_addr, uint8_t page); |
wbeaumont | 0:7cb648bc5c2a | 48 | // read a single byte from ee prom |
wbeaumont | 0:7cb648bc5c2a | 49 | int read_eeprombyte(char &data, uint8_t word_addr, uint8_t page); |
wbeaumont | 0:7cb648bc5c2a | 50 | int write_eeprombyte(char data, uint8_t word_addr, uint8_t page); |
wbeaumont | 0:7cb648bc5c2a | 51 | |
wbeaumont | 0:7cb648bc5c2a | 52 | |
wbeaumont | 0:7cb648bc5c2a | 53 | }; |
wbeaumont | 0:7cb648bc5c2a | 54 | |
wbeaumont | 0:7cb648bc5c2a | 55 | #endif |