Skip to content

Commit d4de1c2

Browse files
committed
hide ARMv7-M only peripherals on thumbv6m-none-eabi
1 parent bc31511 commit d4de1c2

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/peripheral/fpu.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
//! Floating Point Unit
22
3-
#[cfg(any(has_fpu, test))]
43
use volatile_register::{RO, RW};
54

65
/// Register block
76
#[repr(C)]
87
pub struct RegisterBlock {
98
reserved: u32,
109
/// Floating Point Context Control
11-
#[cfg(any(has_fpu, test))]
1210
pub fpccr: RW<u32>,
1311
/// Floating Point Context Address
14-
#[cfg(any(has_fpu, test))]
1512
pub fpcar: RW<u32>,
1613
/// Floating Point Default Status Control
17-
#[cfg(any(has_fpu, test))]
1814
pub fpdscr: RW<u32>,
1915
/// Media and FP Feature
20-
#[cfg(any(has_fpu, test))]
2116
pub mvfr: [RO<u32>; 3],
2217
}

src/peripheral/mod.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ pub mod cbp;
7979
pub mod cpuid;
8080
pub mod dcb;
8181
pub mod dwt;
82+
#[cfg(any(armv7m, test))]
8283
pub mod fpb;
84+
#[cfg(any(has_fpu, test))]
8385
pub mod fpu;
86+
#[cfg(any(armv7m, test))]
8487
pub mod itm;
8588
pub mod mpu;
8689
pub mod nvic;
8790
pub mod scb;
8891
pub mod syst;
92+
#[cfg(any(armv7m, test))]
8993
pub mod tpiu;
9094

9195
#[cfg(test)]
@@ -106,10 +110,13 @@ pub struct Peripherals {
106110
/// Data Watchpoint and Trace unit
107111
pub DWT: DWT,
108112
/// Flash Patch and Breakpoint unit
113+
#[cfg(armv7m)]
109114
pub FPB: FPB,
110115
/// Floating Point Unit
116+
#[cfg(has_fpu)]
111117
pub FPU: FPU,
112118
/// Instrumentation Trace Macrocell
119+
#[cfg(armv7m)]
113120
pub ITM: ITM,
114121
/// Memory Protection Unit
115122
pub MPU: MPU,
@@ -120,6 +127,7 @@ pub struct Peripherals {
120127
/// SysTick: System Timer
121128
pub SYST: SYST,
122129
/// Trace Port Interface Unit;
130+
#[cfg(armv7m)]
123131
pub TPIU: TPIU,
124132
}
125133

@@ -161,12 +169,15 @@ impl Peripherals {
161169
DWT: DWT {
162170
_marker: PhantomData,
163171
},
172+
#[cfg(armv7m)]
164173
FPB: FPB {
165174
_marker: PhantomData,
166175
},
176+
#[cfg(has_fpu)]
167177
FPU: FPU {
168178
_marker: PhantomData,
169179
},
180+
#[cfg(armv7m)]
170181
ITM: ITM {
171182
_marker: PhantomData,
172183
},
@@ -182,6 +193,7 @@ impl Peripherals {
182193
SYST: SYST {
183194
_marker: PhantomData,
184195
},
196+
#[cfg(armv7m)]
185197
TPIU: TPIU {
186198
_marker: PhantomData,
187199
},
@@ -282,17 +294,20 @@ impl Deref for DWT {
282294
}
283295

284296
/// Flash Patch and Breakpoint unit
297+
#[cfg(any(armv7m, test))]
285298
pub struct FPB {
286299
_marker: PhantomData<*const ()>,
287300
}
288301

302+
#[cfg(any(armv7m, test))]
289303
impl FPB {
290304
/// Returns a pointer to the register block
291305
pub fn ptr() -> *const fpb::RegisterBlock {
292306
0xE000_2000 as *const _
293307
}
294308
}
295309

310+
#[cfg(armv7m)]
296311
impl Deref for FPB {
297312
type Target = self::fpb::RegisterBlock;
298313

@@ -302,18 +317,20 @@ impl Deref for FPB {
302317
}
303318

304319
/// Floating Point Unit
320+
#[cfg(any(has_fpu, test))]
305321
pub struct FPU {
306322
_marker: PhantomData<*const ()>,
307323
}
308324

325+
#[cfg(any(has_fpu, test))]
309326
impl FPU {
310327
/// Returns a pointer to the register block
311328
pub fn ptr() -> *const fpu::RegisterBlock {
312329
0xE000_EF30 as *const _
313330
}
314331
}
315332

316-
#[cfg(any(has_fpu, test))]
333+
#[cfg(has_fpu)]
317334
impl Deref for FPU {
318335
type Target = self::fpu::RegisterBlock;
319336

@@ -323,17 +340,20 @@ impl Deref for FPU {
323340
}
324341

325342
/// Instrumentation Trace Macrocell
343+
#[cfg(any(armv7m, test))]
326344
pub struct ITM {
327345
_marker: PhantomData<*const ()>,
328346
}
329347

348+
#[cfg(any(armv7m, test))]
330349
impl ITM {
331350
/// Returns a pointer to the register block
332351
pub fn ptr() -> *mut itm::RegisterBlock {
333352
0xE000_0000 as *mut _
334353
}
335354
}
336355

356+
#[cfg(armv7m)]
337357
impl Deref for ITM {
338358
type Target = self::itm::RegisterBlock;
339359

@@ -342,6 +362,7 @@ impl Deref for ITM {
342362
}
343363
}
344364

365+
#[cfg(armv7m)]
345366
impl DerefMut for ITM {
346367
fn deref_mut(&mut self) -> &mut Self::Target {
347368
unsafe { &mut *Self::ptr() }
@@ -429,17 +450,20 @@ impl Deref for SYST {
429450
}
430451

431452
/// Trace Port Interface Unit;
453+
#[cfg(any(armv7m, test))]
432454
pub struct TPIU {
433455
_marker: PhantomData<*const ()>,
434456
}
435457

458+
#[cfg(any(armv7m, test))]
436459
impl TPIU {
437460
/// Returns a pointer to the register block
438461
pub fn ptr() -> *const tpiu::RegisterBlock {
439462
0xE004_0000 as *const _
440463
}
441464
}
442465

466+
#[cfg(armv7m)]
443467
impl Deref for TPIU {
444468
type Target = self::tpiu::RegisterBlock;
445469

0 commit comments

Comments
 (0)