Skip to content

Commit

Permalink
Merge pull request #163 from card-io-ecg/update
Browse files Browse the repository at this point in the history
Update esp-hal
  • Loading branch information
bugadani authored Oct 10, 2024
2 parents 436f6bd + 08369ef commit 8e2f0ac
Show file tree
Hide file tree
Showing 31 changed files with 454 additions and 577 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ jobs:
with:
default: true
buildtargets: esp32s3
version: "1.80.0"
ldproxy: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-06-01
components: clippy, rustfmt, rust-src
- uses: Swatinem/rust-cache@v2

- uses: cargo-bins/cargo-binstall@main
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ jobs:
with:
default: true
buildtargets: esp32s3
version: "1.80.0"
ldproxy: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-06-01
components: clippy, rustfmt, rust-src
- uses: Swatinem/rust-cache@v2

- name: format check
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ jobs:
with:
default: true
buildtargets: esp32s3
version: "1.80.0"
ldproxy: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-06-01
components: clippy, rustfmt, rust-src
- uses: Swatinem/rust-cache@v2

- uses: cargo-bins/cargo-binstall@main
Expand Down
33 changes: 33 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,39 @@
"programBinary": "${workspaceRoot}/target/xtensa-esp32s3-none-elf/debug/card_io_fw"
}
]
},
{
"name": "Attach to v4 release",
"type": "probe-rs-debug",
"request": "attach",
"chip": "esp32s3",
"coreConfigs": [
{
"programBinary": "${workspaceRoot}/target/xtensa-esp32s3-none-elf/release/card_io_fw"
}
]
},
{
"name": "Attach to v6c6",
"type": "probe-rs-debug",
"request": "attach",
"chip": "esp32c6",
"coreConfigs": [
{
"programBinary": "${workspaceRoot}/target/riscv32imac-unknown-none-elf/debug/card_io_fw"
}
]
},
{
"name": "Attach to v6c6 release",
"type": "probe-rs-debug",
"request": "attach",
"chip": "esp32c6",
"coreConfigs": [
{
"programBinary": "${workspaceRoot}/target/riscv32imac-unknown-none-elf/release/card_io_fw"
}
]
}
]
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"rust-analyzer.showUnlinkedFileNotification": false,
"cortex-debug.variableUseNaturalFormat": false,
"rust-analyzer.cargo.features": [
"esp32c6",
"hw_v6"
"esp32s3",
"hw_v4"
]
}
88 changes: 33 additions & 55 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT"
embedded-graphics = "0.8.0"
embedded-hal = "1.0.0"
embedded-hal-async = "1.0.0"
embedded-hal-bus = { version = "0.1.0", features = ["async"] }
embedded-hal-bus = { version = "0.2.0", features = ["async"] }
embedded-nal-async = "0.7.0"
embedded-io = "0.6"
embedded-io-async = "0.6"
Expand All @@ -21,8 +21,8 @@ embassy-net = { version = "0.4", features = [
"dns",
"medium-ethernet",
] }
embassy-sync = { version = "0.5.0" }
embassy-executor = { version = "0.5" }
embassy-sync = { version = "0.6.0" }
embassy-executor = { version = "0.6" }

