Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PeripheralRef init: uart #272

Merged
merged 6 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion esp-hal-common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ fn main() {
"uart2",
]
} else if esp32c2 {
vec!["esp32c2", "riscv", "single_core", "gdma", "systimer", "timg0"]
vec![
"esp32c2",
"riscv",
"single_core",
"gdma",
"systimer",
"timg0",
]
} else if esp32c3 {
vec![
"esp32c3",
Expand Down
8 changes: 6 additions & 2 deletions esp-hal-common/src/embassy/time_driver_systimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ impl EmbassyTimer {
}
}

pub(crate) fn set_alarm(&self, alarm: embassy_time::driver::AlarmHandle, timestamp: u64) -> bool {
pub(crate) fn set_alarm(
&self,
alarm: embassy_time::driver::AlarmHandle,
timestamp: u64,
) -> bool {
critical_section::with(|cs| {
let now = Self::now();
let alarm_state = unsafe { self.alarms.borrow(cs).get_unchecked(alarm.id() as usize) };
Expand Down Expand Up @@ -108,7 +112,7 @@ impl EmbassyTimer {
}

fn disable_interrupt(&self, id: u8) {
match id {
match id {
0 => self.alarm0.interrupt_enable(false),
1 => self.alarm1.interrupt_enable(false),
2 => self.alarm2.interrupt_enable(false),
Expand Down
8 changes: 6 additions & 2 deletions esp-hal-common/src/embassy/time_driver_timg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ impl EmbassyTimer {
}
}

pub(crate) fn set_alarm(&self, alarm: embassy_time::driver::AlarmHandle, timestamp: u64) -> bool {
pub(crate) fn set_alarm(
&self,
alarm: embassy_time::driver::AlarmHandle,
timestamp: u64,
) -> bool {
critical_section::with(|cs| {
let now = Self::now();
let alarm_state = unsafe { self.alarms.borrow(cs).get_unchecked(alarm.id() as usize) };
Expand All @@ -87,7 +91,7 @@ impl EmbassyTimer {
tg.set_auto_reload(false);
tg.set_counter_active(true);
tg.set_alarm_active(true);

true
})
}
Expand Down
4 changes: 3 additions & 1 deletion esp-hal-common/src/interrupt/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ mod vectored {
const CPU_INTERRUPT_EDGE: u32 = 0b_0111_0000_0100_0000_0000_1100_1000_0000;

#[inline]
fn cpu_interrupt_nr_to_cpu_interrupt_handler(number: u32) -> Option<unsafe extern "C" fn(u32, save_frame: &mut Context)> {
fn cpu_interrupt_nr_to_cpu_interrupt_handler(
number: u32,
) -> Option<unsafe extern "C" fn(u32, save_frame: &mut Context)> {
use xtensa_lx_rt::*;
// we're fortunate that all esp variants use the same CPU interrupt layout
Some(match number {
Expand Down
23 changes: 16 additions & 7 deletions esp-hal-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@
#![cfg_attr(xtensa, feature(asm_experimental_arch))]

#[cfg(esp32)]
pub use esp32 as pac;
pub(crate) use esp32 as pac;
#[cfg(esp32c2)]
pub use esp32c2 as pac;
pub(crate) use esp32c2 as pac;
#[cfg(esp32c3)]
pub use esp32c3 as pac;
pub(crate) use esp32c3 as pac;
#[cfg(esp32s2)]
pub use esp32s2 as pac;
pub(crate) use esp32s2 as pac;
#[cfg(esp32s3)]
pub use esp32s3 as pac;
pub(crate) use esp32s3 as pac;

#[cfg_attr(esp32, path = "peripherals/esp32.rs")]
#[cfg_attr(esp32c3, path = "peripherals/esp32c3.rs")]
#[cfg_attr(esp32c2, path = "peripherals/esp32c2.rs")]
#[cfg_attr(esp32s2, path = "peripherals/esp32s2.rs")]
#[cfg_attr(esp32s3, path = "peripherals/esp32s3.rs")]
pub mod peripherals;

pub use procmacros as macros;

#[cfg(rmt)]
Expand All @@ -43,9 +51,9 @@ pub use self::{
interrupt::*,
rng::Rng,
rtc_cntl::{Rtc, Rwdt},
serial::Serial,
spi::Spi,
timer::Timer,
uart::Uart,
};

pub mod analog;
Expand All @@ -63,19 +71,20 @@ pub mod ledc;
pub mod mcpwm;
#[cfg(usb_otg)]
pub mod otg_fs;
pub mod peripheral;
pub mod prelude;
#[cfg(rmt)]
pub mod pulse_control;
pub mod rng;
pub mod rom;
pub mod rtc_cntl;
pub mod serial;
pub mod sha;
pub mod spi;
pub mod system;
#[cfg(systimer)]
pub mod systimer;
pub mod timer;
pub mod uart;
#[cfg(usb_serial_jtag)]
pub mod usb_serial_jtag;
#[cfg(rmt)]
Expand Down
Loading