Skip to content

Commit

Permalink
Attempt to fix test GPIO assingment
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 19, 2024
1 parent cb1f461 commit 53e43a3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
20 changes: 16 additions & 4 deletions hil-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,23 @@ macro_rules! common_test_pins {
}};
}

// A GPIO that's not connected to anything. We use the BOOT pin for this, but
// beware: it has a pullup.
#[macro_export]
macro_rules! unconnected_test_pins {
macro_rules! unconnected_pin {
($io:expr) => {{
let (a, _) = $crate::common_test_pins!($io);
let (_, b) = $crate::i2c_pins!($io);
(a, b)
cfg_if::cfg_if! {
if #[cfg(any(esp32, esp32s2, esp32s3))] {
$io.pins.gpio0
} else if #[cfg(esp32c6)] {
$io.pins.gpio9
} else if #[cfg(esp32h2)] {
$io.pins.gpio9
} else if #[cfg(esp32c2)] {
$io.pins.gpio8
} else {
$io.pins.gpio9
}
}
}};
}
19 changes: 14 additions & 5 deletions hil-test/tests/qspi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! QSPI Test Suite

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: defmt

#![no_std]
#![no_main]
Expand Down Expand Up @@ -161,7 +162,7 @@ mod tests {
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);

let (pin, pin_mirror) = hil_test::common_test_pins!(io);
let (unconnected_pin, _) = hil_test::i2c_pins!(io);
let unconnected_pin = hil_test::unconnected_pin!(io);

let dma = Dma::new(peripherals.DMA);

Expand Down Expand Up @@ -296,7 +297,9 @@ mod tests {
#[timeout(3)]
#[cfg(pcnt)]
fn test_spi_writes_correctly_to_pin_0(ctx: Context) {
let [mosi, _, _] = ctx.gpios;
// For PCNT-using tests we swap the pins around so that the PCNT is not pulled
// up by a resistor if the command phase doesn't drive its line.
let [_, _, mosi] = ctx.gpios;

let pcnt = Pcnt::new(ctx.pcnt);
let unit = pcnt.unit0;
Expand All @@ -316,7 +319,9 @@ mod tests {
#[timeout(3)]
#[cfg(pcnt)]
fn test_spi_writes_correctly_to_pin_1(ctx: Context) {
let [mosi, _, gpio] = ctx.gpios;
// For PCNT-using tests we swap the pins around so that the PCNT is not pulled
// up by a resistor if the command phase doesn't drive its line.
let [gpio, _, mosi] = ctx.gpios;

let pcnt = Pcnt::new(ctx.pcnt);
let unit = pcnt.unit0;
Expand All @@ -340,7 +345,9 @@ mod tests {
#[timeout(3)]
#[cfg(pcnt)]
fn test_spi_writes_correctly_to_pin_2(ctx: Context) {
let [mosi, _, gpio] = ctx.gpios;
// For PCNT-using tests we swap the pins around so that the PCNT is not pulled
// up by a resistor if the command phase doesn't drive its line.
let [gpio, _, mosi] = ctx.gpios;

let pcnt = Pcnt::new(ctx.pcnt);
let unit = pcnt.unit0;
Expand All @@ -364,7 +371,9 @@ mod tests {
#[timeout(3)]
#[cfg(pcnt)]
fn test_spi_writes_correctly_to_pin_3(ctx: Context) {
let [mosi, _, gpio] = ctx.gpios;
// For PCNT-using tests we swap the pins around so that the PCNT is not pulled
// up by a resistor if the command phase doesn't drive its line.
let [gpio, _, mosi] = ctx.gpios;

let pcnt = Pcnt::new(ctx.pcnt);
let unit = pcnt.unit0;
Expand Down

0 comments on commit 53e43a3

Please sign in to comment.