diff options
author | 2022-08-11 01:49:33 +0200 | |
---|---|---|
committer | 2022-08-11 23:31:08 +0200 | |
commit | 3a15a6b4b320fa328e8ab99c31f81536960dd280 (patch) | |
tree | 4c3ef55e91988845873479460e438afea445c919 /cortex-m-semihosting | |
parent | 4e908625204a1e95dd3fd5bdcd8d66d6bc11c3bc (diff) | |
download | cortex-m-3a15a6b4b320fa328e8ab99c31f81536960dd280.tar.gz cortex-m-3a15a6b4b320fa328e8ab99c31f81536960dd280.tar.zst cortex-m-3a15a6b4b320fa328e8ab99c31f81536960dd280.zip |
Add implementation for critical-section 1.0
Co-Authored-By: Markus Reiter <me@reitermark.us>
Diffstat (limited to 'cortex-m-semihosting')
-rw-r--r-- | cortex-m-semihosting/Cargo.toml | 1 | ||||
-rw-r--r-- | cortex-m-semihosting/src/export.rs | 10 |
2 files changed, 5 insertions, 6 deletions
diff --git a/cortex-m-semihosting/Cargo.toml b/cortex-m-semihosting/Cargo.toml index 5afe0ac..ac0afa5 100644 --- a/cortex-m-semihosting/Cargo.toml +++ b/cortex-m-semihosting/Cargo.toml @@ -21,3 +21,4 @@ no-semihosting = [] [dependencies] cortex-m = { path = "..", version = ">= 0.5.8, < 0.8" } +critical-section = "1.0.0" diff --git a/cortex-m-semihosting/src/export.rs b/cortex-m-semihosting/src/export.rs index 0bbd09f..46e70e7 100644 --- a/cortex-m-semihosting/src/export.rs +++ b/cortex-m-semihosting/src/export.rs @@ -2,14 +2,12 @@ use core::fmt::{self, Write}; -use cortex_m::interrupt; - use crate::hio::{self, HostStream}; static mut HSTDOUT: Option<HostStream> = None; pub fn hstdout_str(s: &str) { - let _result = interrupt::free(|_| unsafe { + let _result = critical_section::with(|_| unsafe { if HSTDOUT.is_none() { HSTDOUT = Some(hio::hstdout()?); } @@ -19,7 +17,7 @@ pub fn hstdout_str(s: &str) { } pub fn hstdout_fmt(args: fmt::Arguments) { - let _result = interrupt::free(|_| unsafe { + let _result = critical_section::with(|_| unsafe { if HSTDOUT.is_none() { HSTDOUT = Some(hio::hstdout()?); } @@ -31,7 +29,7 @@ pub fn hstdout_fmt(args: fmt::Arguments) { static mut HSTDERR: Option<HostStream> = None; pub fn hstderr_str(s: &str) { - let _result = interrupt::free(|_| unsafe { + let _result = critical_section::with(|_| unsafe { if HSTDERR.is_none() { HSTDERR = Some(hio::hstderr()?); } @@ -41,7 +39,7 @@ pub fn hstderr_str(s: &str) { } pub fn hstderr_fmt(args: fmt::Arguments) { - let _result = interrupt::free(|_| unsafe { + let _result = critical_section::with(|_| unsafe { if HSTDERR.is_none() { HSTDERR = Some(hio::hstderr()?); } |