code to access the AT30TSE75x temperature and E-prom device
Dependents: AT30TSE752TST AT30TSE752TST2
AT30TSE75x.h@1:c0db18a0c56b, 2017-01-17 (annotated)
- Committer:
- wbeaumont
- Date:
- Tue Jan 17 13:43:08 2017 +0000
- Revision:
- 1:c0db18a0c56b
- Parent:
- 0:7cb648bc5c2a
- Child:
- 2:91836ad02096
ee-prom write protect
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 | 1:c0db18a0c56b | 12 | #define VERSION_AT30TSE75x_HDR "0.86" |
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 | 1:c0db18a0c56b | 24 | * version 0.86 : added ee-prom write protect mode tested ( un-protect not tested) |
wbeaumont | 0:7cb648bc5c2a | 25 | * this code is only tested with the AT30TSE752 version ( 2 KBit version) |
wbeaumont | 1:c0db18a0c56b | 26 | * |
wbeaumont | 1:c0db18a0c56b | 27 | * processor board for the testing : FRDM-KL25Z |
wbeaumont | 0:7cb648bc5c2a | 28 | * |
wbeaumont | 0:7cb648bc5c2a | 29 | * (C) Wim Beaumont Universiteit Antwerpen 2016, 2017 |
wbeaumont | 0:7cb648bc5c2a | 30 | * |
wbeaumont | 0:7cb648bc5c2a | 31 | */ |
wbeaumont | 0:7cb648bc5c2a | 32 | class AT30TSE75x : public virtual getVersion { |
wbeaumont | 0:7cb648bc5c2a | 33 | uint8_t buffer[4]; |
wbeaumont | 0:7cb648bc5c2a | 34 | int Taddr, Eaddr; // base address for temperature and eeprom |
wbeaumont | 0:7cb648bc5c2a | 35 | int Esize; |
wbeaumont | 0:7cb648bc5c2a | 36 | int resolution; |
wbeaumont | 0:7cb648bc5c2a | 37 | protected: |
wbeaumont | 0:7cb648bc5c2a | 38 | /** pointer to the I2C interface driver. */ |
wbeaumont | 0:7cb648bc5c2a | 39 | I2CInterface* _i2c; |
wbeaumont | 0:7cb648bc5c2a | 40 | public: |
wbeaumont | 0:7cb648bc5c2a | 41 | AT30TSE75x (I2CInterface* i2cinterface, int device_address_bits, int eepromsize=2); |
wbeaumont | 0:7cb648bc5c2a | 42 | int getTaddr(){ return Taddr;}; |
wbeaumont | 0:7cb648bc5c2a | 43 | int getEaddr(){ return Eaddr;}; |
wbeaumont | 0:7cb648bc5c2a | 44 | float get_temperature(int *error = 0); |
wbeaumont | 0:7cb648bc5c2a | 45 | int set_config( int Nonvolatille=0 ); |
wbeaumont | 0:7cb648bc5c2a | 46 | int read_config( int Nonvolatille=0, int *error = 0 ); |
wbeaumont | 0:7cb648bc5c2a | 47 | // max lenght =16 for 1 page. If word =0 |
wbeaumont | 0:7cb648bc5c2a | 48 | int read_eeprompage(char *data, uint8_t length, uint8_t word_addr, uint8_t page); |
wbeaumont | 0:7cb648bc5c2a | 49 | int write_eeprompage(char *data, uint8_t length, uint8_t word_addr, uint8_t page); |
wbeaumont | 0:7cb648bc5c2a | 50 | // read a single byte from ee prom |
wbeaumont | 0:7cb648bc5c2a | 51 | int read_eeprombyte(char &data, uint8_t word_addr, uint8_t page); |
wbeaumont | 0:7cb648bc5c2a | 52 | int write_eeprombyte(char data, uint8_t word_addr, uint8_t page); |
wbeaumont | 1:c0db18a0c56b | 53 | // set ee-prom in read only mode special voltage on A0 is needed and A1 and A2 shoud be low. |
wbeaumont | 1:c0db18a0c56b | 54 | int protect_eeprom(void); |
wbeaumont | 1:c0db18a0c56b | 55 | // set ee-prom in read only mode special voltage on A0 and A1 should be high , A2 should be low |
wbeaumont | 1:c0db18a0c56b | 56 | int unprotect_eeprom(void); |
wbeaumont | 1:c0db18a0c56b | 57 | // returns I2C err ( NACK) in case protected , else ACK ( no error =0) |
wbeaumont | 1:c0db18a0c56b | 58 | int get_eeprom_protec(void); |
wbeaumont | 0:7cb648bc5c2a | 59 | |
wbeaumont | 0:7cb648bc5c2a | 60 | }; |
wbeaumont | 0:7cb648bc5c2a | 61 | |
wbeaumont | 0:7cb648bc5c2a | 62 | #endif |