-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
interrupt::free
with critical_section::with
.
- Loading branch information
1 parent
0d94e3b
commit a3c5b41
Showing
12 changed files
with
71 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
use crate::interrupt; | ||
use crate::register::primask::{self, Primask}; | ||
#[cfg(all(cortex_m, feature = "single-core-critical-section"))] | ||
mod single_core_critical_section { | ||
use crate::interrupt; | ||
use crate::register::primask::{self, Primask}; | ||
|
||
struct CriticalSection; | ||
critical_section::custom_impl!(CriticalSection); | ||
struct CriticalSection; | ||
critical_section::custom_impl!(CriticalSection); | ||
|
||
const TOKEN_IGNORE: u8 = 0; | ||
const TOKEN_REENABLE: u8 = 1; | ||
const TOKEN_IGNORE: u8 = 0; | ||
const TOKEN_REENABLE: u8 = 1; | ||
|
||
unsafe impl critical_section::Impl for CriticalSection { | ||
unsafe fn acquire() -> u8 { | ||
match primask::read() { | ||
Primask::Active => { | ||
interrupt::disable(); | ||
TOKEN_REENABLE | ||
unsafe impl critical_section::Impl for CriticalSection { | ||
unsafe fn acquire() -> u8 { | ||
match primask::read() { | ||
Primask::Active => { | ||
interrupt::disable(); | ||
TOKEN_REENABLE | ||
} | ||
Primask::Inactive => TOKEN_IGNORE, | ||
} | ||
Primask::Inactive => TOKEN_IGNORE, | ||
} | ||
} | ||
|
||
unsafe fn release(token: u8) { | ||
// Only re-enable interrupts if they were enabled before the critical section. | ||
if token == TOKEN_REENABLE { | ||
interrupt::enable() | ||
unsafe fn release(token: u8) { | ||
// Only re-enable interrupts if they were enabled before the critical section. | ||
if token == TOKEN_REENABLE { | ||
interrupt::enable() | ||
} | ||
} | ||
} | ||
} | ||
|
||
pub use critical_section::with; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters