-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.s
157 lines (108 loc) · 3.31 KB
/
main.s
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AREA RESET, DATA, READONLY
ALIGN
GET samd21g18a.inc
GET vectors.inc
GET macroses.inc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AREA |.text|, CODE, READONLY
ALIGN
GBLA GCNT
GCNT SETA 0
tmpa RN R1
tmpd RN R2
trPacket RN R6
tmp RN R7
; Events Register Flags
_MEIF_ EQU 0 ; Main Event Interval Flag
_RDF_ EQU 1 ; Run Display Flag
_DF_ EQU 2 ; Delay Flag
_NSF_ EQU 3 ; No Sleep Flag
_GSIF_ EQU 4 ; Global Software Interrupt is on Flag
_TF_ EQU 5 ; Ticker MAX7219 Flag
_DEV0_ EQU 12 ; Device 0 is ready to use
_DEV1_ EQU 13 ; Device 1 is ready to use
_DEV2_ EQU 14 ; Device 2 is ready to use
_DEV3_ EQU 15 ; Device 3 is ready to use
_DEV4_ EQU 16 ; Device 4 is ready to use
_DEV5_ EQU 17 ; Device 5 is ready to use
_DEV6_ EQU 18 ; Device 6 is ready to use
_DEV7_ EQU 19 ; Device 7 is ready to use
_DEV8_ EQU 20 ; Device 8 is ready to use
_DEV9_ EQU 21 ; Device 9 is ready to use
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENTRY
AREA |.text|, CODE, READONLY
GET init.inc
GET spi.inc
;======================== MAIN Loop ===========================;
MAIN PROC
FLAG_CHK "clear", _EREG_, _MEIF_, _MAIN_check_delay
FLAG "clear", _EREG_, (1<<_MEIF_)
BL LED_BLINK
BL MEASURMENT
_MAIN_check_delay
FLAG_CHK "clear", _EREG_, _DF_, _MAIN_run_ticker
FLAG "set", _EREG_, (1<<_NSF_)
LDR tmpa, =TC5
LDRB tmpd, [tmpa, #TC_STATUS_offset]
LSRS tmpd, #TC_STATUS_STOP_Pos + 1
BCC _MAIN_check_sleep
FLAG "clear", _EREG_, (1<<_NSF_)
LDR tmpa, =_DELAY_wait_exit
MOV PC, tmpa
_MAIN_run_ticker
FLAG_CHK "clear", _EREG_, _TF_, _MAIN_check_sleep
FLAG "clear", _EREG_, (1<<_TF_)
BL TICKER
_MAIN_check_sleep
FLAG_CHK "set", _EREG_, _NSF_, MAIN
_MAIN_sleep
WFI
B.N MAIN
_MAIN_exit
B.N MAIN
ENDP
;==============================================================;
;===================== BMP280 MEASUREMENT =====================;
MEASURMENT PROC
PUSH {LR}
FLAG_CHK "set", _EREG_, _GSIF_, _MEASURMENT_exit ; check global software interrupt, if it's on, then exit
FLAG "set", _EREG_, (1<<_GSIF_)
BL BMP280_MEASURMENT
FLAG "clear", _EREG_, (1<<_GSIF_)
_MEASURMENT_exit
POP {PC}
ENDP
;==============================================================;
;======================= MAX 7219 Ticker ======================;
TICKER PROC
PUSH {LR}
FLAG_CHK "set", _EREG_, _GSIF_, _TICKER_exit ; check global software interrupt, if it's on, then exit
FLAG "set", _EREG_, (1<<_GSIF_)
BL MAX7219_RUN
FLAG "clear", _EREG_, (1<<_GSIF_)
_TICKER_exit
POP {PC}
ENDP
;==============================================================;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AREA |.text|, CODE, READONLY
ALIGN
GET utils.inc
GET interrupts.inc
GET max7219.inc
GET bmp280.inc
GET var.inc
END