forked from loboris/mecrisp-stellaris
-
Notifications
You must be signed in to change notification settings - Fork 1
/
radio.s
218 lines (200 loc) · 4.45 KB
/
radio.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
.equ RADIO, 0x40001000
.equ RADIO_TXEN, RADIO 0x000
.equ RADIO_RXEN, RADIO 0x004
.equ RADIO_START, RADIO 0x008
.equ RADIO_STOP, RADIO 0x00C
.equ RADIO_DISABLE, RADIO 0x010
.equ RADIO_READY, RADIO 0x100
.equ RADIO_DISABLED, RADIO 0x110
.equ RADIO_SHORTS, RADIO 0x200
.equ RADIO_PACKETPTR, RADIO 0x504
.equ RADIO_FREQUENCY, RADIO 0x508
.equ RADIO_TXPOWER, RADIO 0x50C
.equ RADIO_MODE, RADIO 0x510
.equ RADIO_PCNF0, RADIO 0x514
.equ RADIO_PCNF1, RADIO 0x518
.equ RADIO_BASE0, RADIO 0x51C
.equ RADIO_BASE1, RADIO 0x520
.equ RADIO_PREFIX0, RADIO 0x524
.equ RADIO_PREFIX1, RADIO 0x528
.equ RADIO_TXADDRESS, RADIO 0x52C
.equ RADIO_RXADDRESSES, RADIO 0x530
.equ RADIO_CRCCNF, RADIO 0x534
.equ RADIO_CRCPOLY, RADIO 0x538
.equ RADIO_CRCINIT, RADIO 0x53C
.equ RADIO_DATAWHITEIV, RADIO 0x554
.equ RADIO_POWER, RADIO 0xFFC
Wortbirne Flag_visible, "init_radio"
init_radio: @ ( -- )
@ 0 RADIO_POWER !
ldr r1, =RADIO_POWER
movs r0, #0
str r0, [r1]
@ 1 RADIO_POWER !
movs r0, #1
str r0, [r1]
@ 3 RADIO_MODE !
ldr r1, =RADIO_MODE
movs r0, #3
str r0, [r1]
@ 20106 RADIO_PCNF0 !
ldr r1, =RADIO_PCNF0
ldr r0, =0x20106
str r0, [r1]
@ 2030027 RADIO_PCNF1 !
ldr r1, =RADIO_PCNF1
ldr r0, =0x2030027
str r0, [r1]
@ 89BED600 dup RADIO_BASE0 ! RADIO_BASE1 !
ldr r1, =RADIO_BASE0
ldr r0, =0x89BED600
str r0, [r1]
ldr r1, =RADIO_BASE1
str r0, [r1]
@ 8E dup RADIO_PREFIX0 ! RADIO_PREFIX1 !
ldr r1, =RADIO_PREFIX0
movs r0, #0x8E
str r0, [r1]
ldr r1, =RADIO_PREFIX1
str r0, [r1]
@ 0 RADIO_TXADDRESS !
ldr r1, =RADIO_TXADDRESS
movs r0, #0
str r0, [r1]
@ 0 RADIO_RXADDRESSES !
ldr r1, =RADIO_RXADDRESSES
str r0, [r1]
@ 103 RADIO_CRCCNF !
ldr r1, =RADIO_CRCCNF
ldr r0, =0x103
str r0, [r1]
@ 000065B RADIO_CRCPOLY !
ldr r1, =RADIO_CRCPOLY
ldr r0, =0x65B
str r0, [r1]
@ 555555 RADIO_CRCINIT !
ldr r1, =RADIO_CRCINIT
ldr r0, =0x555555
str r0, [r1]
@ 3 RADIO_SHORTS ! ( Ready -> Start & End -> Disable )
ldr r1, =RADIO_SHORTS
movs r0, #0x3
str r0, [r1]
bx lr
Wortbirne Flag_visible, "set_radio_power"
set_radio_power: @ ( F -- )
ldr r1, =RADIO_TXPOWER
popda r0
str r0, [r1]
bx lr
Wortbirne Flag_visible, "set_ble_chan"
set_ble_chan: @ ( C -- )
ldr r1, =RADIO_DATAWHITEIV
popda r0
str r0, [r1]
@ case
@ 25 of 2 endof
movs r1, #2
cmp r0, #0x25
beq 1f
@ 26 of 1A endof
movs r1, #0x1A
cmp r0, #0x26
beq 1f
@ 27 of 50 endof
movs r1, #0X50
cmp r0, #0x27
beq 1f
@ dup dup A <= ?of 2* 4 endof
mov r1, r0
add r1, r1
movs r2, #4
add r1, r2
cmp r0, #0xA
ble 1f
@ dup 2* 6 swap
movs r2, #2
add r1, r2
@ endcase
1:
@ RADIO_FREQUENCY !
ldr r0, =RADIO_FREQUENCY
str r1, [r0]
bx lr
Wortbirne Flag_visible, "radio_send"
radio_send: @ ( le_ch, .pkt -- )
push {lr}
@ RADIO_PACKETPTR !
ldr r1, =RADIO_PACKETPTR
popda r0
str r0, [r1]
bl set_ble_chan
@ 0 RADIO_DISABLED !
ldr r1, =RADIO_DISABLED
movs r0, #0
str r0, [r1]
@ 1 RADIO_TXEN !
ldr r1, =RADIO_TXEN
movs r0, #1
str r0, [r1]
@;
pop {pc}
Wortbirne Flag_visible, "radio_receive"
radio_receive: @ ( le_ch, .pkt -- )
push {lr}
@ RADIO_PACKETPTR !
ldr r1, =RADIO_PACKETPTR
popda r0
str r0, [r1]
bl set_ble_chan
@ 0 RADIO_DISABLED !
ldr r1, =RADIO_DISABLED
movs r0, #0
str r0, [r1]
@ 1 RADIO_RXEN !
ldr r1, =RADIO_RXEN
movs r0, #1
str r0, [r1]
@;
pop {pc}
Wortbirne Flag_visible, "wait_radio_disabled"
wait_radio_disabled: @ ( -- )
ldr r1, =RADIO_DISABLED
2:
ldr r0, [r1]
cmp r0, #0
beq 2b
movs r0, #0
str r0, [r1]
bx lr
Wortbirne Flag_visible, "radio_disable"
radio_disable: @ ( -- )
ldr r1, =RADIO_DISABLE
movs r0, #1
str r0, [r1]
bx lr
Wortbirne Flag_visible, "radio_stop"
radio_stop: @ ( -- )
ldr r1, =RADIO_STOP
movs r0, #1
str r0, [r1]
bx lr
Wortbirne Flag_visible, "clear_radio_event"
clear_radio_event: @ ( E# -- )
popda r0
add r0, r0
add r0, r0
ldr r1, =RADIO_READY
add r1, r0
movs r0, #0
str r0, [r1]
bx lr
Wortbirne Flag_visible, "get_radio_event"
radio_task: @ ( E# -- E )
add tos, tos
add tos, tos
ldr r1, =RADIO_READY
add r1, tos
ldr tos, [r1]
bx lr
.ltorg