Skip to content

Commit

Permalink
Merge pull request #165 from card-io-ecg/old2
Browse files Browse the repository at this point in the history
Remove hw_v2
  • Loading branch information
bugadani committed Apr 21, 2024
2 parents 2134d6c + 50ed997 commit b225078
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 21 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ default = ["defmt"]

battery_max17055 = ["dep:max17055"]

hw_v2 = ["battery_max17055", "esp32s3"] # skipped v3
hw_v4 = ["battery_max17055", "esp32s3"]
hw_v6 = ["battery_max17055"] # skipped v5, v6 has S3 and C6 options

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Commands
- `cargo xbuild <hw>`: Build the firmware for a `<hw>` version board.
- `cargo xrun <hw>`: Build and run the firmware on a `<hw>` version board.
- `cargo monitor`: Connect to the Card/IO device and display serial output.
`<hw>` can be omitted, or one of: `v1`, `v2`, `v4`, `v6_s3`, `v6_c6`. Defaults to `v4`.
`<hw>` can be omitted, or one of: `v4`, `v6s3`, `v6c6`. Defaults to `v6c6`.
- `cargo xcheck <hw>`: runs `cargo check`
- `cargo xclippy <hw>`: runs `cargo clippy`
- `cargo xdoc <hw> [--open]`: runs `cargo doc` and optionally opens the generated documentation.
Expand Down
7 changes: 1 addition & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ impl Mcu {

#[derive(Clone, Copy, PartialEq, PartialOrd)]
enum HwVersion {
V1,
V2,
V4,
V6,
}

impl HwVersion {
fn as_str(self) -> &'static str {
match self {
Self::V1 => "v1",
Self::V2 => "v2",
Self::V4 => "v4",
Self::V6 => "v6",
}
Expand Down Expand Up @@ -84,13 +80,12 @@ fn main() {

// Ensure that only a single HW version
let hw_features = [
(cfg!(feature = "hw_v2"), HwVersion::V2),
(cfg!(feature = "hw_v4"), HwVersion::V4),
(cfg!(feature = "hw_v6"), HwVersion::V6),
];

let Some(hw_version) = get_unique(hw_features) else {
panic!("Exactly 1 hardware version must be selected via its Cargo feature (hw_v2, hw_v4, hw_v6)");
panic!("Exactly 1 hardware version must be selected via its Cargo feature (hw_v4, hw_v6)");
};

let build_config = BuildConfig { mcu, hw_version };
Expand Down
2 changes: 0 additions & 2 deletions src/board/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#[cfg_attr(feature = "hw_v2", path = "hardware/v2.rs")]
#[cfg_attr(feature = "hw_v4", path = "hardware/v4.rs")]
#[cfg_attr(all(feature = "hw_v6", feature = "esp32s3"), path = "hardware/v6s3.rs")]
#[cfg_attr(all(feature = "hw_v6", feature = "esp32c6"), path = "hardware/v6c6.rs")]
#[cfg_attr( // We default to hw_v6/esp32c6 if no feature is selected to help rust-analyzer for example
not(any(
feature = "hw_v2",
feature = "hw_v4",
all(feature = "hw_v6", feature = "esp32s3"),
all(feature = "hw_v6", feature = "esp32c6")
Expand Down
11 changes: 2 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use crate::board::{
TouchDetect,
};

#[cfg(any(feature = "hw_v2", feature = "hw_v4", feature = "hw_v6"))]
#[cfg(any(feature = "hw_v4", feature = "hw_v6"))]
use crate::board::VbusDetect;

#[cfg(feature = "esp32s3")]
Expand Down Expand Up @@ -213,9 +213,6 @@ where
async fn main(_spawner: Spawner) {
let resources = StartupResources::initialize().await;

#[cfg(feature = "hw_v2")]
info!("Hardware version: v2");

#[cfg(feature = "hw_v4")]
info!("Hardware version: v4");

Expand Down Expand Up @@ -311,11 +308,7 @@ async fn main(_spawner: Spawner) {
// will have nothing else to do. Not ideal, but again, we shouldn't reach this.
}

#[cfg(any(
feature = "hw_v2",
feature = "hw_v4",
all(feature = "hw_v6", feature = "esp32s3")
))]
#[cfg(any(feature = "hw_v4", all(feature = "hw_v6", feature = "esp32s3")))]
fn setup_wakeup_pins<'a, 'b, const N: usize>(
wakeup_pins: &'a mut heapless::Vec<(&'b mut dyn RtcWakeupPin, WakeupLevel), N>,
touch: &'b mut TouchDetect,
Expand Down
2 changes: 0 additions & 2 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ pub enum Subcommands {

#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum HardwareVersion {
V2,
V4,
V6S3,
#[default]
Expand All @@ -86,7 +85,6 @@ pub enum HardwareVersion {
impl HardwareVersion {
fn feature(&self) -> &str {
match self {
HardwareVersion::V2 => "hw_v2",
HardwareVersion::V4 => "hw_v4",
HardwareVersion::V6S3 => "hw_v6,esp32s3",
HardwareVersion::V6C6 => "hw_v6,esp32c6",
Expand Down

0 comments on commit b225078

Please sign in to comment.