Fallback

You inherited firmware for an environmental monitor. An I2C temperature sensor (address 0x48) is polled 5 times at startup. The firmware should track the last valid reading and print the result via USART1.

The sensor occasionally returns out-of-range values: hardware noise, a supply glitch, a connector seating issue. Valid temperatures are in the range 0-85 degrees C. Anything above 85 from this sensor is a malformed reading and should be discarded.

If at least one valid reading was received, print the last valid temperature: TEMP:<value>

If no valid reading was ever received during the 5 polls, print the safe sentinel instead: TEMP:SAFE

The starter code compiles without warnings but produces incorrect output under fault conditions. Find and fix all the bugs.

Loading the interactive arena.