Skip to content

Commit 7156659

Browse files
committed
pre driver PeripheralRef update.
1 parent 9a352b7 commit 7156659

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

esp-hal-common/src/twai/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::slice::{from_raw_parts, from_raw_parts_mut};
77

88
use crate::{
99
clock::Clocks,
10-
pac::twai::RegisterBlock,
10+
peripherals::twai::RegisterBlock,
1111
system::PeripheralClockControl,
1212
types::{InputSignal, OutputSignal},
1313
InputPin, OutputPin,
@@ -669,7 +669,7 @@ pub trait Instance {
669669
}
670670

671671
#[cfg(any(esp32c3))]
672-
impl Instance for crate::pac::TWAI {
672+
impl Instance for crate::peripherals::TWAI {
673673
#[inline(always)]
674674
fn register_block(&self) -> &RegisterBlock {
675675
self

esp32c3-hal/examples/twai.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#![no_std]
22
#![no_main]
33

4-
use core::fmt::Write;
54
use esp32c3_hal::{
6-
clock::ClockControl, gpio::IO, pac::Peripherals, prelude::*, timer::TimerGroup, twai, Rtc,
7-
UsbSerialJtag,
5+
clock::ClockControl, gpio::IO, peripherals::Peripherals, prelude::*, timer::TimerGroup, twai,
6+
Rtc,
87
};
8+
use esp_println::println;
99

1010
// Run this example with the eh1 feature enabled to use embedded-can instead of
1111
// embedded-hal-0.2.7. embedded-can was split off from embedded-hal before it's upgrade to 1.0.0.
@@ -24,7 +24,7 @@ use riscv_rt::entry;
2424

2525
#[entry]
2626
fn main() -> ! {
27-
let peripherals = Peripherals::take().unwrap();
27+
let peripherals = Peripherals::take();
2828
let mut system = peripherals.SYSTEM.split();
2929
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
3030

@@ -77,29 +77,24 @@ fn main() -> ! {
7777
// Wait for a frame to be received.
7878
let frame = block!(can.receive()).unwrap();
7979

80-
writeln!(UsbSerialJtag, "Received a frame:").unwrap();
80+
println!("Received a frame:");
8181

8282
// Print different messages based on the frame id type.
8383
match frame.id() {
8484
Id::Standard(id) => {
85-
writeln!(UsbSerialJtag, "\tStandard Id: {:?}", id).unwrap();
85+
println!("\tStandard Id: {:?}", id);
8686
}
8787
Id::Extended(id) => {
88-
writeln!(UsbSerialJtag, "\tExtended Id: {:?}", id).unwrap();
88+
println!("\tExtended Id: {:?}", id);
8989
}
9090
}
9191

9292
// Print out the frame data or the requested data length code for a remote
9393
// transmission request frame.
9494
if frame.is_data_frame() {
95-
writeln!(UsbSerialJtag, "\tData: {:?}", frame.data()).unwrap();
95+
println!("\tData: {:?}", frame.data());
9696
} else {
97-
writeln!(
98-
UsbSerialJtag,
99-
"\tRemote Frame. Data Length Code: {}",
100-
frame.dlc()
101-
)
102-
.unwrap();
97+
println!("\tRemote Frame. Data Length Code: {}", frame.dlc());
10398
}
10499

105100
// Transmit the frame back.

0 commit comments

Comments
 (0)