
\ ----------------------------
\  Interrupt controller tools
\ ----------------------------

$E000E100 constant en0 ( Interrupt Set Enable )
$E000E104 constant en1 ( Interrupt Set Enable )
$E000E108 constant en2 ( Interrupt Set Enable )
$E000E10C constant en3 ( Interrupt Set Enable )

: nvic-enable ( irq# -- )
  16 - \ Cortex Core Vectors
  dup 32 u< if      1 swap lshift en0 bis! exit then
  dup 64 u< if 32 - 1 swap lshift en1 bis! exit then
  dup 96 u< if 64 - 1 swap lshift en2 bis! exit then
               96 - 1 swap lshift en3 bis!
;

: nvic-disable ( irq# -- )
  16 - \ Cortex Core Vectors
  dup 32 u< if      1 swap lshift en0 bic! exit then
  dup 64 u< if 32 - 1 swap lshift en1 bic! exit then
  dup 96 u< if 64 - 1 swap lshift en2 bic! exit then
               96 - 1 swap lshift en3 bic!
;
 
