Skip to content

Commit

Permalink
Adding I2C HIL test (#2023)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
playfulFence authored Sep 4, 2024
1 parent b7b916f commit 9bec6a1
Show file tree
Hide file tree
Showing 23 changed files with 352 additions and 209 deletions.
4 changes: 4 additions & 0 deletions hil-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ harness = false
name = "interrupt"
harness = false

[[test]]
name = "i2c"
harness = false

[[test]]
name = "i2s"
harness = false
Expand Down
18 changes: 11 additions & 7 deletions hil-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,39 @@ The [`hil.yml`] workflow builds the test suite for all our available targets and
Our self-hosted runners have the following setup:
- ESP32-C2 (`esp32c2-jtag`):
- Devkit: `ESP8684-DevKitM-1` connected via UART.
- `GPIO18` and `GPIO9` are I2C pins.
- `GPIO2` and `GPIO3` are connected.
- Probe: `ESP-Prog` connected with the [following connections][connection_c2]
- RPi: Raspbian 12 configured with the following [setup]
- ESP32-C3 (`rustboard`):
- Devkit: `ESP32-C3-DevKit-RUST-1` connected via USB-Serial-JTAG.
- `GPIO4` and `GPIO5` are I2C pins.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO6` are connected.
- RPi: Raspbian 12 configured with the following [setup]
- ESP32-C6 (`esp32c6-usb`):
- Devkit: `ESP32-C6-DevKitC-1 V1.2` connected via USB-Serial-JTAG (`USB` port).
- `GPIO6` and `GPIO7` are I2C pins.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO6` are connected.
- `GPIO4` and `GPIO5` are connected.
- RPi: Raspbian 12 configured with the following [setup]
- ESP32-H2 (`esp32h2-usb`):
- Devkit: `ESP32-H2-DevKitM-1` connected via USB-Serial-JTAG (`USB` port).
- `GPIO12` and `GPIO22` are I2C pins.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO8` are connected.
- `GPIO4` and `GPIO5` are connected.
- RPi: Raspbian 12 configured with the following [setup]
- ESP32-S2 (`esp32s2-jtag`):
- Devkit: `ESP32-S2-Saola-1` connected via UART.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO6` are connected.
- `GPIO2` and `GPIO3` are I2C pins.
- `GPIO9` and `GPIO10` are connected.
- Probe: `ESP-Prog` connected with the [following connections][connection_s2]
- RPi: Raspbian 12 configured with the following [setup]
- ESP32-S3 (`esp32s3-usb`):
- Devkit: `ESP32-S3-DevKitC-1` connected via USB-Serial-JTAG.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO6` are connected.
- `GPIO2` and `GPIO3` are I2C pins.
- `GPIO4` and `GPIO5` are connected.
- `GPIO1` and `GPIO21` are connected.
- `GPIO9` and `GPIO10` are connected.
- `GPIO43 (TX)` and `GPIO45` are connected.
- RPi: Raspbian 12 configured with the following [setup]

Expand Down
34 changes: 34 additions & 0 deletions hil-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,37 @@ unsafe impl defmt::Logger for Logger {
use defmt_rtt as _;
// Make sure esp_backtrace is not removed.
use esp_backtrace as _;

#[macro_export]
macro_rules! i2c_pins {
($io:expr) => {{
// Order: (SDA, SCL)
cfg_if::cfg_if! {
if #[cfg(any(esp32s2, esp32s3))] {
($io.pins.gpio2, $io.pins.gpio3)
} else if #[cfg(esp32c6)] {
($io.pins.gpio6, $io.pins.gpio7)
} else if #[cfg(esp32h2)] {
($io.pins.gpio12, $io.pins.gpio22)
} else if #[cfg(esp32c2)] {
($io.pins.gpio18, $io.pins.gpio9)
} else {
($io.pins.gpio4, $io.pins.gpio5)
}
}
}};
}

#[macro_export]
macro_rules! common_test_pins {
($io:expr) => {{
cfg_if::cfg_if! {
if #[cfg(any(esp32s2, esp32s3))] {
($io.pins.gpio9, $io.pins.gpio10)
}
else {
($io.pins.gpio2, $io.pins.gpio3)
}
}
}};
}
Loading

0 comments on commit 9bec6a1

Please sign in to comment.