Skip to content

Add cfg to Peripheral fields #181

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

Merged
merged 1 commit into from
Apr 15, 2020
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
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub mod asm;
#[cfg(armv8m)]
pub mod cmse;
pub mod interrupt;
#[cfg(not(armv6m))]
#[cfg(all(not(armv6m), not(armv8m_base)))]
pub mod itm;
pub mod peripheral;
pub mod register;
Expand Down
2 changes: 1 addition & 1 deletion src/peripheral/cbp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Cache and branch predictor maintenance operations
//!
//! *NOTE* Available only on ARMv7-M (`thumbv7*m-none-eabi*`)
//! *NOTE* Not available on Armv6-M.

use volatile_register::WO;

Expand Down
2 changes: 1 addition & 1 deletion src/peripheral/fpb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Flash Patch and Breakpoint unit
//!
//! *NOTE* Available only on ARMv7-M (`thumbv7*m-none-eabi*`)
//! *NOTE* Not available on Armv6-M.

use volatile_register::{RO, RW, WO};

Expand Down
2 changes: 1 addition & 1 deletion src/peripheral/fpu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Floating Point Unit
//!
//! *NOTE* Available only on ARMv7E-M (`thumbv7em-none-eabihf`)
//! *NOTE* Available only on targets with a Floating Point Unit (FPU) extension.

use volatile_register::{RO, RW};

Expand Down
2 changes: 1 addition & 1 deletion src/peripheral/itm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Instrumentation Trace Macrocell
//!
//! *NOTE* Available only on ARMv7-M (`thumbv7*m-none-eabi*`)
//! *NOTE* Not available on Armv6-M and Armv8-M Baseline.

use core::cell::UnsafeCell;
use core::ptr;
Expand Down
22 changes: 13 additions & 9 deletions src/peripheral/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub mod fpb;
// NOTE(target_arch) is for documentation purposes
#[cfg(any(has_fpu, target_arch = "x86_64"))]
pub mod fpu;
#[cfg(not(armv6m))]
#[cfg(all(not(armv6m), not(armv8m_base)))]
pub mod itm;
pub mod mpu;
pub mod nvic;
Expand All @@ -90,7 +90,8 @@ mod test;
/// Core peripherals
#[allow(non_snake_case)]
pub struct Peripherals {
/// Cache and branch predictor maintenance operations (not present on Cortex-M0 variants)
/// Cache and branch predictor maintenance operations.
/// Not available on Armv6-M.
pub CBP: CBP,

/// CPUID
Expand All @@ -102,13 +103,15 @@ pub struct Peripherals {
/// Data Watchpoint and Trace unit
pub DWT: DWT,

/// Flash Patch and Breakpoint unit (not present on Cortex-M0 variants)
/// Flash Patch and Breakpoint unit.
/// Not available on Armv6-M.
pub FPB: FPB,

/// Floating Point Unit (only present on `thumbv7em-none-eabihf`)
/// Floating Point Unit.
pub FPU: FPU,

/// Instrumentation Trace Macrocell (not present on Cortex-M0 variants)
/// Instrumentation Trace Macrocell.
/// Not available on Armv6-M and Armv8-M Baseline.
pub ITM: ITM,

/// Memory Protection Unit
Expand All @@ -123,7 +126,8 @@ pub struct Peripherals {
/// SysTick: System Timer
pub SYST: SYST,

/// Trace Port Interface Unit (not present on Cortex-M0 variants)
/// Trace Port Interface Unit.
/// Not available on Armv6-M.
pub TPIU: TPIU,

// Private field making `Peripherals` non-exhaustive. We don't use `#[non_exhaustive]` so we
Expand Down Expand Up @@ -360,7 +364,7 @@ pub struct ITM {

unsafe impl Send for ITM {}

#[cfg(not(armv6m))]
#[cfg(all(not(armv6m), not(armv8m_base)))]
impl ITM {
/// Returns a pointer to the register block
#[inline(always)]
Expand All @@ -369,7 +373,7 @@ impl ITM {
}
}

#[cfg(not(armv6m))]
#[cfg(all(not(armv6m), not(armv8m_base)))]
impl ops::Deref for ITM {
type Target = self::itm::RegisterBlock;

Expand All @@ -379,7 +383,7 @@ impl ops::Deref for ITM {
}
}

#[cfg(not(armv6m))]
#[cfg(all(not(armv6m), not(armv8m_base)))]
impl ops::DerefMut for ITM {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Target {
Expand Down
2 changes: 1 addition & 1 deletion src/peripheral/tpiu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Trace Port Interface Unit;
//!
//! *NOTE* Available only on ARMv7-M (`thumbv7*m-none-eabi*`)
//! *NOTE* Not available on Armv6-M.

use volatile_register::{RO, RW, WO};

Expand Down