int32_t EEPROM_Read(uint8_t* dest, uint32_t startpos, uint32_t len) { int32_t retval=0; if(startpos<256 && dest && len && len<=256) { uint8_t offset=(uint8_t)startpos; retval = I2C_Xfer(EEADDR, &offset, 1, 0); // Set address pointer to startpos if(!retval) retval = I2C_Xfer(EEADDR | 1, dest, len, 1); // Read requested data } return retval; }
void I2C_Init( void ) { uint8_t dummybyte; I20SCLL = I20SCLH = PCLKFREQ / I2CSPEED / 2; I20CONCLR = 0xff; I20CONSET = (1<<6); // I2EN I2C_Xfer(0xff,&dummybyte,0,1); // Dummy initial xfer }