Skip to content

Commit c290aa4

Browse files
committed
ARMv6-M: remove fields that are not available from NVIC and SCB
1 parent 716398c commit c290aa4

File tree

3 files changed

+101
-19
lines changed

3 files changed

+101
-19
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2323
- [breaking-change] Some variants of the `Exception` enumeration are no longer available on
2424
`thumbv6m-none-eabi`. See API docs for details.
2525

26+
- [breaking-change] fixed typo in `shcrs` field of `scb::RegisterBlock`; it was previously named
27+
`shpcrs`.
28+
29+
- [breaking-change] removed several fields from `scb::RegisterBlock` on ARMv6-M. These registers are
30+
not available on that sub-architecture.
31+
32+
- [breaking-change] changed the type of `scb::RegisterBlock.shpr` from `RW<u8>` to `RW<u32>` on
33+
ARMv6-M. These registers are word accessible only on that sub-architecture.
34+
35+
- [breaking-change] renamed the `mmar` field of `scb::RegisterBlock` to `mmfar` to match the CMSIS
36+
name.
37+
38+
- [breaking-change] removed the `iabr` field from `scb::RegisterBlock` on ARMv6-M. This register is
39+
not available on that sub-architecture.
40+
2641
### Removed
2742

2843
- [breaking-change] The `exception` module has been removed. A replacement for `Exception::active`

src/peripheral/nvic.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Nested Vector Interrupt Controller
22
3-
use volatile_register::{RO, RW};
3+
#[cfg(not(armv6m))]
4+
use volatile_register::RO;
5+
use volatile_register::RW;
46

57
use interrupt::Nr;
68
use peripheral::NVIC;
@@ -10,19 +12,31 @@ use peripheral::NVIC;
1012
pub struct RegisterBlock {
1113
/// Interrupt Set-Enable
1214
pub iser: [RW<u32>; 16],
13-
reserved0: [u32; 16],
15+
16+
_reserved0: [u32; 16],
17+
1418
/// Interrupt Clear-Enable
1519
pub icer: [RW<u32>; 16],
16-
reserved1: [u32; 16],
20+
21+
_reserved1: [u32; 16],
22+
1723
/// Interrupt Set-Pending
1824
pub ispr: [RW<u32>; 16],
19-
reserved2: [u32; 16],
25+
26+
_reserved2: [u32; 16],
27+
2028
/// Interrupt Clear-Pending
2129
pub icpr: [RW<u32>; 16],
22-
reserved3: [u32; 16],
23-
/// Interrupt Active Bit
30+
31+
_reserved3: [u32; 16],
32+
33+
/// Interrupt Active Bit (not present on Cortex-M0 variants)
34+
#[cfg(not(armv6m))]
2435
pub iabr: [RO<u32>; 16],
25-
reserved4: [u32; 48],
36+
#[cfg(armv6m)]
37+
_reserved4: [u32; 16],
38+
39+
_reserved5: [u32; 48],
2640

2741
#[cfg(not(armv6m))]
2842
/// Interrupt Priority
@@ -110,6 +124,7 @@ impl NVIC {
110124
}
111125

112126
/// Is `interrupt` active or pre-empted and stacked
127+
#[cfg(not(armv6m))]
113128
pub fn is_active<I>(interrupt: I) -> bool
114129
where
115130
I: Nr,

src/peripheral/scb.rs

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,85 @@ use super::SCB;
1717
pub struct RegisterBlock {
1818
/// Interrupt Control and State
1919
pub icsr: RW<u32>,
20-
/// Vector Table Offset
20+
21+
/// Vector Table Offset (not present on Cortex-M0 variants)
22+
#[cfg(not(armv6m))]
2123
pub vtor: RW<u32>,
24+
#[cfg(armv6m)]
25+
_reserved0: u32,
26+
2227
/// Application Interrupt and Reset Control
2328
pub aircr: RW<u32>,
29+
2430
/// System Control
2531
pub scr: RW<u32>,
32+
2633
/// Configuration and Control
2734
pub ccr: RW<u32>,
28-
/// System Handler Priority
35+
36+
/// System Handler Priority (word accessible only on Cortex-M0 variants)
37+
///
38+
/// On ARMv7-M, `shpr[0]` points to SHPR1
39+
///
40+
/// On ARMv6-M, `shpr[0]` points to SHPR2
41+
#[cfg(not(armv6m))]
2942
pub shpr: [RW<u8>; 12],
43+
#[cfg(armv6m)]
44+
_reserved1: u32,
45+
/// System Handler Priority (word accessible only on Cortex-M0 variants)
46+
///
47+
/// On ARMv7-M, `shpr[0]` points to SHPR1
48+
///
49+
/// On ARMv6-M, `shpr[0]` points to SHPR2
50+
#[cfg(armv6m)]
51+
pub shpr: [RW<u32>; 2],
52+
3053
/// System Handler Control and State
31-
pub shpcrs: RW<u32>,
32-
/// Configurable Fault Status
54+
pub shcrs: RW<u32>,
55+
56+
/// Configurable Fault Status (not present on Cortex-M0 variants)
57+
#[cfg(not(armv6m))]
3358
pub cfsr: RW<u32>,
34-
/// HardFault Status
59+
#[cfg(armv6m)]
60+
_reserved2: u32,
61+
62+
/// HardFault Status (not present on Cortex-M0 variants)
63+
#[cfg(not(armv6m))]
3564
pub hfsr: RW<u32>,
36-
/// Debug Fault Status
65+
#[cfg(armv6m)]
66+
_reserved3: u32,
67+
68+
/// Debug Fault Status (not present on Cortex-M0 variants)
69+
#[cfg(not(armv6m))]
3770
pub dfsr: RW<u32>,
38-
/// MemManage Fault Address
39-
pub mmar: RW<u32>,
40-
/// BusFault Address
71+
#[cfg(armv6m)]
72+
_reserved4: u32,
73+
74+
/// MemManage Fault Address (not present on Cortex-M0 variants)
75+
#[cfg(not(armv6m))]
76+
pub mmfar: RW<u32>,
77+
#[cfg(armv6m)]
78+
_reserved5: u32,
79+
80+
/// BusFault Address (not present on Cortex-M0 variants)
81+
#[cfg(not(armv6m))]
4182
pub bfar: RW<u32>,
42-
/// Auxiliary Fault Status
83+
#[cfg(armv6m)]
84+
_reserved6: u32,
85+
86+
/// Auxiliary Fault Status (not present on Cortex-M0 variants)
87+
#[cfg(not(armv6m))]
4388
pub afsr: RW<u32>,
44-
reserved: [u32; 18],
45-
/// Coprocessor Access Control
89+
#[cfg(armv6m)]
90+
_reserved7: u32,
91+
92+
_reserved8: [u32; 18],
93+
94+
/// Coprocessor Access Control (not present on Cortex-M0 variants)
95+
#[cfg(not(armv6m))]
4696
pub cpacr: RW<u32>,
97+
#[cfg(armv6m)]
98+
_reserved9: u32,
4799
}
48100

49101
/// FPU access mode

0 commit comments

Comments
 (0)