Skip to content

Commit 9bec6a1

Browse files
authored
Adding I2C HIL test (#2023)
* i2c hil test * pin * fmt * Test * WIP (gpio test left) * Finalize the CODE part (to be cleaned up) fmt * Smaller cleanup * cleanup * rebase * fix * getting last chips ready * Addressing reviews
1 parent b7b916f commit 9bec6a1

23 files changed

+352
-209
lines changed

hil-test/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ harness = false
5151
name = "interrupt"
5252
harness = false
5353

54+
[[test]]
55+
name = "i2c"
56+
harness = false
57+
5458
[[test]]
5559
name = "i2s"
5660
harness = false

hil-test/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,39 @@ The [`hil.yml`] workflow builds the test suite for all our available targets and
6868
Our self-hosted runners have the following setup:
6969
- ESP32-C2 (`esp32c2-jtag`):
7070
- Devkit: `ESP8684-DevKitM-1` connected via UART.
71+
- `GPIO18` and `GPIO9` are I2C pins.
7172
- `GPIO2` and `GPIO3` are connected.
7273
- Probe: `ESP-Prog` connected with the [following connections][connection_c2]
7374
- RPi: Raspbian 12 configured with the following [setup]
7475
- ESP32-C3 (`rustboard`):
7576
- Devkit: `ESP32-C3-DevKit-RUST-1` connected via USB-Serial-JTAG.
77+
- `GPIO4` and `GPIO5` are I2C pins.
7678
- `GPIO2` and `GPIO3` are connected.
77-
- `GPIO5` and `GPIO6` are connected.
7879
- RPi: Raspbian 12 configured with the following [setup]
7980
- ESP32-C6 (`esp32c6-usb`):
8081
- Devkit: `ESP32-C6-DevKitC-1 V1.2` connected via USB-Serial-JTAG (`USB` port).
82+
- `GPIO6` and `GPIO7` are I2C pins.
8183
- `GPIO2` and `GPIO3` are connected.
82-
- `GPIO5` and `GPIO6` are connected.
84+
- `GPIO4` and `GPIO5` are connected.
8385
- RPi: Raspbian 12 configured with the following [setup]
8486
- ESP32-H2 (`esp32h2-usb`):
8587
- Devkit: `ESP32-H2-DevKitM-1` connected via USB-Serial-JTAG (`USB` port).
88+
- `GPIO12` and `GPIO22` are I2C pins.
8689
- `GPIO2` and `GPIO3` are connected.
87-
- `GPIO5` and `GPIO8` are connected.
90+
- `GPIO4` and `GPIO5` are connected.
8891
- RPi: Raspbian 12 configured with the following [setup]
8992
- ESP32-S2 (`esp32s2-jtag`):
9093
- Devkit: `ESP32-S2-Saola-1` connected via UART.
91-
- `GPIO2` and `GPIO3` are connected.
92-
- `GPIO5` and `GPIO6` are connected.
94+
- `GPIO2` and `GPIO3` are I2C pins.
95+
- `GPIO9` and `GPIO10` are connected.
9396
- Probe: `ESP-Prog` connected with the [following connections][connection_s2]
9497
- RPi: Raspbian 12 configured with the following [setup]
9598
- ESP32-S3 (`esp32s3-usb`):
9699
- Devkit: `ESP32-S3-DevKitC-1` connected via USB-Serial-JTAG.
97-
- `GPIO2` and `GPIO3` are connected.
98-
- `GPIO5` and `GPIO6` are connected.
100+
- `GPIO2` and `GPIO3` are I2C pins.
101+
- `GPIO4` and `GPIO5` are connected.
99102
- `GPIO1` and `GPIO21` are connected.
103+
- `GPIO9` and `GPIO10` are connected.
100104
- `GPIO43 (TX)` and `GPIO45` are connected.
101105
- RPi: Raspbian 12 configured with the following [setup]
102106

hil-test/src/lib.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,37 @@ unsafe impl defmt::Logger for Logger {
2222
use defmt_rtt as _;
2323
// Make sure esp_backtrace is not removed.
2424
use esp_backtrace as _;
25+
26+
#[macro_export]
27+
macro_rules! i2c_pins {
28+
($io:expr) => {{
29+
// Order: (SDA, SCL)
30+
cfg_if::cfg_if! {
31+
if #[cfg(any(esp32s2, esp32s3))] {
32+
($io.pins.gpio2, $io.pins.gpio3)
33+
} else if #[cfg(esp32c6)] {
34+
($io.pins.gpio6, $io.pins.gpio7)
35+
} else if #[cfg(esp32h2)] {
36+
($io.pins.gpio12, $io.pins.gpio22)
37+
} else if #[cfg(esp32c2)] {
38+
($io.pins.gpio18, $io.pins.gpio9)
39+
} else {
40+
($io.pins.gpio4, $io.pins.gpio5)
41+
}
42+
}
43+
}};
44+
}
45+
46+
#[macro_export]
47+
macro_rules! common_test_pins {
48+
($io:expr) => {{
49+
cfg_if::cfg_if! {
50+
if #[cfg(any(esp32s2, esp32s3))] {
51+
($io.pins.gpio9, $io.pins.gpio10)
52+
}
53+
else {
54+
($io.pins.gpio2, $io.pins.gpio3)
55+
}
56+
}
57+
}};
58+
}

0 commit comments

Comments
 (0)