-
Notifications
You must be signed in to change notification settings - Fork 1
tests: Add board qualification test for I2C bus scan. #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nedseb
merged 4 commits into
feature/board-qualification-framework
from
feature/board-i2c-scan
Mar 13, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e56ada4
tests: Add board qualification test for I2C bus scan.
nedseb 58277d9
tests: Return missing/unexpected addresses for better diagnostics.
nedseb c407145
tests: Fix I2C scan addresses and add WHO_AM_I checks per device.
nedseb cd07701
tests: Add LIS2MDL to expected I2C addresses list.
nedseb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| type: board | ||
| name: "board_i2c_scan" | ||
|
|
||
| tests: | ||
| - name: "I2C bus scan finds expected devices" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C, Pin | ||
| # Release MCP23009E from reset so it responds to scan | ||
| rst = Pin("RST_EXPANDER", Pin.OUT) | ||
| rst.on() | ||
| from time import sleep_ms | ||
| sleep_ms(10) | ||
| i2c = I2C(1) | ||
| found = i2c.scan() | ||
| # Expected I2C addresses on STeaMi board (7-bit): | ||
| # 0x1E=LIS2MDL, 0x20=MCP23009E, 0x29=VL53L1X, 0x39=APDS9960 | ||
| # 0x3B=STM32F103CB, 0x55=BQ27441, 0x5D=WSEN-PADS | ||
| # 0x5F=HTS221/WSEN-HIDS, 0x6B=ISM330DL | ||
| expected = [0x1E, 0x20, 0x29, 0x39, 0x3B, 0x55, 0x5D, 0x5F, 0x6B] | ||
| missing = sorted([hex(a) for a in expected if a not in found]) | ||
| result = missing | ||
| expect: [] | ||
| mode: [hardware] | ||
|
|
||
| - name: "No unexpected I2C devices" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C, Pin | ||
| rst = Pin("RST_EXPANDER", Pin.OUT) | ||
| rst.on() | ||
| from time import sleep_ms | ||
| sleep_ms(10) | ||
| i2c = I2C(1) | ||
| found = i2c.scan() | ||
| known = [0x1E, 0x20, 0x29, 0x39, 0x3B, 0x55, 0x5D, 0x5F, 0x6B] | ||
| unexpected = sorted([hex(a) for a in found if a not in known]) | ||
| result = unexpected | ||
| expect: [] | ||
| mode: [hardware] | ||
|
|
||
| # --- WHO_AM_I / Device ID checks --- | ||
| # Each test reads the identification register of one component. | ||
|
|
||
|
nedseb marked this conversation as resolved.
|
||
| - name: "LIS2MDL WHO_AM_I (0x1E)" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C | ||
| i2c = I2C(1) | ||
| result = i2c.readfrom_mem(0x1E, 0x4F, 1)[0] | ||
| expect: 0x40 | ||
| mode: [hardware] | ||
|
|
||
| - name: "MCP23009E IODIR default (0x20)" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C, Pin | ||
| rst = Pin("RST_EXPANDER", Pin.OUT) | ||
| rst.on() | ||
| from time import sleep_ms | ||
| sleep_ms(10) | ||
| i2c = I2C(1) | ||
| # IODIR register default value after reset = 0xFF (all inputs) | ||
| result = i2c.readfrom_mem(0x20, 0x00, 1)[0] | ||
| expect: 0xFF | ||
| mode: [hardware] | ||
|
|
||
| - name: "VL53L1X model ID (0x29)" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C | ||
| i2c = I2C(1) | ||
| data = i2c.readfrom_mem(0x29, 0x010F, 2, addrsize=16) | ||
| result = (data[0] << 8) | data[1] | ||
| expect: 0xEACC | ||
| mode: [hardware] | ||
|
|
||
| - name: "APDS9960 device ID (0x39)" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C | ||
| i2c = I2C(1) | ||
| result = i2c.readfrom_mem(0x39, 0x92, 1)[0] | ||
| expect: 0xAB | ||
| mode: [hardware] | ||
|
|
||
| - name: "WSEN-PADS device ID (0x5D)" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C | ||
| i2c = I2C(1) | ||
| result = i2c.readfrom_mem(0x5D, 0x0F, 1)[0] | ||
| expect: 0xB3 | ||
| mode: [hardware] | ||
|
|
||
| - name: "HTS221/WSEN-HIDS device ID (0x5F)" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C | ||
| i2c = I2C(1) | ||
| result = i2c.readfrom_mem(0x5F, 0x0F, 1)[0] | ||
| expect: 0xBC | ||
| mode: [hardware] | ||
|
|
||
| - name: "ISM330DL WHO_AM_I (0x6B)" | ||
| action: hardware_script | ||
| script: | | ||
| from machine import I2C | ||
| i2c = I2C(1) | ||
| result = i2c.readfrom_mem(0x6B, 0x0F, 1)[0] | ||
| expect: 0x6A | ||
| mode: [hardware] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.