aboutsummaryrefslogtreecommitdiff
path: root/src/peripheral
diff options
context:
space:
mode:
Diffstat (limited to 'src/peripheral')
-rw-r--r--src/peripheral/dwt.rs12
-rw-r--r--src/peripheral/mod.rs4
-rw-r--r--src/peripheral/sau.rs5
-rw-r--r--src/peripheral/tpiu.rs1
4 files changed, 15 insertions, 7 deletions
diff --git a/src/peripheral/dwt.rs b/src/peripheral/dwt.rs
index c5f7bc9..72575d3 100644
--- a/src/peripheral/dwt.rs
+++ b/src/peripheral/dwt.rs
@@ -155,6 +155,18 @@ impl DWT {
}
}
+ /// Disables the cycle counter
+ #[cfg(not(armv6m))]
+ #[inline]
+ pub fn disable_cycle_counter(&mut self) {
+ unsafe {
+ self.ctrl.modify(|mut r| {
+ r.set_cyccntena(false);
+ r
+ });
+ }
+ }
+
/// Returns `true` if the cycle counter is enabled
#[cfg(not(armv6m))]
#[inline]
diff --git a/src/peripheral/mod.rs b/src/peripheral/mod.rs
index af922b1..bf18151 100644
--- a/src/peripheral/mod.rs
+++ b/src/peripheral/mod.rs
@@ -60,8 +60,6 @@
use core::marker::PhantomData;
use core::ops;
-use crate::interrupt;
-
#[cfg(cm7)]
pub mod ac;
#[cfg(not(armv6m))]
@@ -165,7 +163,7 @@ impl Peripherals {
/// Returns all the core peripherals *once*
#[inline]
pub fn take() -> Option<Self> {
- interrupt::free(|_| {
+ critical_section::with(|_| {
if unsafe { TAKEN } {
None
} else {
diff --git a/src/peripheral/sau.rs b/src/peripheral/sau.rs
index da91aca..6b8477f 100644
--- a/src/peripheral/sau.rs
+++ b/src/peripheral/sau.rs
@@ -7,7 +7,6 @@
//!
//! For reference please check the section B8.3 of the Armv8-M Architecture Reference Manual.
-use crate::interrupt;
use crate::peripheral::SAU;
use bitfield::bitfield;
use volatile_register::{RO, RW};
@@ -162,7 +161,7 @@ impl SAU {
/// This function is executed under a critical section to prevent having inconsistent results.
#[inline]
pub fn set_region(&mut self, region_number: u8, region: SauRegion) -> Result<(), SauError> {
- interrupt::free(|_| {
+ critical_section::with(|_| {
let base_address = region.base_address;
let limit_address = region.limit_address;
let attribute = region.attribute;
@@ -215,7 +214,7 @@ impl SAU {
/// This function is executed under a critical section to prevent having inconsistent results.
#[inline]
pub fn get_region(&mut self, region_number: u8) -> Result<SauRegion, SauError> {
- interrupt::free(|_| {
+ critical_section::with(|_| {
if region_number >= self.region_numbers() {
Err(SauError::RegionNumberTooBig)
} else {
diff --git a/src/peripheral/tpiu.rs b/src/peripheral/tpiu.rs
index 0762495..14dd35c 100644
--- a/src/peripheral/tpiu.rs
+++ b/src/peripheral/tpiu.rs
@@ -118,7 +118,6 @@ impl TPIU {
/// [`trace_output_protocol`](Self::set_trace_output_protocol).
#[inline]
pub fn trace_output_protocol(&self) -> Option<TraceProtocol> {
- use core::convert::TryInto;
self.sppr.read().txmode().try_into().ok()
}