forked from juju2013/touchled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interrupt.fs
74 lines (70 loc) · 1.41 KB
/
interrupt.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
\ nRF52 NVIC words
\ Copyright (C) 2018 juju2013@github
\ BSD licensed, See LICENSE
\ standard cortex M NVIC
$E000E100 constant ISER
$E000E180 constant ICER
$E000E200 constant ISPR
$E000E280 constant ICPR
$E000E400 constant IPR0
$E000EF00 constant STIR
\ enable irq #
: irq.en ( # -- )
dup 31 > if
32 - bit ISER 4 + !
else
bit ISER !
then
;
\ disable irq #
: irq.den ( # -- )
dup 31 > if
32 - bit ICER 4 + !
else
bit ICER !
then
;
\ trigger irq #, how to clear interrupt status is this case ?
: irq ( # -- )
STIR !
;
: &exti ( pin -- mask addr ) \ return exti mask and addresse for pin
dup $0f and 4 /mod 2 lshift afio-exticr1 + ( pin remain addr )
-rot swap 8 rshift swap 2 lshift lshift swap
( mask addr )
;
: +exti ( pin -- ) \ enable exti for pin
&exti bis!
;
: -exti ( pin -- ) \ disable exti for pin
&exti bic!
;
: extien ( pin -- )
$0f and bit exti-imr bis!
;
: +exti.irq ( pin -- )
$0f and bit exti-imr bis!
;
: -exti.irq ( pin -- )
$0f and bit
dup exti-imr bic!
exti-pr bis! \ clear pr
;
: +exti.evt ( pin -- )
$0f and bit exti-emr bis!
;
: -exti.evt ( pin -- )
$0f and bit exti-emr bic!
;
: +exti.raise ( pin -- )
$0f and bit exti-rtsr bis!
;
: -exti.raise ( pin -- )
$0f and bit exti-rtsr bic!
;
: +exti.fall ( pin -- )
$0f and bit exti-ftsr bis!
;
: -exti.fall ( pin -- )
$0f and bit exti-ftsr bic!
;