-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Furi: smaller critical enter and critical exit macro (#2716)
* Furi: smaller critical enter and critical exit macro * api: bumped version --------- Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su>
- Loading branch information
1 parent
e4a2e9a
commit 3e1f209
Showing
4 changed files
with
47 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "common_defines.h" | ||
|
||
__FuriCriticalInfo __furi_critical_enter(void) { | ||
__FuriCriticalInfo info; | ||
|
||
info.isrm = 0; | ||
info.from_isr = FURI_IS_ISR(); | ||
info.kernel_running = (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING); | ||
|
||
if(info.from_isr) { | ||
info.isrm = taskENTER_CRITICAL_FROM_ISR(); | ||
} else if(info.kernel_running) { | ||
taskENTER_CRITICAL(); | ||
} else { | ||
__disable_irq(); | ||
} | ||
|
||
return info; | ||
} | ||
|
||
void __furi_critical_exit(__FuriCriticalInfo info) { | ||
if(info.from_isr) { | ||
taskEXIT_CRITICAL_FROM_ISR(info.isrm); | ||
} else if(info.kernel_running) { | ||
taskEXIT_CRITICAL(); | ||
} else { | ||
__enable_irq(); | ||
} | ||
} |