Skip to content

Commit

Permalink
Add IC/DC fields to SCB_CCR register
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jeandudey committed Jul 21, 2021
1 parent 9fb647d commit 8ccf71e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ bit-band = []
floating-point-unit = []
memory-protection-unit = []
security-extension = []
instruction-cache = []
data-cache = []

[dependencies.drone-cortexm-macros]
version = "=0.14.1"
Expand Down
6 changes: 6 additions & 0 deletions src/map/reg/scb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ reg! {
reset => 0x0000_0200;
traits => { RReg WReg };
fields => {
/// Enables L1 instruction cache.
#[cfg(feature = "instruction-cache")]
IC => { offset => 17; width => 1; traits => { RRRegField WWRegField } };
/// Enables L1 data cache.
#[cfg(feature = "data-cache")]
DC => { offset => 16; width => 1; traits => { RRRegField WWRegField } };
/// Force exception stacking start in double word aligned address.
#[cfg(not(cortexm_core = "cortexm_r0p1"))]
STKALIGN => { offset => 9; width => 1; traits => { RRRegField WWRegField } };
Expand Down
12 changes: 12 additions & 0 deletions src/thr/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ pub unsafe trait ThrsInitToken: Token {
/// A set of register tokens returned by [`init_extended`].
#[allow(missing_docs)]
pub struct ThrInitExtended {
#[cfg(feature = "instruction-cache")]
pub scb_ccr_ic: scb::ccr::Ic<Srt>,
#[cfg(feature = "data-cache")]
pub scb_ccr_dc: scb::ccr::Dc<Srt>,
pub scb_ccr_bfhfnmign: scb::ccr::Bfhfnmign<Srt>,
pub scb_ccr_div_0_trp: scb::ccr::Div0Trp<Srt>,
pub scb_ccr_unalign_trp: scb::ccr::UnalignTrp<Srt>,
Expand Down Expand Up @@ -67,6 +71,10 @@ pub fn init_extended<T: ThrsInitToken>(_token: T) -> (T::ThrTokens, ThrInitExten
#[cfg(cortexm_core = "cortexm7_r0p1")]
scb_ccr.store(|r| r.set_nonbasethrdena());
let scb::Ccr {
#[cfg(feature = "instruction-cache")]
ic: scb_ccr_ic,
#[cfg(feature = "data-cache")]
dc: scb_ccr_dc,
stkalign,
bfhfnmign: scb_ccr_bfhfnmign,
div_0_trp: scb_ccr_div_0_trp,
Expand All @@ -81,6 +89,10 @@ pub fn init_extended<T: ThrsInitToken>(_token: T) -> (T::ThrTokens, ThrInitExten
drop(stkalign);
drop(nonbasethrdena);
(unsafe { T::ThrTokens::take() }, ThrInitExtended {
#[cfg(feature = "instruction-cache")]
scb_ccr_ic,
#[cfg(feature = "data-cache")]
scb_ccr_dc,
scb_ccr_bfhfnmign,
scb_ccr_div_0_trp,
scb_ccr_unalign_trp,
Expand Down

0 comments on commit 8ccf71e

Please sign in to comment.