Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Cortex-M7 r0p1 CPUs #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//! | ARMv7E-M | ARM® Cortex®-M4 r0p1 | `thumbv7em-none-eabi` | `cortexm4_r0p1` |
//! | ARMv7E-M | ARM® Cortex®-M4F r0p0 | `thumbv7em-none-eabihf` | `cortexm4f_r0p0` |
//! | ARMv7E-M | ARM® Cortex®-M4F r0p1 | `thumbv7em-none-eabihf` | `cortexm4f_r0p1` |
//! | ARMv7E-M | ARM® Cortex®-M7 r0p1 | `thumbv7em-none-eabihf` | `cortexm7_r0p1` |
//! | ARMv8-M | ARM® Cortex®-M33 r0p2 | `thumbv8m.main-none-eabi` | `cortexm33_r0p2` |
//! | ARMv8-M | ARM® Cortex®-M33 r0p3 | `thumbv8m.main-none-eabi` | `cortexm33_r0p3` |
//! | ARMv8-M | ARM® Cortex®-M33 r0p4 | `thumbv8m.main-none-eabi` | `cortexm33_r0p4` |
Expand Down
10 changes: 10 additions & 0 deletions src/map/reg/scb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,18 @@ 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 } };
/// Force exception stacking start in double word aligned address.
#[cfg(cortexm_core = "cortexm_r0p1")]
STKALIGN => { offset => 9; width => 1; traits => { RRRegField } };
/// Ignore data bus fault during HardFault and NMI handlers.
BFHFNMIGN => { offset => 8; width => 1; traits => { RRRegField WWRegField } };
/// Trap on divide by 0.
Expand Down
2 changes: 1 addition & 1 deletion src/reg/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ macro_rules! atomic_bits {
$strex,
input = in(reg) self,
address = in(reg) address,
status = lateout(reg) status,
status = out(reg) status,
options(nostack, preserves_flags),
);
}
Expand Down
15 changes: 15 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 @@ -62,8 +66,15 @@ pub struct ThrInitExtended {
#[inline]
pub fn init_extended<T: ThrsInitToken>(_token: T) -> (T::ThrTokens, ThrInitExtended) {
let scb_ccr = unsafe { scb::Ccr::<Srt>::take() };
#[cfg(not(cortexm_core = "cortexm7_r0p1"))]
scb_ccr.store(|r| r.set_stkalign().set_nonbasethrdena());
#[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 @@ -78,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