heapless = "0.8"
log = { version = "0.4.18", default-features = false, features = [
Expand All @@ -37,7 +37,7 @@ norfs-esp32s3 = { git = "https://github.com/card-io-ecg/norfs.git", rev = "19e14
norfs-esp32c6 = { git = "https://github.com/card-io-ecg/norfs.git", rev = "19e14b5" }
object-chain = "0.1.3"
bad-server = { path = "bad-server" }
defmt = { version = "=0.3.5" }
defmt = "0.3.8"
ufmt = "0.2.0"

smoltcp = { version = "0.11.0", default-features = false, features = [
Expand All @@ -51,35 +51,18 @@ embassy-time = { version = "0.3.0" }

embedded-hal-old = { package = "embedded-hal", version = "0.2.7" }

# esp32s2-hal = { version = "0.10.0", optional = true, features = ["rt", "async", "embassy", "embassy-time-systick", "eh1"] }
esp32s3-hal = { version = "0.15.0", optional = true, features = [
"rt",
"async",
"embassy",
"embassy-executor-thread",
"embassy-executor-interrupt",
"embassy-time-systick",
"eh1",
] }
esp32c6-hal = { version = "0.8.0", optional = true, default-features = false, features = [
"rt",
"vectored",
"zero-rtc-bss",
"async",
"embassy",
"embassy-executor-thread",
"embassy-executor-interrupt",
"eh1",
] }
esp-backtrace = { version = "0.10.0", features = [
esp-hal = { version = "0.21.0" }
esp-hal-embassy = { version = "0.4.0" }
esp-backtrace = { version = "0.14.2", features = [
"panic-handler",
"exception-handler",
] }
esp-println = { version = "0.8.0", default-features = false, features = [
esp-println = { version = "0.12.0", default-features = false, features = [
"critical-section",
] }
esp-alloc = "0.3.0"
esp-wifi = { version = "0.3.0", default-features = false, features = [
esp-alloc = "0.5.0"
esp-wifi = { version = "0.10.1", default-features = false, features = [
"esp-alloc",
"phy-enable-usb",
"ps-max-modem",
"wifi",
Expand All @@ -93,11 +76,9 @@ esp-wifi = { version = "0.3.0", default-features = false, features = [

display-interface = "0.5"
display-interface-spi = "0.5"
ssd1306 = { git = "https://github.com/bugadani/ssd1306.git", branch = "ehal1", features = [
"graphics",
] }
ssd1306 = { version = "0.9.0", features = ["async", "graphics"] }

atomic_enum = "0.2.0"
portable_atomic_enum = "0.3.1"
config-site = { path = "config-site", default-features = false, features = [
"embedded",
] }
Expand All @@ -117,7 +98,7 @@ replace_with = { version = "0.1", default-features = false, features = [
static_cell = { version = "2.0.0", features = ["nightly"] }
bad-server = { path = "bad-server", features = ["embassy"] }
embedded-tls = { version = "0.17.0", default-features = false }
reqwless = "0.11.0"
reqwless = "0.12.1"

embedded-graphics.workspace = true
embedded-hal.workspace = true
Expand Down Expand Up @@ -150,17 +131,13 @@ smoltcp = { workspace = true }
crc = "3.0.1"
enumset = "1.1.3"

[patch.crates-io]
esp32-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp32s2-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp32s3-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp32c2-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp32c3-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp32c6-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp32h2-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp-hal-procmacros = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "9a95c0aa880af7271f059797339bf890d2d59c64" }
esp-wifi = { git = "https://github.com/esp-rs/esp-wifi", rev = "d200a167237f03cf63edce721a5f85fd65d2db84" }
#[patch.crates-io]
#esp-hal = { git = "https://github.com/bugadani/esp-hal.git", rev = "7ca1b4376fd48229c887018d7133ce317742ce4e" }
#esp-hal-embassy = { git = "https://github.com/bugadani/esp-hal.git", rev = "7ca1b4376fd48229c887018d7133ce317742ce4e" }
#esp-wifi = { git = "https://github.com/bugadani/esp-hal.git", rev = "7ca1b4376fd48229c887018d7133ce317742ce4e" }
#esp-backtrace = { git = "https://github.com/bugadani/esp-hal.git", rev = "7ca1b4376fd48229c887018d7133ce317742ce4e" }
#esp-println = { git = "https://github.com/bugadani/esp-hal.git", rev = "7ca1b4376fd48229c887018d7133ce317742ce4e" }
#esp-alloc = { git = "https://github.com/bugadani/esp-hal.git", rev = "7ca1b4376fd48229c887018d7133ce317742ce4e" }

[features]
default = ["defmt"]
Expand All @@ -173,40 +150,41 @@ hw_v6 = ["battery_max17055"] # skipped v5, v6 has S3 and C6 options
# MCU options
# esp32s2 = ["dep:esp32s2", "dep:esp32s2-hal", "esp-backtrace/esp32s2", "esp-println/esp32s2", "rtt"]
esp32s3 = [
"dep:esp32s3-hal",
"esp32s3-hal/embassy-time-systick",
"esp-hal/esp32s3",
"embassy-executor/integrated-timers",
"dep:norfs-esp32s3",
"esp-backtrace/esp32s3",
"esp-println/esp32s3",
"jtag-serial",
"esp-wifi/esp32s3",
"esp-hal-embassy/esp32s3",
]
esp32c6 = [
"dep:esp32c6-hal",
"esp32c6-hal/embassy-time-timg0",
"esp-hal/esp32c6",
"embassy-time/generic-queue-8",
"dep:norfs-esp32c6",
"esp-backtrace/esp32c6",
"esp-println/esp32c6",
"jtag-serial",
"esp-wifi/esp32c6",
"esp-hal-embassy/esp32c6",
]

# Signal processing
downsampler-light = [] # uses IIR-based filtering and less memory

# Print options
uart = ["esp-backtrace/print-uart", "esp-println/uart"]
jtag-serial = ["esp-backtrace/print-jtag-serial", "esp-println/jtag-serial"]
uart = ["esp-println/uart"]
jtag-serial = ["esp-println/jtag-serial"]

log = [
"dep:log",
"norfs/log",
"esp-println/log",
"esp-println/colors",
"esp-wifi/log",
"esp32s3-hal?/log",
"esp32c6-hal?/log",
"esp-hal/log",
"esp-backtrace/println",

"logger/log",
"config-site/log",
Expand All @@ -227,8 +205,8 @@ defmt = [
"embedded-graphics/defmt",
"esp-println/defmt-espflash",
"esp-wifi/defmt",
"esp32s3-hal?/defmt",
"esp32c6-hal?/defmt",
"esp-hal/defmt",
"esp-backtrace/defmt",

"logger/defmt",
"config-site/defmt",
Expand Down Expand Up @@ -268,7 +246,7 @@ codegen-units = 1
lto = "thin"

[profile.release]
debug = false
debug = true
codegen-units = 1
lto = "fat"

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Commands
Use `--watch` to enable automatic reload when a file changes.
- To run the config site on your PC, run `cargo example config-site simple --watch`
and open `127.0.0.1:8080` in a browser.

6 changes: 1 addition & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#[derive(Clone, Copy)]
enum Mcu {
ESP32S2,
ESP32S3,
ESP32C6,
}

impl Mcu {
fn as_str(self) -> &'static str {
match self {
Self::ESP32S2 => "ESP32-S2",
Self::ESP32S3 => "ESP32-S3",
Self::ESP32C6 => "ESP32-C6",
}
Expand Down Expand Up @@ -39,7 +37,6 @@ impl BuildConfig {
fn as_str(&self) -> String {
let mcu = if self.hw_version >= HwVersion::V6 {
match self.mcu {
Mcu::ESP32S2 => "s2",
Mcu::ESP32S3 => "s3",
Mcu::ESP32C6 => "c6",
}
Expand Down Expand Up @@ -69,13 +66,12 @@ fn get_unique<T, const N: usize>(values: [(bool, T); N]) -> Option<T> {
fn main() {
// Ensure that only a single MCU is specified.
let mcu_features = [
(cfg!(feature = "esp32s2"), Mcu::ESP32S2),
(cfg!(feature = "esp32s3"), Mcu::ESP32S3),
(cfg!(feature = "esp32c6"), Mcu::ESP32C6),
];

let Some(mcu) = get_unique(mcu_features) else {
panic!("Exactly 1 MCU must be selected via its Cargo feature (esp32s2, esp32s3, esp32c6)");
panic!("Exactly 1 MCU must be selected via its Cargo feature (esp32s3, esp32c6)");
};

// Ensure that only a single HW version
Expand Down
16 changes: 7 additions & 9 deletions src/board/drivers/battery_monitor/battery_fg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ use embedded_hal::digital::OutputPin;
use embedded_hal_async::{delay::DelayNs, i2c::I2c};
use max17055::Max17055;

#[cfg(all(feature = "esp32s3", not(feature = "hw_v6")))]
use crate::board::hal as esp_hal;

use crate::{task_control::TaskControlToken, Shared};
#[cfg(all(feature = "esp32s3", not(feature = "hw_v6")))]
use esp_hal::gpio::RTCPinWithResistors;

#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
Expand Down Expand Up @@ -52,13 +47,16 @@ where
}

#[cfg(all(feature = "esp32s3", not(feature = "hw_v6")))]
pub fn disable(&mut self)
pub fn disable<R>(&mut self)
where
EN: RTCPinWithResistors,
EN: esp_hal::peripheral::Peripheral<P = R>,
R: esp_hal::gpio::RtcPinWithResistors,
{
use esp_hal::peripheral::Peripheral;
// We want to keep the fuel gauge out of shutdown mode
self.enable.rtcio_pad_hold(true);
self.enable.rtcio_pullup(true);
let mut enable = (&mut self.enable).into_ref();
enable.rtcio_pad_hold(true);
enable.rtcio_pullup(true);
}

#[cfg(any(not(feature = "esp32s3"), feature = "hw_v6"))]
Expand Down
12 changes: 10 additions & 2 deletions src/board/drivers/battery_monitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ pub struct BatteryMonitor<VBUS, CHG> {
sensor: Shared<BatterySensor>,
}

impl<VBUS: InputPin, CHG: InputPin> BatteryMonitor<VBUS, CHG> {
impl<VBUS, CHG> BatteryMonitor<VBUS, CHG>
where
VBUS: InputPin,
CHG: InputPin,
{
pub async fn start(vbus_detect: VBUS, charger_status: CHG, sensor: BatterySensorImpl) -> Self {
let this = BatteryMonitor {
sensor: Rc::new(Mutex::new(BatterySensor {
Expand Down Expand Up @@ -133,7 +137,11 @@ impl<VBUS: InputPin, CHG: InputPin> BatteryMonitor<VBUS, CHG> {
}

#[cfg(feature = "battery_max17055")]
impl<VBUS: InputPin, CHG: InputPin> BatteryMonitor<VBUS, CHG> {
impl<VBUS, CHG> BatteryMonitor<VBUS, CHG>
where
VBUS: InputPin,
CHG: InputPin,
{
pub fn convert_battery_data(&mut self, data: BatteryData) -> BatteryInfo {
BatteryInfo {
voltage: data.voltage,
Expand Down
Loading

0 comments on commit 8e2f0ac

Please sign in to comment.