Orcino
Joined: 07 Sep 2003 Posts: 56
|
VAR 32 in lib linear_24LC512 |
Posted: Thu Nov 13, 2008 12:08 pm |
|
|
Hi,
in code linear_24lc512 listed below, how write a var 32 bits ?
Thanks.
Orcino
Code: | //////////////////////////////////////////////////////////////////////////////////
//// Library for lineal address to a bank of 8 24LC512 chip memory ////
//// ////
//// 0 to 0x07FFF ////
//// //// ////
//// init_24512x8(); Call before the other functions are used ////
//// ////
//// writeByte24512x8(a,d); Write the byte (int8)d to the address (int32)a ////
//// ////
//// d=ReadByte24512x8(a); Read the byte int8)d from the address (int32)a ////
//// ////
//// ////
///////////////////////////////////////////////////////////////////////////////////
//#ifndef EEPROM_SDA
//#define EEPROM_SDA PIN_B0
//#define EEPROM_SCL PIN_B1
//#endif
//#use i2c(master,slow,sda=PIN_B0,scl=PIN_B1,force_hw)
#define MULTIPLE_EEPROM_ADDRESS int32
#define EEPROM_SIZE 524288
void init_ext_eeprom()
{
output_float(PIN_B0);
output_float(PIN_B1);
}
void writeByte_24512x8(int32 memaddress, int8 data){
int16 address;
int8 controlbyte;
short int status;
address=memaddress;
controlbyte=(0xa0 | ((make8(memaddress,2))<<1));
i2c_start();
i2c_write(controlbyte);
i2c_write(address>>8);
i2c_write(address);
i2c_write(data);
i2c_stop();
// AckNolege pooling
i2c_start();
status=i2c_write(controlbyte);
while(status==1)
{
i2c_start();
status=i2c_write(controlbyte);
}
i2c_stop();
}
int8 readByte_24512x8(int32 memaddress){
int16 address;
int8 controlbyte;
int8 data;
address=memaddress;
controlbyte=(0xa0 | ((make8(memaddress,2))<<1));
i2c_start();
i2c_write(controlbyte);
i2c_write(address>>8);
i2c_write(address);
i2c_start();
i2c_write(controlbyte|1);
data=i2c_read(0);
i2c_stop();
return data;
} |
|
|