void I2CMEM_writeData(unsigned int addr,unsigned char num,unsigned char* buf)
{
unsigned char Haddr=0;
//unsigned char upbyte = 0,lowbyte = 0;
Haddr = (unsigned char)((addr & 0xFF00));
while(!(I2CMEM_idle()));
I2CMEM_start();
I2CMEM_writeByte(MEMWRITE);
I2CMEM_writeByte(Haddr);
I2CMEM_writeByte((unsigned char)(addr & 0x00FF));
while(num--)
{
//upbyte = (unsigned char)(((*buf)&(0xFF00))>>8);
//lowbyte = (unsigned char)((*buf)&(0x00FF));
I2CMEM_writeByte(*buf);
//I2CMEM_writeByte(lowbyte);
//I2CRTC_nak();
buf++;
}
I2CMEM_stop();
}
void I2CMEM_readData(unsigned int addr,unsigned char num,unsigned char *ptrtemp)
{
unsigned char Haddr = 0;
Haddr = (unsigned char)((addr & 0xFF00));
while(!(I2CMEM_idle()));
I2CMEM_start();
I2CMEM_writeByte(MEMWRITE);
// device address with write operation
I2CMEM_writeByte(Haddr); // Higher Byte of the address
I2CMEM_writeByte((unsigned char)(addr & 0x00FF)); // Lower Byte of
//the address
I2CMEM_start();
I2CMEM_writeByte(MEMREAD);
while(num--)
{
if(num > 0)
{
*ptrtemp = I2CMEM_readByte(ACK);
//*ptrtemp = (((*ptrtemp)<<8)|I2CMEM_readByte(ACK));
ptrtemp++;
}
else
{
*ptrtemp = I2CMEM_readByte(NO_ACK);
//*ptrtemp = (((*ptrtemp)<8)|I2CMEM_readByte(NO_ACK));
}
}
//I2CMEM_nak();
I2CMEM_stop();
}