Skip to content

Commit 8ccf71e

Browse files
committed
Add IC/DC fields to SCB_CCR register
These fields are available only for Cortex-M targets with an instruction and data cache. As of now only Cortex-M7 and Cortex-M35P have options for these caches. Signed-off-by: Jean Pierre Dudey <[email protected]>
1 parent 9fb647d commit 8ccf71e

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ bit-band = []
4040
floating-point-unit = []
4141
memory-protection-unit = []
4242
security-extension = []
43+
instruction-cache = []
44+
data-cache = []
4345

4446
[dependencies.drone-cortexm-macros]
4547
version = "=0.14.1"

src/map/reg/scb.rs

+6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ reg! {
128128
reset => 0x0000_0200;
129129
traits => { RReg WReg };
130130
fields => {
131+
/// Enables L1 instruction cache.
132+
#[cfg(feature = "instruction-cache")]
133+
IC => { offset => 17; width => 1; traits => { RRRegField WWRegField } };
134+
/// Enables L1 data cache.
135+
#[cfg(feature = "data-cache")]
136+
DC => { offset => 16; width => 1; traits => { RRRegField WWRegField } };
131137
/// Force exception stacking start in double word aligned address.
132138
#[cfg(not(cortexm_core = "cortexm_r0p1"))]
133139
STKALIGN => { offset => 9; width => 1; traits => { RRRegField WWRegField } };

src/thr/init.rs

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ pub unsafe trait ThrsInitToken: Token {
1717
/// A set of register tokens returned by [`init_extended`].
1818
#[allow(missing_docs)]
1919
pub struct ThrInitExtended {
20+
#[cfg(feature = "instruction-cache")]
21+
pub scb_ccr_ic: scb::ccr::Ic<Srt>,
22+
#[cfg(feature = "data-cache")]
23+
pub scb_ccr_dc: scb::ccr::Dc<Srt>,
2024
pub scb_ccr_bfhfnmign: scb::ccr::Bfhfnmign<Srt>,
2125
pub scb_ccr_div_0_trp: scb::ccr::Div0Trp<Srt>,
2226
pub scb_ccr_unalign_trp: scb::ccr::UnalignTrp<Srt>,
@@ -67,6 +71,10 @@ pub fn init_extended<T: ThrsInitToken>(_token: T) -> (T::ThrTokens, ThrInitExten
6771
#[cfg(cortexm_core = "cortexm7_r0p1")]
6872
scb_ccr.store(|r| r.set_nonbasethrdena());
6973
let scb::Ccr {
74+
#[cfg(feature = "instruction-cache")]
75+
ic: scb_ccr_ic,
76+
#[cfg(feature = "data-cache")]
77+
dc: scb_ccr_dc,
7078
stkalign,
7179
bfhfnmign: scb_ccr_bfhfnmign,
7280
div_0_trp: scb_ccr_div_0_trp,
@@ -81,6 +89,10 @@ pub fn init_extended<T: ThrsInitToken>(_token: T) -> (T::ThrTokens, ThrInitExten
8189
drop(stkalign);
8290
drop(nonbasethrdena);
8391
(unsafe { T::ThrTokens::take() }, ThrInitExtended {
92+
#[cfg(feature = "instruction-cache")]
93+
scb_ccr_ic,
94+
#[cfg(feature = "data-cache")]
95+
scb_ccr_dc,
8496
scb_ccr_bfhfnmign,
8597
scb_ccr_div_0_trp,
8698
scb_ccr_unalign_trp,

0 commit comments

Comments
 (0)