Skip to content

Commit e41b273

Browse files
bors[bot]hug-dev
andauthored
Merge #181
181: Add cfg to Peripheral fields r=thejpster a=hug-dev The cfg conditional compilation attribute was only set on impl blocks of peripherals. This commit also sets it on the fields themselves to be more consistent. Also adds Armv8-M Baseline to the blacklist of the ITM peripheral (cf rule `FMQF` of the Armv8-M ARM). Co-authored-by: Hugues de Valon <[email protected]>
2 parents f2a56ec + 9c1a467 commit e41b273

File tree

7 files changed

+19
-15
lines changed

7 files changed

+19
-15
lines changed

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub mod asm;
6262
#[cfg(armv8m)]
6363
pub mod cmse;
6464
pub mod interrupt;
65-
#[cfg(not(armv6m))]
65+
#[cfg(all(not(armv6m), not(armv8m_base)))]
6666
pub mod itm;
6767
pub mod peripheral;
6868
pub mod register;

src/peripheral/cbp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Cache and branch predictor maintenance operations
22
//!
3-
//! *NOTE* Available only on ARMv7-M (`thumbv7*m-none-eabi*`)
3+
//! *NOTE* Not available on Armv6-M.
44
55
use volatile_register::WO;
66

src/peripheral/fpb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Flash Patch and Breakpoint unit
22
//!
3-
//! *NOTE* Available only on ARMv7-M (`thumbv7*m-none-eabi*`)
3+
//! *NOTE* Not available on Armv6-M.
44
55
use volatile_register::{RO, RW, WO};
66

src/peripheral/fpu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Floating Point Unit
22
//!
3-
//! *NOTE* Available only on ARMv7E-M (`thumbv7em-none-eabihf`)
3+
//! *NOTE* Available only on targets with a Floating Point Unit (FPU) extension.
44
55
use volatile_register::{RO, RW};
66

src/peripheral/itm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Instrumentation Trace Macrocell
22
//!
3-
//! *NOTE* Available only on ARMv7-M (`thumbv7*m-none-eabi*`)
3+
//! *NOTE* Not available on Armv6-M and Armv8-M Baseline.
44
55
use core::cell::UnsafeCell;
66
use core::ptr;

src/peripheral/mod.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub mod fpb;
7272
// NOTE(target_arch) is for documentation purposes
7373
#[cfg(any(has_fpu, target_arch = "x86_64"))]
7474
pub mod fpu;
75-
#[cfg(not(armv6m))]
75+
#[cfg(all(not(armv6m), not(armv8m_base)))]
7676
pub mod itm;
7777
pub mod mpu;
7878
pub mod nvic;
@@ -91,7 +91,8 @@ mod test;
9191
/// Core peripherals
9292
#[allow(non_snake_case)]
9393
pub struct Peripherals {
94-
/// Cache and branch predictor maintenance operations (not present on Cortex-M0 variants)
94+
/// Cache and branch predictor maintenance operations.
95+
/// Not available on Armv6-M.
9596
pub CBP: CBP,
9697

9798
/// CPUID
@@ -103,13 +104,15 @@ pub struct Peripherals {
103104
/// Data Watchpoint and Trace unit
104105
pub DWT: DWT,
105106

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

109-
/// Floating Point Unit (only present on `thumbv7em-none-eabihf`)
111+
/// Floating Point Unit.
110112
pub FPU: FPU,
111113

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

115118
/// Memory Protection Unit
@@ -127,7 +130,8 @@ pub struct Peripherals {
127130
/// SysTick: System Timer
128131
pub SYST: SYST,
129132

130-
/// Trace Port Interface Unit (not present on Cortex-M0 variants)
133+
/// Trace Port Interface Unit.
134+
/// Not available on Armv6-M.
131135
pub TPIU: TPIU,
132136

133137
// Private field making `Peripherals` non-exhaustive. We don't use `#[non_exhaustive]` so we
@@ -367,7 +371,7 @@ pub struct ITM {
367371

368372
unsafe impl Send for ITM {}
369373

370-
#[cfg(not(armv6m))]
374+
#[cfg(all(not(armv6m), not(armv8m_base)))]
371375
impl ITM {
372376
/// Returns a pointer to the register block
373377
#[inline(always)]
@@ -376,7 +380,7 @@ impl ITM {
376380
}
377381
}
378382

379-
#[cfg(not(armv6m))]
383+
#[cfg(all(not(armv6m), not(armv8m_base)))]
380384
impl ops::Deref for ITM {
381385
type Target = self::itm::RegisterBlock;
382386

@@ -386,7 +390,7 @@ impl ops::Deref for ITM {
386390
}
387391
}
388392

389-
#[cfg(not(armv6m))]
393+
#[cfg(all(not(armv6m), not(armv8m_base)))]
390394
impl ops::DerefMut for ITM {
391395
#[inline(always)]
392396
fn deref_mut(&mut self) -> &mut Self::Target {

src/peripheral/tpiu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Trace Port Interface Unit;
22
//!
3-
//! *NOTE* Available only on ARMv7-M (`thumbv7*m-none-eabi*`)
3+
//! *NOTE* Not available on Armv6-M.
44
55
use volatile_register::{RO, RW, WO};
66

0 commit comments

Comments
 (0)