int eeprom_save(void) { printf("Saving EEPROM data by 16 bytes pages...\n"); // load eeprom by pages of 32 bytes each int counter = 0; 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); // write data for (int j = 0; j < 16; j++) { i2c_send(eeprom_map[counter++]); } I2C_GenerateSTOP(I2C1, ENABLE); while (!(I2C1->SR1 & I2C_SR1_BTF)) { uint8_t data = I2C1->DR; data++; } // wait for EEPROM to catch bytes delay_ms(20); early_putc('*'); } printf("\nDone.\n"); return 0; }
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; }
static void bcm_cfe_eputc(int c) { unsigned char ch; int handle; ch = (unsigned char) c; /* bcm_get_platform() cannot be used here, as we may be called * from bcm_init_platform_data(). */ if ((handle = bcm_platform_data.cfe_console) < 0) return; if (ch == '\n') early_putc('\r'); while ((cfe_write(handle, &ch, 1)) == 0) continue; }
static int avr_early_putc(char c, FILE *stream) { early_putc(c); return 0; }