Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
eeprom.cpp
00001 // eeprom.cpp file 00002 #include "eeprom.h" 00003 00004 00005 00006 void freq(uint32_t frec) 00007 { 00008 i2c.frequency(frec); 00009 } 00010 00011 int write_data(uint8_t eepr_addr, uint16_t address, uint8_t *ptr_string) 00012 { 00013 wait_ms(4); 00014 i2c.start(); 00015 int ack=i2c.write(eepr_addr<<1); 00016 if(ack==1) { 00017 i2c.write(address<<8); 00018 i2c.write(address); 00019 for(int i =0; i<4 ;i++) { 00020 i2c.write(ptr_string[i]); 00021 } 00022 i2c.stop(); 00023 return 1;//success 00024 } else if(ack==0) { 00025 return 0;//NACK 00026 } else if(ack==2) { 00027 return 2;//TIMEOUT 00028 } 00029 return -1; 00030 } 00031 00032 00033 uint8_t data_read(uint8_t eepr_addr, uint16_t address_read) 00034 { 00035 wait_ms(5); 00036 uint8_t read; 00037 i2c.start(); 00038 int ack=i2c.write(eepr_addr<<1); 00039 //pc.printf("ack= %d \n",ack); 00040 if(ack==1) { 00041 i2c.write(address_read<<8); 00042 i2c.write(address_read); 00043 i2c.start(); 00044 i2c.write(eepr_addr<<1|0x01); 00045 read=i2c.read(0); 00046 i2c.stop(); 00047 return read; 00048 } 00049 return -1; 00050 }
Generated on Tue Aug 23 2022 14:03:57 by
1.7.2