|
|
@@ -15,7 +15,7 @@ require"pins"
|
|
|
-- require "sx126x_reg"
|
|
|
require "Drv_spi"
|
|
|
require "sx126x_reg"
|
|
|
-
|
|
|
+-- TODU: 驱动文件要分开。我把redio.c的函数放到了驱动里面了,为了方便调试。
|
|
|
local SX126x = json.encode(sx126x_reg.SX126x_t)
|
|
|
local SX126xCopy,result,errinfo = json.decode(SX126x)
|
|
|
SX126x = nil
|
|
|
@@ -176,9 +176,9 @@ end
|
|
|
-- SX126xWriteCommand(sx126x_reg.RadioCommands.RADIO_SET_TX,buf)
|
|
|
-- end
|
|
|
|
|
|
-
|
|
|
+-- TODU : 参数配置问题,好像并不影响发生。这里主要是配置中断设置的。
|
|
|
function SX126xSetDioIrqParams(irqMask, dio1Mask, dio2Mask, dio3Mask )
|
|
|
- local buf = {"02","02","02","02","00","00","00","00"}
|
|
|
+ local buf = {"02","01","02","01","00","00","00","00"}
|
|
|
-- buf[2] = irqMask
|
|
|
-- buf[4] = irqMask
|
|
|
local jsondata = json.encode(buf)
|
|
|
@@ -201,6 +201,7 @@ function SX126xSetPacketType(packetType)
|
|
|
log.info("PacketType:",PacketType,sx126x_reg.RadioCommands.RADIO_SET_PACKETTYPE)
|
|
|
end
|
|
|
|
|
|
+-- 原驱动好像并没有启用,不晓得这个是什么功能
|
|
|
function RadioSetPublicNetwork(enable)
|
|
|
SX126xSetPacketType(sx126x_reg.RadioPacketTypes_t.PACKET_TYPE_LORA)
|
|
|
if enable == true then
|
|
|
@@ -278,12 +279,12 @@ function RadioSetTxConfig(modem,power,fdev,bandwidth,datarate,coderate,preambleL
|
|
|
SX126xCopy.ModulationParams.Params.LoRa.Bandwidth = "05"
|
|
|
SX126xCopy.ModulationParams.Params.LoRa.CodingRate= coderate
|
|
|
|
|
|
- -- if ( (bandwidth == 0) and ( (datarate == 11) or (datarate == 12) ) ) or ( (bandwidth == 1) and (datarate == 12) ) then
|
|
|
- -- SX126xCopy.ModulationParams.Params.LoRa.LowDatarateOptimize = 0x01
|
|
|
- -- else
|
|
|
- -- SX126xCopy.ModulationParams.Params.LoRa.LowDatarateOptimize = 0x00
|
|
|
- -- end
|
|
|
- SX126xCopy.ModulationParams.Params.LoRa.LowDatarateOptimize = "00"
|
|
|
+ if ( (bandwidth == 0) and ( (datarate == 11) or (datarate == 12) ) ) or ( (bandwidth == 1) and (datarate == 12) ) then
|
|
|
+ SX126xCopy.ModulationParams.Params.LoRa.LowDatarateOptimize = "01"
|
|
|
+ else
|
|
|
+ SX126xCopy.ModulationParams.Params.LoRa.LowDatarateOptimize = "00"
|
|
|
+ end
|
|
|
+ -- SX126xCopy.ModulationParams.Params.LoRa.LowDatarateOptimize = "00"
|
|
|
|
|
|
|
|
|
|
|
|
@@ -292,6 +293,7 @@ function RadioSetTxConfig(modem,power,fdev,bandwidth,datarate,coderate,preambleL
|
|
|
SX126xCopy.PacketParams.Params.LoRa.PreambleLength = preambleLen
|
|
|
|
|
|
SX126xCopy.PacketParams.Params.LoRa.HeaderType = fixLen
|
|
|
+ -- TODU:这里的FF写死了,应该不要写死。
|
|
|
SX126xCopy.PacketParams.Params.LoRa.PayloadLength = "FF"
|
|
|
SX126xCopy.PacketParams.Params.LoRa.CrcMode = crcOn
|
|
|
SX126xCopy.PacketParams.Params.LoRa.InvertIQ = iqInverted
|
|
|
@@ -384,9 +386,7 @@ function SX126xInit()
|
|
|
SX126xIoInit()
|
|
|
SX126xReset()
|
|
|
SX126xWakeup()
|
|
|
- -- local table = {sx126x_reg.RadioStandbyModes_t.STDBY_RC}
|
|
|
SX126xSetStandby(sx126x_reg.RadioStandbyModes_t.STDBY_RC)
|
|
|
- -- local table1 = {sx126x_reg.RadioStandbyModes_t.USE_DCDC}
|
|
|
SX126xSetRegulatorMode(sx126x_reg.RadioStandbyModes_t.USE_DCDC)
|
|
|
SX126xSetBufferBaseAddress("00","00")
|
|
|
SX126xSetTxParams( "00", sx126x_reg.RadioRampTimes_t.RADIO_RAMP_200_US )
|