-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.con.sx1231.spin
346 lines (292 loc) · 13.1 KB
/
core.con.sx1231.spin
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
{
----------------------------------------------------------------------------------------------------
Filename: core.con.sx1231.spin
Description: SX1231-specific constants
Author: Jesse Burt
Started: Apr 19, 2019
Updated: Oct 14, 2024
Copyright (c) 2024 - See end of file for terms of use.
----------------------------------------------------------------------------------------------------
}
CON
' SPI Configuration
SCK_MAX_FREQ = 10_000_000
SPI_MODE = 0
T_POR = 10_000 ' uSec
T_RESACTIVE = 100
T_RES = 5_000
SPI_WR = 1 << 7 ' wnr bit (Write access)
' Register definitions
FIFO = $00
OPMODE = $01
OPMODE_MASK = $FC
SEQOFF = 7
LISTENON = 6
LISTENABT = 5
MODE = 2
MODE_BITS = %111
SEQOFF_MASK = (1 << SEQOFF) ^ OPMODE_MASK
LISTENON_MASK = (1 << LISTENON) ^ OPMODE_MASK
LISTENABT_MASK = (1 << LISTENABT) ^ OPMODE_MASK
MODE_MASK = (MODE_BITS << MODE) ^ OPMODE_MASK
DATAMOD = $02
DATAMOD_MASK = $6B
DATAMODE = 5
MODTYPE = 3
MODSHP = 0
DATAMODE_BITS = %11
MODTYPE_BITS = %11
MODSHP_BITS = %11
DATAMODE_MASK = (DATAMODE_BITS << DATAMODE) ^ DATAMOD_MASK
MODTYPE_MASK = (MODTYPE_BITS << MODTYPE) ^ DATAMOD_MASK
MODSHP_MASK = MODSHP_BITS ^ DATAMOD_MASK
BITRATEMSB = $03
BITRATELSB = $04
BITRATE_MASK = $FFFF
FDEVMSB = $05
FDEVLSB = $06
FDEV_MASK = $3FFF
FRFMSB = $07
FRFMID = $08
FRFLSB = $09
FRF_MASK = $FF_FF_FF
OSC1 = $0A
OSC1_MASK = $81
RCCALSTART = 7 ' W/O
RCCALDONE = 6 ' R/O
OSC1_RSVD = %000001
RCCALSTART_MASK = (1 << RCCALSTART) ^ OSC1_MASK
AFCCTRL = $0B
AFCCTRL_MASK = $20
AFCLOWBETAON = 5
AFCLOWBETAON_MASK = (1 << AFCLOWBETAON) ^ AFCCTRL_MASK
LOWBAT = $0C
LOWBAT_MASK = $1F
LOWBATMON = 4
LOWBATON = 3
LOWBATTRIM = 0
LOWBATTRIM_BITS = %111
LOWBATMON_MASK = (1 << LOWBATMON) ^ LOWBAT_MASK
LOWBATON_MASK = (1 << LOWBATON) ^ LOWBAT_MASK
LOWBATTRIM_MASK = LOWBATTRIM_BITS ^ LOWBAT_MASK
LISTEN1 = $0D
LISTEN2 = $0E
LISTEN3 = $0F
VERSION = $10
PALVL = $11
PALVL_MASK = $FF
PA0ON = 7
PA1ON = 6
PA2ON = 5
OUTPWR = 0
PA012_BITS = %111
OUTPWR_BITS = %11111
PA0ON_MASK = (1 << PA0ON) ^ PALVL_MASK
PA1ON_MASK = (1 << PA1ON) ^ PALVL_MASK
PA2ON_MASK = (1 << PA2ON) ^ PALVL_MASK
PA012ON_MASK = (PA012_BITS << PA2ON) ^ PALVL_MASK
OUTPWR_MASK = OUTPWR_BITS ^ PALVL_MASK
PARAMP = $12
PARAMP_MASK = $0F
PA_RAMP = 0
PA_RAMP_BITS = %1111
OCP = $13
OCP_MASK = $1F
OCPON = 4
OCPTRIM = 0
OCPTRIM_BITS = %1111
OCPON_MASK = (1 << OCPON) ^ OCP_MASK
OCPTRIM_MASK = OCPTRIM_BITS ^ OCP_MASK
LNA = $18
LNA_MASK = $BF
LNAZIN = 7
LNACURRGAIN = 3
LNAGAINSEL = 0
LNACURRGAIN_BITS = %111
LNAGAINSEL_BITS = %111
LNAZIN_MASK = (1 << LNAZIN) ^ LNA_MASK
LNACURRGAIN_MASK = (LNACURRGAIN_BITS << LNACURRGAIN) ^ LNA_MASK
LNAGAINSEL_MASK = LNAGAINSEL_BITS ^ LNA_MASK
RXBW = $19
RXBW_MASK = $FF
DCCFREQ = 5
RXBWMANT = 3
RXBWEXP = 0
RX_BW = 0
DCCFREQ_BITS = %111
RXBWMANT_BITS = %11
RXBWEXP_BITS = %111
RX_BW_BITS = %11111
DCCFREQ_MASK = (DCCFREQ_BITS << DCCFREQ) ^ RXBW_MASK
RXBWMANT_MASK = (RXBWMANT_BITS << RXBWMANT) ^ RXBW_MASK
RXBWEXP_MASK = (RXBWEXP_BITS << RXBWEXP) ^ RXBW_MASK
RX_BW_MASK = RX_BW_BITS ^ RXBW_MASK
AFCBW = $1A
OOKPEAK = $1B
OOKAVG = $1C
OOKFIX = $1D
AFCFEI = $1E
AFCFEI_MASK = $7F
FEIDONE = 6 'R/O
FEISTART = 5 'W/O
AFCDONE = 4 'R/O
AFCAUTOCLRON = 3 'R/W
AFCAUTOON = 2 'R/W
AFCCLR = 1 'W/O
AFCSTART = 0 'W/O
FEIDONE_MASK = (1 << FEIDONE) ^ AFCFEI_MASK
FEISTART_MASK = (1 << FEISTART) ^ AFCFEI_MASK
AFCDONE_MASK = (1 << AFCDONE) ^ AFCFEI_MASK
AFCAUTOCLRON_MASK = (1 << AFCAUTOCLRON) ^ AFCFEI_MASK
AFCAUTOON_MASK = (1 << AFCAUTOON) ^ AFCFEI_MASK
AFCCLR_MASK = (1 << AFCCLR) ^ AFCFEI_MASK
AFCSTART_MASK = 1 ^ AFCFEI_MASK
AFCMSB = $1F
AFCLSB = $20
FEIMSB = $21
FEILSB = $22
RSSICFG = $23
RSSIDONE = %10
RSSIVALUE = $24
DIOMAP1 = $25
DIOMAP1_MASK = $FF
DIO0 = 6
DIO1 = 4
DIO2 = 2
DIO3 = 0
DIO_BITS = %11 ' used for all DIOx fields
DIO0_MASK = (DIO_BITS << DIO0) ^ DIOMAP1_MASK
DIO1_MASK = (DIO_BITS << DIO1) ^ DIOMAP1_MASK
DIO2_MASK = (DIO_BITS << DIO2) ^ DIOMAP1_MASK
DIO3_MASK = (DIO_BITS << DIO3) ^ DIOMAP1_MASK
DIOMAP2 = $26
DIOMAP2_MASK = $F7
DIO4 = 6
DIO5 = 4
CLKOUT = 0
CLKOUT_BITS = %111
DIO4_MASK = (DIO_BITS << DIO4) ^ DIOMAP2_MASK
DIO5_MASK = (DIO_BITS << DIO5) ^ DIOMAP2_MASK
CLKOUT_MASK = CLKOUT_BITS ^ DIOMAP2_MASK
IRQFLAGS1 = $27
IRQFLAGS1_MASK = $FF
MODERDY = 7
RXRDY = 6
TXRDY = 5
PLLLOCK = 4
RSSI = 3
TMOUT = 2
AUTOMD = 1
SYNCADDRMATCH = 0
IRQFLAGS2 = $28
IRQFLAGS2_MASK = $FF
FIFOFULL = 7
FIFONOTEMPTY = 6
FIFOLVL = 5
FIFOOVERRUN = 4
PKTSENT = 3
PAYLOADREADY = 2
CRCOK = 1
LOWBATT = 0
RSSITHRESH = $29
RXTIMEOUT1 = $2A
RXTIMEOUT2 = $2B
PREAMBLEMSB = $2C
PREAMBLELSB = $2D
SYNCCFG = $2E
SYNCCFG_MASK = $FF
SYNCON = 7
FIFOFILLCOND = 6
SYNCSIZE = 3
SYNCTOL = 0
SYNCSIZE_BITS = %111
SYNCTOL_BITS = %111
SYNCON_MASK = (1 << SYNCON) ^ SYNCCFG_MASK
FIFOFILLCOND_MASK = (1 << FIFOFILLCOND) ^ SYNCCFG_MASK
SYNCSIZE_MASK = (SYNCSIZE_BITS << SYNCSIZE) ^ SYNCCFG_MASK
SYNCTOL_MASK = SYNCTOL_BITS ^ SYNCCFG_MASK
#$2F, SYNCVALUE1, SYNCVALUE2, SYNCVALUE3, SYNCVALUE4, SYNCVALUE5,{
} SYNCVALUE6, SYNCVALUE7, SYNCVALUE8
PKTCFG1 = $37
PKTCFG1_MASK = $FE
PKTFORMAT = 7
DCFREE = 5
CRCON = 4
CRCAUTOCLROFF = 3
ADDRFILT = 1
DCFREE_BITS = %11
ADDRFILT_BITS = %11
PKTFORMAT_MASK = (1 << PKTFORMAT) ^ PKTCFG1_MASK
DCFREE_MASK = (DCFREE_BITS << DCFREE) ^ PKTCFG1_MASK
CRCON_MASK = (1 << CRCON) ^ PKTCFG1_MASK
CRCAUTOCLROFF_MASK = (1 << CRCAUTOCLROFF) ^ PKTCFG1_MASK
ADDRFILT_MASK = ADDRFILT_BITS ^ PKTCFG1_MASK
PAYLOADLENGTH = $38
NODEADRS = $39
BCASTADRS = $3A
AUTOMODES = $3B
AUTOMODES_MASK = $FF
ENTCOND = 5
EXITCOND = 2
INTMDTMODE = 0
ENTCOND_BITS = %111
EXITCOND_BITS = %111
INTMDTMODE_BITS = %11
ENTCOND_MASK = (ENTCOND_BITS << ENTCOND) ^ AUTOMODES_MASK
EXITCOND_MASK = (EXITCOND_BITS << EXITCOND) ^ AUTOMODES_MASK
INTMDTMODE_MASK = INTMDTMODE_BITS ^ AUTOMODES_MASK
FIFOTHRESH = $3C
FIFOTHRESH_MASK = $FF
TXSTARTCOND = 7
FIFOTHRESHOLD = 0
FIFOTHRESHOLD_BITS = %1111111
TXSTARTCOND_MASK = (1 << TXSTARTCOND) ^ FIFOTHRESH_MASK
FIFOTHRESHOLD_MASK = FIFOTHRESHOLD_BITS ^ FIFOTHRESH_MASK
PKTCFG2 = $3D
PKTCFG2_MASK = $F7
INTPKTDLY = 4
RSTARTRX = 2
AUTORSTARTRXON = 1
AESON = 0
INTPKTDLY_BITS = %1111
INTPKTDLY_MASK = (INTPKTDLY_BITS << INTPKTDLY) ^ PKTCFG2_MASK
RSTARTRX_MASK = (1 << RSTARTRX) ^ PKTCFG2_MASK
AUTORSTARTRXON_MASK = (1 << AUTORSTARTRXON) ^ PKTCFG2_MASK
AESON_MASK = 1 ^ PKTCFG2_MASK
#$3E, AESKEY1, AESKEY2, AESKEY3, AESKEY4, AESKEY5, AESKEY6, AESKEY7,{
} AESKEY8, AESKEY9, AESKEY10, AESKEY11, AESKEY12, AESKEY13, AESKEY14,{
} AESKEY15, AESKEY16
TEMP1 = $4E
TEMP1_MASK = $0C
TEMPMEASSTART = 3
TEMPMEASRUN = 2
TEMP2 = $4F
TESTLNA = $58
TESTTCXO = $59
TESTPA1 = $5A
PA1_NORMAL = $55
PA1_BOOST = $5D
TESTPA2 = $5C
PA2_NORMAL = $70
PA2_BOOST = $7C
TESTLLBW = $5F
TESTDAGC = $6F
TESTAFC = $71
PUB null()
' This is not a top-level object
DAT
{
Copyright 2024 Jesse Burt
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}