Skip to content

Commit

Permalink
fix basepri setting for enabling/disabling interrupts
Browse files Browse the repository at this point in the history
  • Loading branch information
shengwen-tw committed Nov 25, 2023
1 parent 153c38c commit ed833c9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions kernel/arch/v7m_entry.S
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
#include <common/linkage.h>

#define PRI_THRESHOLD #1
/* NVIC Priority Group 4:
* Group priority bits: PRI_M[7:4]
* Subpriority bits: None
* By setting BASEPRI to 16 (1 << 4),
* All interrupts with priority value lower than 0 will be disable.
* (Lower priority value has higher priority)
*/
#define PRI_THRESHOLD #16

.syntax unified

.macro irq_disable
push {r0}
mov r0, PRI_THRESHOLD /* Set priority threshold to 1 */
mov r0, PRI_THRESHOLD
msr basepri, r0
pop {r0}
.endm

.macro irq_enable
push {r0}
mov r0, #0 /* No priority threshold is set */
mov r0, #0
msr basepri, r0
pop {r0}
.endm
Expand Down

0 comments on commit ed833c9

Please sign in to comment.