Persistence
A colleague's environmental monitor reads an I2C temperature sensor at address 0x48. The sensor is mounted on a long flex cable and occasionally NACKs due to electrical noise; reads return 0xFF when this happens.
Your task: implement a bounded retry loop with exponential backoff. On each failed read (0xFF), wait longer before trying again. The delay should double with each attempt, starting at a base delay. Stop after 10 total attempts.
After the retry loop, report the outcome via UART:
If a valid reading was obtained: OK:<attempt_number> where attempt_number is 1-based (first attempt = 1).
If all 10 attempts returned 0xFF: FAIL
Each output line must end with a newline character (\n); output is matched exactly.
I2C initialization and a single-byte register read helper are provided. UART helpers (init, putc, puts, print_int) are also provided. You need to write the retry loop in main() and report the result.
The sensor's temperature register is at address 0x00. A valid temperature is never 0xFF.
Implement real exponential backoff, not just the retry count and the bound -- on a noisy bus, hammering the sensor back-to-back is what keeps a flaky line from ever settling.