From 24853bcc3b025386d17ef712f02c493f6f9f54be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Mon, 7 Oct 2024 13:29:38 +0200 Subject: [PATCH] De-CAN --- esp-hal/src/soc/esp32c3/efuse/fields.rs | 2 +- esp-hal/src/soc/esp32s3/efuse/fields.rs | 2 +- examples/src/bin/embassy_twai.rs | 6 +++--- examples/src/bin/twai.rs | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/esp-hal/src/soc/esp32c3/efuse/fields.rs b/esp-hal/src/soc/esp32c3/efuse/fields.rs index 29e2c2e86e3..b67fe2d125d 100644 --- a/esp-hal/src/soc/esp32c3/efuse/fields.rs +++ b/esp-hal/src/soc/esp32c3/efuse/fields.rs @@ -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 diff --git a/esp-hal/src/soc/esp32s3/efuse/fields.rs b/esp-hal/src/soc/esp32s3/efuse/fields.rs index 8fa8e7bb81b..42bed0b931a 100644 --- a/esp-hal/src/soc/esp32s3/efuse/fields.rs +++ b/esp-hal/src/soc/esp32s3/efuse/fields.rs @@ -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); diff --git a/examples/src/bin/embassy_twai.rs b/examples/src/bin/embassy_twai.rs index 0db3a5f091f..86ac5f74bf3 100644 --- a/examples/src/bin/embassy_twai.rs +++ b/examples/src/bin/embassy_twai.rs @@ -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 @@ -118,7 +118,7 @@ async fn main(spawner: Spawner) { peripherals.TWAI0, rx_pin, tx_pin, - CAN_BAUDRATE, + TWAI_BAUDRATE, TwaiMode::Normal, ); diff --git a/examples/src/bin/twai.rs b/examples/src/bin/twai.rs index c7edf60e884..1238413675e 100644 --- a/examples/src/bin/twai.rs +++ b/examples/src/bin/twai.rs @@ -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 @@ -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"); } }