diff options
author | 2017-12-22 11:20:22 +0100 | |
---|---|---|
committer | 2017-12-23 19:08:04 +0100 | |
commit | 80328e98f361bd7ea07e3376691130790dae71a3 (patch) | |
tree | 24cb226132889f8b535a31d9a3babc766776afa8 /src/peripheral/cpuid.rs | |
parent | bdc7ca96c5593e410c8f49025d2b0fced7607a4d (diff) | |
download | cortex-m-80328e98f361bd7ea07e3376691130790dae71a3.tar.gz cortex-m-80328e98f361bd7ea07e3376691130790dae71a3.tar.zst cortex-m-80328e98f361bd7ea07e3376691130790dae71a3.zip |
revise peripheral API
closes #67
Diffstat (limited to 'src/peripheral/cpuid.rs')
-rw-r--r-- | src/peripheral/cpuid.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/peripheral/cpuid.rs b/src/peripheral/cpuid.rs index f0b7e6e..624d5c5 100644 --- a/src/peripheral/cpuid.rs +++ b/src/peripheral/cpuid.rs @@ -4,6 +4,9 @@ use volatile_register::RO; #[cfg(any(armv7m, test))] use volatile_register::RW; +#[cfg(armv7m)] +use peripheral::CPUID; + /// Register block #[repr(C)] pub struct RegisterBlock { @@ -45,14 +48,14 @@ pub enum CsselrCacheType { } #[cfg(armv7m)] -impl RegisterBlock { +impl CPUID { /// Selects the current CCSIDR /// /// * `level`: the required cache level minus 1, e.g. 0 for L1, 1 for L2 /// * `ind`: select instruction cache or data/unified cache /// /// `level` is masked to be between 0 and 7. - pub fn select_cache(&self, level: u8, ind: CsselrCacheType) { + pub fn select_cache(&mut self, level: u8, ind: CsselrCacheType) { const CSSELR_IND_POS: u32 = 0; const CSSELR_IND_MASK: u32 = 1 << CSSELR_IND_POS; const CSSELR_LEVEL_POS: u32 = 1; @@ -67,7 +70,7 @@ impl RegisterBlock { } /// Returns the number of sets and ways in the selected cache - pub fn cache_num_sets_ways(&self, level: u8, ind: CsselrCacheType) -> (u16, u16) { + pub fn cache_num_sets_ways(&mut self, level: u8, ind: CsselrCacheType) -> (u16, u16) { const CCSIDR_NUMSETS_POS: u32 = 13; const CCSIDR_NUMSETS_MASK: u32 = 0x7FFF << CCSIDR_NUMSETS_POS; const CCSIDR_ASSOCIATIVITY_POS: u32 = 3; |