Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/cargo/examples/esp32c3/esp-hal-0.…
Browse files Browse the repository at this point in the history
…23.1
  • Loading branch information
ScottGibb authored Jan 21, 2025
2 parents 4cfeb9f + 4b24ee8 commit 9f001cf
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 61 deletions.
4 changes: 2 additions & 2 deletions examples/esp32c3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ edition = "2021"
[dependencies]
tmag5273 = { path = "../../" }
embedded-hal = { version = "1.0.0" }
esp-backtrace = { version = "0.14.0", features = [
esp-backtrace = { version = "0.15.0", features = [
"esp32c3",
"exception-handler",
"panic-handler",
"println",
] }

esp-hal = { version = "0.23.1", features = ["esp32c3"] }
esp-println = { version = "0.12.0", features = ["esp32c3", "log"] }
esp-println = { version = "0.13.0", features = ["esp32c3", "log"] }
log = { version = "0.4.21" }

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion tests/esp32c3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmt = { version = "0.3.8"}
defmt-rtt = { version = "0.4.1"}

# Esp32 related dependencies for main.rs. Note: embedded-test comes with its own panic handler and logging sink.
esp-hal = { version = "0.22.0", features = ["esp32c3"] }
esp-hal = { version = "0.23.1", features = ["esp32c3"] }
esp-backtrace = { version = "0.14.0", features = [
"esp32c3",
"exception-handler",
Expand Down
11 changes: 5 additions & 6 deletions tests/esp32c3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
/// This module is a simple setup method and type declarations that can be shared across the tests, reducing boiler plate code.
pub mod initialise {
use defmt_rtt as _;
use esp_hal::{
i2c::master::{AnyI2c, I2c},
prelude::*,
Blocking,
};
pub fn initialise() -> I2c<'static, Blocking, AnyI2c> {
use esp_hal::{clock::CpuClock, i2c::master::I2c, Blocking};
pub type EspI2c = I2c<'static, Blocking>;

pub fn initialise() -> EspI2c {
let peripherals = esp_hal::init({
let mut config = esp_hal::Config::default();
config.cpu_clock = CpuClock::max();
config
});
let i2c = I2c::new(peripherals.I2C0, esp_hal::i2c::master::Config::default())
.unwrap()
.with_sda(peripherals.GPIO5)
.with_scl(peripherals.GPIO6);
i2c
Expand Down
52 changes: 24 additions & 28 deletions tests/esp32c3/tests/cold_start_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,65 @@
#[embedded_test::tests]
mod cold_start_tests {

use esp32c3_tests::initialise::initialise;
use esp_hal::{
i2c::master::{AnyI2c, I2c},
Blocking,
};
use esp32c3_tests::initialise::{initialise, EspI2c};
use tests_common::generic_cold_start_tests::*;
#[init]
fn init() -> I2c<'static, Blocking, AnyI2c> {
fn init() -> EspI2c {
initialise()
}

#[test]
fn test_device_id(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_device_id(i2c); // Pass the i2c variable to the inner test function
fn test_device_id(i2c: EspI2c) {
generic_test_device_id(i2c);
}

#[test]
fn test_manufacturer_id(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_manufacturer_id(i2c); // Pass the i2c variable to the inner test function
fn test_manufacturer_id(i2c: EspI2c) {
generic_test_manufacturer_id(i2c);
}

#[test]
fn test_registers(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_registers(i2c); // Pass the i2c variable to the inner test function
fn test_registers(i2c: EspI2c) {
generic_test_registers(i2c);
}

#[test]
fn test_default_i2c_address(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_default_i2c_address(i2c); // Pass the i2c variable to the inner test function
fn test_default_i2c_address(i2c: EspI2c) {
generic_test_default_i2c_address(i2c);
}

#[test]
fn test_get_magnitude_first_boot(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_get_magnitude_first_boot(i2c); // Pass the i2c variable to the inner test function
fn test_get_magnitude_first_boot(i2c: EspI2c) {
generic_test_get_magnitude_first_boot(i2c);
}

#[test]
fn test_get_xyz_thresholds_first_boot(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_get_xyz_thresholds_first_boot(i2c); // Pass the i2c variable to the inner test function
fn test_get_xyz_thresholds_first_boot(i2c: EspI2c) {
generic_test_get_xyz_thresholds_first_boot(i2c);
}

#[test]
fn test_magnetic_gain(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_magnetic_gain(i2c); // Pass the i2c variable to the inner test function
fn test_magnetic_gain(i2c: EspI2c) {
generic_test_magnetic_gain(i2c);
}

#[test]
fn test_magnetic_offset_invalid_at_boot(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_magnetic_offset_invalid_at_boot(i2c); // Pass the i2c variable to the inner test function
fn test_magnetic_offset_invalid_at_boot(i2c: EspI2c) {
generic_test_magnetic_offset_invalid_at_boot(i2c);
}

#[test]
fn test_temperature_invalid_at_boot(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_temperature_invalid_at_boot(i2c); // Pass the i2c variable to the inner test function
fn test_temperature_invalid_at_boot(i2c: EspI2c) {
generic_test_temperature_invalid_at_boot(i2c);
}

#[test]
fn test_get_data_methods(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_get_data_methods(i2c); // Pass the i2c variable to the inner test function
fn test_get_data_methods(i2c: EspI2c) {
generic_test_get_data_methods(i2c);
}

#[test]
fn test_get_angle(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_get_angle(i2c); // Pass the i2c variable to the inner test function
fn test_get_angle(i2c: EspI2c) {
generic_test_get_angle(i2c);
}
}
45 changes: 21 additions & 24 deletions tests/esp32c3/tests/setting_register_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,48 @@
#[cfg(test)]
#[embedded_test::tests]
mod cold_start_tests {
use esp32c3_tests::initialise::initialise;
use esp_hal::{
i2c::master::{AnyI2c, I2c},
Blocking,
};
use esp32c3_tests::initialise::{initialise, EspI2c};
use tests_common::generic_setting_registers_tests::*;

#[init]
fn init() -> I2c<'static, Blocking, AnyI2c> {
fn init() -> EspI2c {
initialise()
}

#[test]
fn test_is_connected(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_is_connected(i2c); // Pass the i2c variable to the inner test function
fn test_is_connected(i2c: EspI2c) {
generic_test_is_connected(i2c);
}
#[test]
fn test_create_tmag5273(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_create_tmag5273(i2c); // Pass the i2c variable to the inner test function
fn test_create_tmag5273(i2c: EspI2c) {
generic_test_create_tmag5273(i2c);
}
#[test]
fn test_set_reset_device_config_1_register(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_set_reset_device_config_1_register(i2c); // Pass the i2c variable to the inner test function
fn test_set_reset_device_config_1_register(i2c: EspI2c) {
generic_test_set_reset_device_config_1_register(i2c);
}
#[test]
fn test_set_reset_device_config_2_register(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_reset_device_config_2_register(i2c); // Pass the i2c variable to the inner test function
fn test_set_reset_device_config_2_register(i2c: EspI2c) {
generic_test_reset_device_config_2_register(i2c);
}
#[test]
fn test_set_reset_i2c_address_register(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_set_reset_i2c_address_register(i2c); // Pass the i2c variable to the inner test function
fn test_set_reset_i2c_address_register(i2c: EspI2c) {
generic_test_set_reset_i2c_address_register(i2c);
}
#[test]
fn test_set_reset_int_config_1_register(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_set_reset_int_config_1_register(i2c); // Pass the i2c variable to the inner test function
fn test_set_reset_int_config_1_register(i2c: EspI2c) {
generic_test_set_reset_int_config_1_register(i2c);
}
#[test]
fn test_set_reset_sensor_config_1_register(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_set_reset_sensor_config_1_register(i2c); // Pass the i2c variable to the inner test function
fn test_set_reset_sensor_config_1_register(i2c: EspI2c) {
generic_test_set_reset_sensor_config_1_register(i2c);
}
#[test]
fn test_set_reset_sensor_config_2_register(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_set_reset_sensor_config_2_register(i2c); // Pass the i2c variable to the inner test function
fn test_set_reset_sensor_config_2_register(i2c: EspI2c) {
generic_test_set_reset_sensor_config_2_register(i2c);
}
#[test]
fn test_set_reset_t_config_register(i2c: I2c<'static, Blocking, AnyI2c>) {
generic_test_set_reset_t_config_register(i2c); // Pass the i2c variable to the inner test function
fn test_set_reset_t_config_register(i2c: EspI2c) {
generic_test_set_reset_t_config_register(i2c);
}
}

0 comments on commit 9f001cf

Please sign in to comment.