Bus Stop
You inherited firmware for a board with two SPI sensors: an accelerometer on SPI1 (CS on PA4) and a gyroscope on SPI2 (CS on PA5). Both use standard SPI register reads: send the register address with the read bit set (address | 0x80), then clock in the response with a dummy byte.
The accelerometer's WHO_AM_I register is at 0x75 and the gyroscope's CHIP_ID register is at 0x00. On the reference board they return 0x68 and 0xD1, but grading also runs with substitute parts that report different IDs (0x71 and 0xA3), so perform the same reads regardless of the values that come back and do not hardcode the responses.
A colleague got device A working but the code for device B was never finished properly. The board prints nothing and hangs. Find and fix all the bugs so both sensors are read correctly.
Expected SPI transactions (reference board): SPI1: MOSI [0xF5, 0x00] -> MISO [0xFF, 0x68] SPI2: MOSI [0x80, 0x00] -> MISO [0xFF, 0xD1]
Constraints:
- PA4 is active-low CS for device A (SPI1), PA5 for device B (SPI2)
- SPI1 clock is on APB2 (RCC APB2ENR bit 12)
- SPI2 clock is on APB1 (RCC APB1ENR bit 14)