28.8.1.3.2 Workflow

  1. Create a buffer to hold a single emulated EEPROM page of memory, and read out logical EEPROM page zero into it.
    uint8_t page_data[EEPROM_PAGE_SIZE];
    eeprom_emulator_read_page(0, page_data);
    
  2. Toggle the first byte of the read page.
    page_data[0] = !page_data[0];
    
  3. Output the toggled LED state onto the board LED.
    port_pin_set_output_level(LED_0_PIN, page_data[0]);
    
  4. Write the modified page back to logical EEPROM page zero, flushing the internal emulator write cache afterwards to ensure it is immediately written to physical non-volatile memory.
    eeprom_emulator_write_page(0, page_data);
    eeprom_emulator_commit_page_buffer();
    
  5. Modify data and write back to logical EEPROM page zero. The data is not committed and should call eeprom_emulator_commit_page_buffer to ensure that any outstanding cache data is fully written to prevent data loss when detecting a BOD early warning.
    page_data[1]=0x1;
    eeprom_emulator_write_page(0, page_data);