Skip to content

Commit

Permalink
Added embedded-can to esp32c3 twai example.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbohm committed Nov 10, 2022
1 parent 8fc9ae8 commit eddea20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion esp32c3-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ cfg-if = "1.0"
embedded-hal = { version = "0.2.7", features = ["unproven"] }
embedded-hal-1 = { version = "=1.0.0-alpha.9", optional = true, package = "embedded-hal" }
embedded-hal-nb = { version = "=1.0.0-alpha.1", optional = true }
embedded-can = { version = "0.4.1", optional = true }
esp-hal-common = { version = "0.2.0", features = ["esp32c3"], path = "../esp-hal-common" }
r0 = "1.0.0"
riscv = "0.9.0"
Expand All @@ -50,7 +51,7 @@ static_cell = "1.0.0"
default = ["rt", "vectored"]
mcu-boot = []
direct-boot = []
eh1 = ["esp-hal-common/eh1", "dep:embedded-hal-1", "dep:embedded-hal-nb"]
eh1 = ["esp-hal-common/eh1", "dep:embedded-hal-1", "dep:embedded-hal-nb", "dep:embedded-can"]
rt = ["riscv-rt"]
smartled = ["esp-hal-common/smartled"]
ufmt = ["esp-hal-common/ufmt"]
Expand Down
12 changes: 11 additions & 1 deletion esp32c3-hal/examples/twai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ use esp32c3_hal::{
UsbSerialJtag,
};

use embedded_hal::can::{Can, Frame, Id, StandardId};
// Run this example with the eh1 feature enabled to use embedded-can instead of
// embedded-hal-0.2.7. embedded-can was split off from embedded-hal before it's upgrade to 1.0.0.
// cargo run --example twai --features eh1 --release
#[cfg(feature = "eh1")]
use embedded_can::{nb::Can, Frame, Id};

// Run this example without the eh1 flag to use the embedded-hal 0.2.7 CAN traits.
// cargo run --example twai --release
#[cfg(not(feature = "eh1"))]
use embedded_hal::can::{Can, Frame, Id};

use esp_backtrace as _;
use nb::block;
use riscv_rt::entry;
Expand Down

0 comments on commit eddea20

Please sign in to comment.