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.
EEPROM24LC01.cpp
00001 /* 00002 *************************************************************************** 00003 * File Name : EEPROM24LC01.cpp 00004 * 00005 * Revision : 1.0 00006 * Notes : 00007 * Target Board : mbed LPC824 00008 * 00009 * Revision History: 00010 *************************************************************************** 00011 */ 00012 #include "EEPROM24LC01.h" 00013 #include "mbed.h" 00014 00015 EEPROM24LC01::EEPROM24LC01(I2C *i2c, const int address): 00016 _i2c_address(address<<1), _i2c(i2c) 00017 { 00018 } 00019 00020 int EEPROM24LC01::byte8_write(char *data) 00021 { 00022 int res; 00023 char buf[9]; 00024 int i = 0; 00025 00026 buf[0] = 0; // Address 00027 00028 for(i=0;i<8;++i){ 00029 buf[i+1] = data[i]; 00030 } 00031 /* buf[1] = data[0]; 00032 buf[2] = data[1]; 00033 buf[3] = data[2]; 00034 buf[4] = data[3]; 00035 buf[5] = data[4]; 00036 buf[6] = data[5]; 00037 buf[7] = data[6]; 00038 buf[8] = data[7]; 00039 */ 00040 res = _i2c->write(_i2c_address, buf, sizeof(buf), false); 00041 00042 wait_ms(5); // 5mS 00043 00044 return res; 00045 } 00046 00047 00048 int EEPROM24LC01::readAll( char *data, int size ) 00049 { 00050 int res; 00051 char buf[1]; 00052 00053 buf[0] = 0; // Read Address High byte set 00054 res = _i2c->write(_i2c_address, buf, sizeof(buf), true); 00055 res = _i2c->read(_i2c_address, (char *)data, size, false); 00056 00057 return res; 00058 }
Generated on Tue Sep 6 2022 04:45:48 by
1.7.2