From c290aa4ee89951a0ea503b129f6c5bd3d47a663d Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 11 May 2018 18:38:55 +0200 Subject: ARMv6-M: remove fields that are not available from NVIC and SCB --- src/peripheral/nvic.rs | 29 ++++++++++++++----- src/peripheral/scb.rs | 76 ++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 86 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/peripheral/nvic.rs b/src/peripheral/nvic.rs index 7ce31ba..1a6a027 100644 --- a/src/peripheral/nvic.rs +++ b/src/peripheral/nvic.rs @@ -1,6 +1,8 @@ //! Nested Vector Interrupt Controller -use volatile_register::{RO, RW}; +#[cfg(not(armv6m))] +use volatile_register::RO; +use volatile_register::RW; use interrupt::Nr; use peripheral::NVIC; @@ -10,19 +12,31 @@ use peripheral::NVIC; pub struct RegisterBlock { /// Interrupt Set-Enable pub iser: [RW; 16], - reserved0: [u32; 16], + + _reserved0: [u32; 16], + /// Interrupt Clear-Enable pub icer: [RW; 16], - reserved1: [u32; 16], + + _reserved1: [u32; 16], + /// Interrupt Set-Pending pub ispr: [RW; 16], - reserved2: [u32; 16], + + _reserved2: [u32; 16], + /// Interrupt Clear-Pending pub icpr: [RW; 16], - reserved3: [u32; 16], - /// Interrupt Active Bit + + _reserved3: [u32; 16], + + /// Interrupt Active Bit (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] pub iabr: [RO; 16], - reserved4: [u32; 48], + #[cfg(armv6m)] + _reserved4: [u32; 16], + + _reserved5: [u32; 48], #[cfg(not(armv6m))] /// Interrupt Priority @@ -110,6 +124,7 @@ impl NVIC { } /// Is `interrupt` active or pre-empted and stacked + #[cfg(not(armv6m))] pub fn is_active(interrupt: I) -> bool where I: Nr, diff --git a/src/peripheral/scb.rs b/src/peripheral/scb.rs index e31c902..0a3a66a 100644 --- a/src/peripheral/scb.rs +++ b/src/peripheral/scb.rs @@ -17,33 +17,85 @@ use super::SCB; pub struct RegisterBlock { /// Interrupt Control and State pub icsr: RW, - /// Vector Table Offset + + /// Vector Table Offset (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] pub vtor: RW, + #[cfg(armv6m)] + _reserved0: u32, + /// Application Interrupt and Reset Control pub aircr: RW, + /// System Control pub scr: RW, + /// Configuration and Control pub ccr: RW, - /// System Handler Priority + + /// System Handler Priority (word accessible only on Cortex-M0 variants) + /// + /// On ARMv7-M, `shpr[0]` points to SHPR1 + /// + /// On ARMv6-M, `shpr[0]` points to SHPR2 + #[cfg(not(armv6m))] pub shpr: [RW; 12], + #[cfg(armv6m)] + _reserved1: u32, + /// System Handler Priority (word accessible only on Cortex-M0 variants) + /// + /// On ARMv7-M, `shpr[0]` points to SHPR1 + /// + /// On ARMv6-M, `shpr[0]` points to SHPR2 + #[cfg(armv6m)] + pub shpr: [RW; 2], + /// System Handler Control and State - pub shpcrs: RW, - /// Configurable Fault Status + pub shcrs: RW, + + /// Configurable Fault Status (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] pub cfsr: RW, - /// HardFault Status + #[cfg(armv6m)] + _reserved2: u32, + + /// HardFault Status (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] pub hfsr: RW, - /// Debug Fault Status + #[cfg(armv6m)] + _reserved3: u32, + + /// Debug Fault Status (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] pub dfsr: RW, - /// MemManage Fault Address - pub mmar: RW, - /// BusFault Address + #[cfg(armv6m)] + _reserved4: u32, + + /// MemManage Fault Address (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] + pub mmfar: RW, + #[cfg(armv6m)] + _reserved5: u32, + + /// BusFault Address (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] pub bfar: RW, - /// Auxiliary Fault Status + #[cfg(armv6m)] + _reserved6: u32, + + /// Auxiliary Fault Status (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] pub afsr: RW, - reserved: [u32; 18], - /// Coprocessor Access Control + #[cfg(armv6m)] + _reserved7: u32, + + _reserved8: [u32; 18], + + /// Coprocessor Access Control (not present on Cortex-M0 variants) + #[cfg(not(armv6m))] pub cpacr: RW, + #[cfg(armv6m)] + _reserved9: u32, } /// FPU access mode -- cgit v1.2.3