aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/register/basepri.rs15
-rw-r--r--src/register/basepri_max.rs15
2 files changed, 26 insertions, 4 deletions
diff --git a/src/register/basepri.rs b/src/register/basepri.rs
index a024d74..c9be9d3 100644
--- a/src/register/basepri.rs
+++ b/src/register/basepri.rs
@@ -18,11 +18,22 @@ pub fn read() -> u8 {
}
/// Writes to the CPU register
+///
+/// **IMPORTANT** If you are using a Cortex-M7 device with revision r0p1 you MUST enable the
+/// `cm7-r0p1` Cargo feature or this function WILL misbehave.
+#[cfg_attr(not(target_arch = "arm"), allow(unused_variables))]
#[inline]
-pub unsafe fn write(_basepri: u8) {
+pub unsafe fn write(basepri: u8) {
match () {
#[cfg(target_arch = "arm")]
- () => asm!("msr BASEPRI, $0" :: "r"(_basepri) : "memory" : "volatile"),
+ () => match () {
+ #[cfg(not(feature = "cm7-r0p1"))]
+ () => asm!("msr BASEPRI, $0" :: "r"(basepri) : "memory" : "volatile"),
+ #[cfg(feature = "cm7-r0p1")]
+ () => asm!("cpsid i
+ msr BASEPRI, $0
+ cpsie i" :: "r"(basepri) : "memory" : "volatile"),
+ },
#[cfg(not(target_arch = "arm"))]
() => unimplemented!(),
}
diff --git a/src/register/basepri_max.rs b/src/register/basepri_max.rs
index 0833aa7..c386e86 100644
--- a/src/register/basepri_max.rs
+++ b/src/register/basepri_max.rs
@@ -4,12 +4,23 @@
///
/// - `basepri != 0` AND `basepri::read() == 0`, OR
/// - `basepri != 0` AND `basepri < basepri::read()`
+///
+/// **IMPORTANT** If you are using a Cortex-M7 device with revision r0p1 you MUST enable the
+/// `cm7-r0p1` Cargo feature or this function WILL misbehave.
+#[cfg_attr(not(target_arch = "arm"), allow(unused_variables))]
#[inline]
-pub fn write(_basepri: u8) {
+pub fn write(basepri: u8) {
match () {
#[cfg(target_arch = "arm")]
() => unsafe {
- asm!("msr BASEPRI_MAX, $0" :: "r"(_basepri) : "memory" : "volatile");
+ match () {
+ #[cfg(not(feature = "cm7-r0p1"))]
+ () => asm!("msr BASEPRI_MAX, $0" :: "r"(basepri) : "memory" : "volatile"),
+ #[cfg(feature = "cm7-r0p1")]
+ () => asm!("cpsid i
+ msr BASEPRI_MAX, $0
+ cpsie i" :: "r"(basepri) : "memory" : "volatile"),
+ }
},
#[cfg(not(target_arch = "arm"))]
() => unimplemented!(),