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

Change target_arch cfgs to chip features #185

Merged
merged 1 commit into from
Sep 13, 2022
Merged
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
15 changes: 8 additions & 7 deletions esp-hal-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! [esp32s3-hal]: https://github.com/esp-rs/esp-hal/tree/main/esp32s3-hal

#![no_std]
#![cfg_attr(target_arch = "xtensa", feature(asm_experimental_arch))]
#![cfg_attr(not(feature = "esp32c3"), feature(asm_experimental_arch))]

#[cfg(feature = "esp32")]
pub use esp32 as pac;
Expand All @@ -38,8 +38,8 @@ pub mod efuse;

pub mod gpio;
pub mod i2c;
#[cfg_attr(target_arch = "riscv32", path = "interrupt/riscv.rs")]
#[cfg_attr(target_arch = "xtensa", path = "interrupt/xtensa.rs")]
#[cfg_attr(feature = "esp32c3", path = "interrupt/riscv.rs")]
#[cfg_attr(not(feature = "esp32c3"), path = "interrupt/xtensa.rs")]
pub mod interrupt;
pub mod ledc;
pub mod prelude;
Expand Down Expand Up @@ -90,12 +90,13 @@ pub enum Cpu {
}

pub fn get_core() -> Cpu {
#[cfg(all(target_arch = "xtensa", feature = "multi_core"))]
#[cfg(all(not(feature = "esp32c3"), feature = "multi_core"))]
match ((xtensa_lx::get_processor_id() >> 13) & 1) != 0 {
false => Cpu::ProCpu,
true => Cpu::AppCpu,
}
// #[cfg(all(target_arch = "riscv32", feature = "multi_core"))]

// #[cfg(all(feature = "esp32c3", feature = "multi_core"))]
// TODO get hart_id

// single core always has ProCpu only
Expand All @@ -108,7 +109,7 @@ mod critical_section_impl {

critical_section::set_impl!(CriticalSection);

#[cfg(target_arch = "xtensa")]
#[cfg(not(feature = "esp32c3"))]
mod xtensa {

unsafe impl critical_section::Impl for super::CriticalSection {
Expand Down Expand Up @@ -139,7 +140,7 @@ mod critical_section_impl {
}
}

#[cfg(target_arch = "riscv32")]
#[cfg(feature = "esp32c3")]
mod riscv {
unsafe impl critical_section::Impl for super::CriticalSection {
unsafe fn acquire() -> critical_section::RawRestoreState {
Expand Down