I2C EEPROM

Source code can be downloaded from source:/Examples/I2C_EEPROM

Description
This demo shows writing to/reading the I2C EEPROM memory.

Init
1     SystemInit();
2     CGU_Init();
Init SysTick to 1ms
1     SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / 1000);
2
3     AT24_Init();   
Prepare buffer
1     for (i = 0; i < sizeof(writeBuffer); i++)
2     {
3         writeBuffer[i] = i;
4     }
Write page
1     AT24_Write(SLA, baseaddr, 1, writeBuffer, sizeof(writeBuffer));
2     DelayMs(10); // wait  
3
4     while (1)
5     {
Clear read buffer
1    for (i = 0; i < sizeof(writeBuffer); i++)
2    {
3        readBuffer[i] = ~writeBuffer[i];
4    }
Read data back
1    AT24_Read(SLA, baseaddr, 1, readBuffer, sizeof(readBuffer));
Verify
1    for (i = 0; i < sizeof(writeBuffer); i++)
2    {
3        if ( writeBuffer[i] != readBuffer[i])
4        {
5            while (1);  // catch th error
6        }
7    }

Undefined