Skip to content

Commit

Permalink
De-CAN
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 7, 2024
1 parent c6a59b9 commit 24853bc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion esp-hal/src/soc/esp32c3/efuse/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub const DIS_USB_SERIAL_JTAG: EfuseField = EfuseField::new(EfuseBlock::Block0,
/// `[]` Set this bit to disable the function that forces chip into download
/// mode
pub const DIS_FORCE_DOWNLOAD: EfuseField = EfuseField::new(EfuseBlock::Block0, 44, 1);
/// `[DIS_CAN]` Set this bit to disable CAN function
/// `[DIS_CAN]` Set this bit to disable TWAI function
pub const DIS_TWAI: EfuseField = EfuseField::new(EfuseBlock::Block0, 46, 1);
/// `[]` Set this bit to enable selection between usb_to_jtag and pad_to_jtag
/// through strapping gpio10 when both reg_dis_usb_jtag and reg_dis_pad_jtag are
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/soc/esp32s3/efuse/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub const DIS_DOWNLOAD_DCACHE: EfuseField = EfuseField::new(EfuseBlock::Block0,
pub const DIS_FORCE_DOWNLOAD: EfuseField = EfuseField::new(EfuseBlock::Block0, 44, 1);
/// `[DIS_USB]` Set this bit to disable USB function
pub const DIS_USB_OTG: EfuseField = EfuseField::new(EfuseBlock::Block0, 45, 1);
/// `[DIS_CAN]` Set this bit to disable CAN function
/// `[DIS_CAN]` Set this bit to disable TWAI function
pub const DIS_TWAI: EfuseField = EfuseField::new(EfuseBlock::Block0, 46, 1);
/// `[]` Disable app cpu
pub const DIS_APP_CPU: EfuseField = EfuseField::new(EfuseBlock::Block0, 47, 1);
Expand Down
6 changes: 3 additions & 3 deletions examples/src/bin/embassy_twai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ async fn main(spawner: Spawner) {
// Without an external transciever, we only need a single line between the two MCUs.
let rx_pin = tx_pin.peripheral_input(); // Comment this line if you want to use an external transciever.

// The speed of the CAN bus.
const CAN_BAUDRATE: twai::BaudRate = twai::BaudRate::B125K;
// The speed of the bus.
const TWAI_BAUDRATE: twai::BaudRate = twai::BaudRate::B125K;

// !!! Use `new_async` when using a transceiver. `new_async_no_transceiver` sets TX to open-drain

Expand All @@ -118,7 +118,7 @@ async fn main(spawner: Spawner) {
peripherals.TWAI0,
rx_pin,
tx_pin,
CAN_BAUDRATE,
TWAI_BAUDRATE,
TwaiMode::Normal,
);

Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/twai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() -> ! {
// Without an external transciever, we only need a single line between the two MCUs.
let rx_pin = tx_pin.peripheral_input(); // Comment this line if you want to use an external transciever.

// The speed of the CAN bus.
// The speed of the bus.
const TWAI_BAUDRATE: twai::BaudRate = twai::BaudRate::B125K;

// !!! Use `new` when using a transceiver. `new_no_transceiver` sets TX to open-drain
Expand Down Expand Up @@ -78,27 +78,27 @@ fn main() -> ! {
// Start the peripheral. This locks the configuration settings of the peripheral
// and puts it into operation mode, allowing packets to be sent and
// received.
let mut can = twai_config.start();
let mut twai = twai_config.start();

if IS_FIRST_SENDER {
// Send a frame to the other ESP
// Use `new_self_reception` if you want to use self-testing.
let frame = EspTwaiFrame::new(StandardId::ZERO, &[1, 2, 3]).unwrap();
block!(can.transmit(&frame)).unwrap();
block!(twai.transmit(&frame)).unwrap();
println!("Sent a frame");
}

let delay = Delay::new();
loop {
// Wait for a frame to be received.
let frame = block!(can.receive()).unwrap();
let frame = block!(twai.receive()).unwrap();

println!("Received a frame: {frame:?}");
delay.delay_millis(250);

let frame = EspTwaiFrame::new(StandardId::ZERO, &[1, 2, 3]).unwrap();
// Transmit a new frame back to the other ESP
block!(can.transmit(&frame)).unwrap();
block!(twai.transmit(&frame)).unwrap();
println!("Sent a frame");
}
}

0 comments on commit 24853bc

Please sign in to comment.