Simvik

Check the chips on the board

Read every expected chip's ID register and report missing or wrong parts. An easy embedded C problem (Board bring-up, step by step), run and graded in the…

easy · Board bring-up, step by step · bring-up · i2c · self-test

Part of a power-on self-test: check that every chip the board should have is there and is the right part. Write post_check(parts, n), which for each part, in order, reads its ID register and prints one line:

  • <name>: ok if the ID matches,
  • <name>: no answer if the read fails,
  • <name>: wrong id 0xXX, expected 0xYY if a different ID comes back (two uppercase hex digits each),

and returns the number of parts that failed.

Starter code

int post_check(const part_t *parts, int n) {
  for (int i = 0; i < n; i++) printf("%s: ok\n", parts[i].name);
  return 0;
}

Example tests

A good board

fit(0x76, 0xD0, 0x60);
fit(0x18, 0x0F, 0x33);
fit(0x68, 0x75, 0x68);
printf("%d failed\n", post_check(BOARD, 3));

Expected output:

BME280: ok
LIS3DH: ok
MPU-6050: ok
0 failed

Learn it first

More Board bring-up, step by step problems