![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
for checking multiple SOLID T sensors
Dependencies: DevInterfaces AT30TSE75x I2Cinterfaces
Fork of AT30TSE752TST by
Diff: main.cpp
- Revision:
- 3:789bc6653f83
- Parent:
- 2:8ce5a2128381
- Child:
- 4:576303494244
--- a/main.cpp Fri Jan 13 12:28:09 2017 +0000 +++ b/main.cpp Tue Jan 17 13:44:20 2017 +0000 @@ -7,7 +7,7 @@ * (C) Wim Beaumont Universiteit Antwerpen 2017 */ -#define AT30TSE753EXAMPLEVER "0.40" +#define AT30TSE753EXAMPLEVER "0.56" #include "mbed.h" @@ -49,15 +49,21 @@ } -int main(void) { - char str1[16] = "SOLID Temp"; - char write_eprom= 'n'; +int main(void) { //432109876543210 \0 + char str1[16] = "SOLTEMPERAT0230"; + char str2[16] ; + char str3[16]= "20170116...0230" ; + char resp[3]; // get the version of getVersion getVersion gv; int addr=0; + int i2cerr; + int cnt=0; + printf("AT30TSE752 example program version %s, compile date %s time %s\n\r",AT30TSE753EXAMPLEVER,__DATE__,__TIME__); printf("getVersion :%s\n\r ",gv.getversioninfo()); printf("%s\n\r",str1); + printf("give new addr "); scanf("%d", &addr); if ( addr < 0 || addr > 15) addr=0; fflush(stdin); @@ -65,28 +71,51 @@ AT30TSE75x tid( i2cdev ,addr); printf ( "AT30SE75x version :%s\n\r ",tid.getversioninfo()); printf( "Taddr %x , Eaddr %x subaddr %d\n\r ", tid.getTaddr(),tid.getEaddr(), addr); + i2cerr=tid.get_eeprom_protec(); + if ( i2cerr ) { printf("ee-prom write protected \n\r");} + else { printf("ee-prom NOT write protected \n\r"); } - int cnt=0; - int i2cerr; + + i2cerr=tid.set_config(); if( i2cerr) printf("config not set %d \n\r", i2cerr); int configrd= tid.read_config( 0, &i2cerr); printf( " config %x I2cerr %d \n\r", configrd,i2cerr ); - printf("write to eprom ?"); scanf("%c",&write_eprom); - int pagenr=0;write_eprom = 'y'; - if(write_eprom == 'y'){ - printf("\n\rgive pagenr"); - scanf("%d",&pagenr); - i2cerr= tid.write_eeprompage(str1, 16, 0, (uint8_t) pagenr); + printf("write to eprom ?"); scanf("%s",resp); + int pagenr=0; + int sernr; + if(resp[0] == 'y'){ + i2cerr= tid.write_eeprompage(str1, 16, 0, (uint8_t) pagenr++); if(i2cerr) printf("eeprom write error %d\n\r",i2cerr); + printf("give serial nr to write "); scanf("%d",&sernr); + sprintf(str2,"%015d",sernr); + i2cerr= tid.write_eeprompage(str2, 16, 0, (uint8_t) pagenr++); + wait_ms(400); // give some time to write + i2cerr= tid.write_eeprompage(str3, 16, 0, (uint8_t) pagenr); } wait_ms(400); // give some time to write + //strcpy(str1,"newstr1");strcp(str2,"newstr2");strcp(str3,"newstr3"); + bool fix=true; while(1) { - i2cerr=tid.read_eeprompage(str1, 16, 0, (uint8_t) pagenr); + pagenr=0; + i2cerr=tid.read_eeprompage(str1, 16, 0, (uint8_t) pagenr++); + if(i2cerr) printf("eeprom read error %d \n\r",i2cerr); + + i2cerr=tid.read_eeprompage(str2, 16, 0, (uint8_t) pagenr++); + if(i2cerr) printf("eeprom read error %d \n\r",i2cerr); + i2cerr=tid.read_eeprompage(str3, 16, 0, (uint8_t) pagenr); if(i2cerr) printf("eeprom read error %d \n\r",i2cerr); - str1[15]='\0'; //make sure it ends - printf("eeprom content page %d :\n\r %s\n\r",pagenr,str1); + str1[15]='\0';str2[15]='\0';str3[15]='\0'; //make sure it ends + printf("eeprom content page %d :\n\r %s %s %s \n\r",pagenr,str1 ,str2 ,str3 ); //print_buf_hex( str1,16); + if ( fix) { + printf("protect eeprom ?") ; scanf("%s",resp); + if(resp[0] == 'y'){ + i2cerr=tid.protect_eeprom(); + if(i2cerr) printf("eeprom protect failed %d \n\r", i2cerr); + } + // fix=false; + } char singlechar; i2cerr=tid.read_eeprombyte(singlechar, 3, (uint8_t) pagenr); if(i2cerr) printf("eeprom read error %d \n\r",i2cerr);