Archive
A small EEPROM (AT24C02-style) is connected to I2C1 at slave address 0x48. It has 4 pages at register addresses 0x00 through 0x03, each storing one byte.
Your firmware receives data bytes over UART1 (9600, 8N1). Each received byte must be written to the EEPROM in round-robin order: first byte to page 0, second to page 1, ..., fifth wraps back to page 0, and so on.
An EEPROM byte write is a single I2C write transaction: START, slave address (0x48) + W, register address (page number), data byte, STOP.
A terminating byte of 0xFF signals end-of-input (do not write 0xFF to the EEPROM). After receiving 0xFF, read back the last page that was written and print the result over UART:
PAGE:<page> DATA:<hex>
where <page> is the 0-indexed page number (0 through 3) and <hex> is the data byte as two uppercase hex digits.
Example: receiving five bytes (four data bytes then the 0xFF terminator) writes the four values to pages 0 through 3 in turn. Whatever the fourth data byte was, it landed on page 3, so the readback reports:
PAGE:3 DATA:<hex>
The starter code provides register definitions, UART helpers, and the round-robin main loop. You need to implement i2c_init() plus the eeprom_write_byte() and eeprom_read_byte() I2C transactions.
Note: the EEPROM model answers readbacks from its own stored contents, which are chosen fresh for every submission — they will not necessarily match the bytes you sent. Report what the device returns over the bus: only an honest I2C read produces the right answer. A memorized reply, or an echo of the byte your firmware remembers writing, will not match.