Code:
#PICAXE 20X2 'One-Page-LoRa-Receiver.bas
#TERMINAL 9600
#no_data
#no_table
'AI LoRa module Ra-01_V1.0 Semtech SX1278. NOT BREADBOARD FRIENDLY !!!!!
'Power supply: 3.3V from computer USB via FTDI module
'
'LoRa Colour Picaxe
''''''''''''''''''''''''''''''''''''''''''''''''
'RESET Brown B.6
'3.3V Red +V THREE point THREE VOLTS !!!.!!!
'GND Black 0V GND
'SCK Yellow B.7 hspi sck
'MISO Orange B .5 hspi sdi
'MOSI Green C.1 hspi sdo
'NSS White B.3
'DIO0 Grey B.0 hint1 IRQ normally LOW pulled DOWN 10k
'ANT The antenna, if provided, or ~17cm wire
'
symbol NSS=B.3
symbol SXReset=B.6
symbol RXBase=0
output NSS
output SXReset
input B.0 ' INT from DIO0
main:
hspisetup spimode00,spifast
gosub SXSetup
hintsetup %00100010 'Rising edge on hint1 (B.0)
pause 5000 'Time to open terminal
setintflags %00000010,%00000010
sertxd("Waiting for data...",CR,LF)
loop1:
pause 100
goto loop1
SXSetup:
low SXReset
pauseus 100 'Reset pin low for 100us sets registers to reset values
high SXReset
pause 10 'Allow a little time for SX1278 to reset, minimum 5mS
low NSS
hspiout($81,$00) 'Can only set LoRa mode from sleep mode
high NSS
low NSS
hspiout($81,$88) 'LoRa, low frequency mode
high NSS
low NSS
HSPIOUT($91,$BF) 'Set up flags for RXdone IRQ
high NSS
low NSS
HSPIOUT($81,$8D) 'RXCONTINUOUS, low frequency, LoRa mode (start listening)
high NSS
return
interrupt:
hint1flag=0
hintflag=0 'Clear Picaxe interrupt flags
low NSS
HSPIOUT($92,$40) 'Clear LoRa IRQ flags
high NSS
low NSS
HSPIOUT($10)
HSPIIN(b1) 'Read last packet address
high NSS
low NSS
HSPIOUT($8D,b1) 'Set FifoAddrPtr to last packet address
high NSS
low NSS
HSPIOUT($00)
HSPIIN(b0) 'Read character from FIFO
high NSS
sertxd("Received ",#b0,CR,LF)
setintflags %00000010,%00000010 'Re-arm Picaxe interrupts
return
N'importe quel module à base de SX1276/78 devrait marcher.