int eeprom_load(void) { printf("Loading EEPROM data by 16 bytes pages...\n"); // load eeprom by pages of 16 bytes each int counter = 0x00; for (int i = 0; i < CONFIG_EEPROM_SIZE / 16; i++) { // set address i2c_start(I2C_Direction_Transmitter, CONFIG_EEPROM_ADDRESS); i2c_send(counter >> 8); i2c_send(counter & 0xFF); // read data i2c_restart(I2C_Direction_Receiver, CONFIG_EEPROM_ADDRESS); for (int j = 0; j < 15; j++) { eeprom_map[counter++] = i2c_recv_ack(); } // stop condition eeprom_map[counter++] = i2c_recv_nack(); early_putc('*'); } printf("\nDone.\n"); return 0; }
void i2c_send_byte(unsigned char dat) { unsigned char i; for(i = 0; i < 8; i++) { if((dat << i) & 0x80) { SDA_HIGH ; } else { SDA_LOW ; } i2c_delay() ; SCL_HIGH ; i2c_delay() ; SCL_LOW ; } i2c_recv_ack(); }