mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-17 21:23:58 +00:00
sx126x, sx127x: remove extra Lora in functions to avoid stuttering
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -77,7 +77,7 @@ func main() {
|
|||||||
|
|
||||||
println("main: Receiving Lora for 10 seconds")
|
println("main: Receiving Lora for 10 seconds")
|
||||||
for int(time.Now().Sub(tStart).Seconds()) < 10 {
|
for int(time.Now().Sub(tStart).Seconds()) < 10 {
|
||||||
buf, err := loraRadio.LoraRx(LORA_DEFAULT_RXTIMEOUT_MS)
|
buf, err := loraRadio.Rx(LORA_DEFAULT_RXTIMEOUT_MS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("RX Error: ", err)
|
println("RX Error: ", err)
|
||||||
} else if buf != nil {
|
} else if buf != nil {
|
||||||
@@ -86,7 +86,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
println("main: End Lora RX")
|
println("main: End Lora RX")
|
||||||
println("LORA TX size=", len(txmsg), " -> ", string(txmsg))
|
println("LORA TX size=", len(txmsg), " -> ", string(txmsg))
|
||||||
err := loraRadio.LoraTx(txmsg, LORA_DEFAULT_TXTIMEOUT_MS)
|
err := loraRadio.Tx(txmsg, LORA_DEFAULT_TXTIMEOUT_MS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("TX Error:", err)
|
println("TX Error:", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func main() {
|
|||||||
|
|
||||||
println("main: Receiving Lora for 10 seconds")
|
println("main: Receiving Lora for 10 seconds")
|
||||||
for time.Since(tStart) < 10*time.Second {
|
for time.Since(tStart) < 10*time.Second {
|
||||||
buf, err := loraRadio.LoraRx(LORA_DEFAULT_RXTIMEOUT_MS)
|
buf, err := loraRadio.Rx(LORA_DEFAULT_RXTIMEOUT_MS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("RX Error: ", err)
|
println("RX Error: ", err)
|
||||||
} else if buf != nil {
|
} else if buf != nil {
|
||||||
@@ -96,7 +96,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
println("main: End Lora RX")
|
println("main: End Lora RX")
|
||||||
println("LORA TX size=", len(txmsg), " -> ", string(txmsg))
|
println("LORA TX size=", len(txmsg), " -> ", string(txmsg))
|
||||||
err := loraRadio.LoraTx(txmsg, LORA_DEFAULT_TXTIMEOUT_MS)
|
err := loraRadio.Tx(txmsg, LORA_DEFAULT_TXTIMEOUT_MS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("TX Error:", err)
|
println("TX Error:", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-20
@@ -133,7 +133,7 @@ func (d *Device) SetTxContinuousWave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetTxContinuousPreamble set device in test mode to constantly modulate LoRa preamble symbols.
|
// SetTxContinuousPreamble set device in test mode to constantly modulate LoRa preamble symbols.
|
||||||
// Take care to initialize all Lora settings like it's done in LoraTx before calling this function
|
// Take care to initialize all Lora settings like it's done in Tx before calling this function
|
||||||
// If you don't init properly all the settings, it'll fail
|
// If you don't init properly all the settings, it'll fail
|
||||||
func (d *Device) SetTxContinuousPreamble() {
|
func (d *Device) SetTxContinuousPreamble() {
|
||||||
if d.rfswitch != nil {
|
if d.rfswitch != nil {
|
||||||
@@ -372,8 +372,8 @@ func (d *Device) GetSyncWord() uint16 {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraPublicNetwork sets Sync Word to 0x3444 (Public) or 0x1424 (Private)
|
// SetPublicNetwork sets Sync Word to 0x3444 (Public) or 0x1424 (Private)
|
||||||
func (d *Device) SetLoraPublicNetwork(enable bool) {
|
func (d *Device) SetPublicNetwork(enable bool) {
|
||||||
if enable {
|
if enable {
|
||||||
d.SetSyncWord(SX126X_LORA_MAC_PUBLIC_SYNCWORD)
|
d.SetSyncWord(SX126X_LORA_MAC_PUBLIC_SYNCWORD)
|
||||||
} else {
|
} else {
|
||||||
@@ -507,15 +507,15 @@ func (d *Device) ExecGetCommand(cmd uint8, size uint8) []uint8 {
|
|||||||
// Configuration
|
// Configuration
|
||||||
//
|
//
|
||||||
|
|
||||||
// SetLoraFrequency() Sets current Lora Frequency
|
// SetFrequency() Sets current Lora Frequency
|
||||||
// NB: Change will be applied at next RX / TX
|
// NB: Change will be applied at next RX / TX
|
||||||
func (d *Device) SetLoraFrequency(freq uint32) {
|
func (d *Device) SetFrequency(freq uint32) {
|
||||||
d.loraConf.Freq = d.loraConf.Freq
|
d.loraConf.Freq = d.loraConf.Freq
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraIqMode() defines the current IQ Mode (Standard/Inverted)
|
// SetIqMode() defines the current IQ Mode (Standard/Inverted)
|
||||||
// NB: Change will be applied at next RX / TX
|
// NB: Change will be applied at next RX / TX
|
||||||
func (d *Device) SetLoraIqMode(mode uint8) {
|
func (d *Device) SetIqMode(mode uint8) {
|
||||||
if mode == 0 {
|
if mode == 0 {
|
||||||
d.loraConf.Iq = lora.IQStandard
|
d.loraConf.Iq = lora.IQStandard
|
||||||
} else {
|
} else {
|
||||||
@@ -523,21 +523,21 @@ func (d *Device) SetLoraIqMode(mode uint8) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraCodingRate() sets current Lora Coding Rate
|
// SetCodingRate() sets current Lora Coding Rate
|
||||||
// NB: Change will be applied at next RX / TX
|
// NB: Change will be applied at next RX / TX
|
||||||
func (d *Device) SetLoraCodingRate(cr uint8) {
|
func (d *Device) SetCodingRate(cr uint8) {
|
||||||
d.loraConf.Cr = cr
|
d.loraConf.Cr = cr
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraBandwidth() sets current Lora Bandwidth
|
// SetBandwidth() sets current Lora Bandwidth
|
||||||
// NB: Change will be applied at next RX / TX
|
// NB: Change will be applied at next RX / TX
|
||||||
func (d *Device) SetLoraBandwidth(bw uint8) {
|
func (d *Device) SetBandwidth(bw uint8) {
|
||||||
d.loraConf.Cr = bw
|
d.loraConf.Cr = bw
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraCrc() sets current CRC mode (ON/OFF)
|
// SetCrc() sets current CRC mode (ON/OFF)
|
||||||
// NB: Change will be applied at next RX / TX
|
// NB: Change will be applied at next RX / TX
|
||||||
func (d *Device) SetLoraCrc(enable bool) {
|
func (d *Device) SetCrc(enable bool) {
|
||||||
if enable {
|
if enable {
|
||||||
d.loraConf.Crc = lora.CRCOn
|
d.loraConf.Crc = lora.CRCOn
|
||||||
} else {
|
} else {
|
||||||
@@ -545,9 +545,9 @@ func (d *Device) SetLoraCrc(enable bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraSpreadingFactor setc surrent Lora Spreading Factor
|
// SetSpreadingFactor setc surrent Lora Spreading Factor
|
||||||
// NB: Change will be applied at next RX / TX
|
// NB: Change will be applied at next RX / TX
|
||||||
func (d *Device) SetLoraSpreadingFactor(sf uint8) {
|
func (d *Device) SetSpreadingFactor(sf uint8) {
|
||||||
d.loraConf.Sf = sf
|
d.loraConf.Sf = sf
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,18 +576,19 @@ func (d *Device) LoraConfig(cnf lora.Config) {
|
|||||||
d.SetBufferBaseAddress(0, 0)
|
d.SetBufferBaseAddress(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoraTx sends a lora packet, (with timeout)
|
// Tx sends a lora packet, (with timeout)
|
||||||
func (d *Device) LoraTx(pkt []uint8, timeoutMs uint32) error {
|
func (d *Device) Tx(pkt []uint8, timeoutMs uint32) error {
|
||||||
|
|
||||||
if d.loraConf.Freq == 0 {
|
if d.loraConf.Freq == 0 {
|
||||||
return lora.ErrUndefinedLoraConf
|
return lora.ErrUndefinedLoraConf
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.rfswitch != nil {
|
if d.rfswitch != nil {
|
||||||
err := d.rfswitch.SetRfSwitchMode(RFSWITCH_TX_HP)
|
err := d.rfswitch.SetRfSwitchMode(RFSWITCH_TX_HP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d.ClearIrqStatus(SX126X_IRQ_ALL)
|
d.ClearIrqStatus(SX126X_IRQ_ALL)
|
||||||
irqVal := uint16(SX126X_IRQ_TX_DONE | SX126X_IRQ_TIMEOUT | SX126X_IRQ_CRC_ERR)
|
irqVal := uint16(SX126X_IRQ_TX_DONE | SX126X_IRQ_TIMEOUT | SX126X_IRQ_CRC_ERR)
|
||||||
d.SetStandby()
|
d.SetStandby()
|
||||||
@@ -610,17 +611,18 @@ func (d *Device) LoraTx(pkt []uint8, timeoutMs uint32) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LoraRx tries to receive a Lora packet (with timeout in milliseconds)
|
// LoraRx tries to receive a Lora packet (with timeout in milliseconds)
|
||||||
func (d *Device) LoraRx(timeoutMs uint32) ([]uint8, error) {
|
func (d *Device) Rx(timeoutMs uint32) ([]uint8, error) {
|
||||||
|
|
||||||
if d.loraConf.Freq == 0 {
|
if d.loraConf.Freq == 0 {
|
||||||
return nil, lora.ErrUndefinedLoraConf
|
return nil, lora.ErrUndefinedLoraConf
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.rfswitch != nil {
|
if d.rfswitch != nil {
|
||||||
err := d.rfswitch.SetRfSwitchMode(RFSWITCH_RX)
|
err := d.rfswitch.SetRfSwitchMode(RFSWITCH_RX)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d.ClearIrqStatus(SX126X_IRQ_ALL)
|
d.ClearIrqStatus(SX126X_IRQ_ALL)
|
||||||
irqVal := uint16(SX126X_IRQ_RX_DONE | SX126X_IRQ_TIMEOUT | SX126X_IRQ_CRC_ERR)
|
irqVal := uint16(SX126X_IRQ_RX_DONE | SX126X_IRQ_TIMEOUT | SX126X_IRQ_CRC_ERR)
|
||||||
d.SetStandby()
|
d.SetStandby()
|
||||||
|
|||||||
+37
-40
@@ -239,8 +239,8 @@ func (d *Device) LoraConfig(cnf lora.Config) {
|
|||||||
d.loraConf.SyncWord = syncword(int(cnf.SyncWord))
|
d.loraConf.SyncWord = syncword(int(cnf.SyncWord))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraFrequency updates the frequency the LoRa module is using
|
// SetFrequency updates the frequency the LoRa module is using
|
||||||
func (d *Device) SetLoraFrequency(frequency uint32) {
|
func (d *Device) SetFrequency(frequency uint32) {
|
||||||
d.loraConf.Freq = frequency
|
d.loraConf.Freq = frequency
|
||||||
var frf = (uint64(frequency) << 19) / 32000000
|
var frf = (uint64(frequency) << 19) / 32000000
|
||||||
d.WriteRegister(SX127X_REG_FRF_MSB, uint8(frf>>16))
|
d.WriteRegister(SX127X_REG_FRF_MSB, uint8(frf>>16))
|
||||||
@@ -249,19 +249,19 @@ func (d *Device) SetLoraFrequency(frequency uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetBandwidth updates the bandwidth the LoRa module is using
|
// SetBandwidth updates the bandwidth the LoRa module is using
|
||||||
func (d *Device) SetLoraBandwidth(bw uint8) {
|
func (d *Device) SetBandwidth(bw uint8) {
|
||||||
d.loraConf.Bw = bandwidth(bw)
|
d.loraConf.Bw = bandwidth(bw)
|
||||||
d.WriteRegister(SX127X_REG_MODEM_CONFIG_1, (d.ReadRegister(SX127X_REG_MODEM_CONFIG_1)&0x0f)|(bw<<4))
|
d.WriteRegister(SX127X_REG_MODEM_CONFIG_1, (d.ReadRegister(SX127X_REG_MODEM_CONFIG_1)&0x0f)|(bw<<4))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetCodingRate updates the coding rate the LoRa module is using
|
// SetCodingRate updates the coding rate the LoRa module is using
|
||||||
func (d *Device) SetLoraCodingRate(cr uint8) {
|
func (d *Device) SetCodingRate(cr uint8) {
|
||||||
d.loraConf.Cr = cr
|
d.loraConf.Cr = cr
|
||||||
d.WriteRegister(SX127X_REG_MODEM_CONFIG_1, (d.ReadRegister(SX127X_REG_MODEM_CONFIG_1)&0xf1)|(cr<<1))
|
d.WriteRegister(SX127X_REG_MODEM_CONFIG_1, (d.ReadRegister(SX127X_REG_MODEM_CONFIG_1)&0xf1)|(cr<<1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetImplicitHeaderModeOn Enables implicit header mode ***
|
// SetImplicitHeaderModeOn Enables implicit header mode ***
|
||||||
func (d *Device) SetLoraHeaderMode(headerType uint8) {
|
func (d *Device) SetHeaderMode(headerType uint8) {
|
||||||
d.loraConf.HeaderType = headerType
|
d.loraConf.HeaderType = headerType
|
||||||
if headerType == lora.HeaderImplicit {
|
if headerType == lora.HeaderImplicit {
|
||||||
d.WriteRegister(SX127X_REG_MODEM_CONFIG_1, d.ReadRegister(SX127X_REG_MODEM_CONFIG_1)|0x01)
|
d.WriteRegister(SX127X_REG_MODEM_CONFIG_1, d.ReadRegister(SX127X_REG_MODEM_CONFIG_1)|0x01)
|
||||||
@@ -270,8 +270,8 @@ func (d *Device) SetLoraHeaderMode(headerType uint8) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraSpreadingFactor changes spreading factor
|
// SetSpreadingFactor changes spreading factor
|
||||||
func (d *Device) SetLoraSpreadingFactor(sf uint8) {
|
func (d *Device) SetSpreadingFactor(sf uint8) {
|
||||||
d.loraConf.Sf = sf
|
d.loraConf.Sf = sf
|
||||||
if sf == lora.SpreadingFactor6 {
|
if sf == lora.SpreadingFactor6 {
|
||||||
d.WriteRegister(SX127X_REG_DETECTION_OPTIMIZE, 0xc5)
|
d.WriteRegister(SX127X_REG_DETECTION_OPTIMIZE, 0xc5)
|
||||||
@@ -293,8 +293,8 @@ func (d *Device) SetTxContinuousMode(val bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraCrc Enable CRC generation and check on payload
|
// SetCrc Enable CRC generation and check on payload
|
||||||
func (d *Device) SetLoraCrc(enable bool) {
|
func (d *Device) SetCrc(enable bool) {
|
||||||
if enable {
|
if enable {
|
||||||
d.loraConf.Crc = lora.CRCOn
|
d.loraConf.Crc = lora.CRCOn
|
||||||
d.WriteRegister(SX127X_REG_MODEM_CONFIG_2, d.ReadRegister(SX127X_REG_MODEM_CONFIG_2)|0x04)
|
d.WriteRegister(SX127X_REG_MODEM_CONFIG_2, d.ReadRegister(SX127X_REG_MODEM_CONFIG_2)|0x04)
|
||||||
@@ -304,21 +304,21 @@ func (d *Device) SetLoraCrc(enable bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Device) SetLoraPreamble(pLen uint16) {
|
func (d *Device) SetPreamble(pLen uint16) {
|
||||||
// Sets preamble length
|
// Sets preamble length
|
||||||
d.WriteRegister(SX127X_REG_PREAMBLE_MSB, uint8((pLen>>8)&0xFF))
|
d.WriteRegister(SX127X_REG_PREAMBLE_MSB, uint8((pLen>>8)&0xFF))
|
||||||
d.WriteRegister(SX127X_REG_PREAMBLE_LSB, uint8(pLen&0xFF))
|
d.WriteRegister(SX127X_REG_PREAMBLE_LSB, uint8(pLen&0xFF))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraSyncWord defines sync word
|
// SetSyncWord defines sync word
|
||||||
func (d *Device) SetLoraSyncWord(syncWord uint16) {
|
func (d *Device) SetSyncWord(syncWord uint16) {
|
||||||
d.loraConf.SyncWord = syncWord
|
d.loraConf.SyncWord = syncWord
|
||||||
sw := uint8(syncWord & 0xFF)
|
sw := uint8(syncWord & 0xFF)
|
||||||
d.WriteRegister(SX127X_REG_SYNC_WORD, sw)
|
d.WriteRegister(SX127X_REG_SYNC_WORD, sw)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLoraIQMode Sets I/Q polarity configuration
|
// SetIQMode Sets I/Q polarity configuration
|
||||||
func (d *Device) SetLoraIqMode(val uint8) {
|
func (d *Device) SetIqMode(val uint8) {
|
||||||
d.loraConf.Iq = val
|
d.loraConf.Iq = val
|
||||||
if val == lora.IQStandard {
|
if val == lora.IQStandard {
|
||||||
//Set IQ to normal values
|
//Set IQ to normal values
|
||||||
@@ -331,10 +331,8 @@ func (d *Device) SetLoraIqMode(val uint8) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoraTx sends a lora packet, (with timeout)
|
// Tx sends a lora packet, (with timeout)
|
||||||
func (d *Device) LoraTx(pkt []uint8, timeoutMs uint32) error {
|
func (d *Device) Tx(pkt []uint8, timeoutMs uint32) error {
|
||||||
|
|
||||||
//println("sx127x: LoraTx:", len(pkt), " bytes", hex.EncodeToString(pkt))
|
|
||||||
d.SetOpModeLora()
|
d.SetOpModeLora()
|
||||||
d.SetOpMode(SX127X_OPMODE_SLEEP)
|
d.SetOpMode(SX127X_OPMODE_SLEEP)
|
||||||
|
|
||||||
@@ -343,16 +341,16 @@ func (d *Device) LoraTx(pkt []uint8, timeoutMs uint32) error {
|
|||||||
d.WriteRegister(SX127X_REG_PA_RAMP, (d.ReadRegister(SX127X_REG_PA_RAMP)&0xF0)|0x08) // set PA ramp-up time 50 uSec
|
d.WriteRegister(SX127X_REG_PA_RAMP, (d.ReadRegister(SX127X_REG_PA_RAMP)&0xF0)|0x08) // set PA ramp-up time 50 uSec
|
||||||
d.WriteRegister(SX127X_REG_LNA, SX127X_LNA_MAX_GAIN) // Set Low Noise Amplifier to MAX
|
d.WriteRegister(SX127X_REG_LNA, SX127X_LNA_MAX_GAIN) // Set Low Noise Amplifier to MAX
|
||||||
|
|
||||||
d.SetLoraFrequency(d.loraConf.Freq)
|
d.SetFrequency(d.loraConf.Freq)
|
||||||
d.SetLoraPreamble(d.loraConf.Preamble)
|
d.SetPreamble(d.loraConf.Preamble)
|
||||||
d.SetLoraSyncWord(d.loraConf.SyncWord)
|
d.SetSyncWord(d.loraConf.SyncWord)
|
||||||
d.SetLoraBandwidth(d.loraConf.Bw)
|
d.SetBandwidth(d.loraConf.Bw)
|
||||||
d.SetLoraSpreadingFactor(d.loraConf.Sf)
|
d.SetSpreadingFactor(d.loraConf.Sf)
|
||||||
d.SetLoraIqMode(d.loraConf.Iq)
|
d.SetIqMode(d.loraConf.Iq)
|
||||||
d.SetLoraCodingRate(d.loraConf.Cr)
|
d.SetCodingRate(d.loraConf.Cr)
|
||||||
d.SetLoraCrc(d.loraConf.Crc == lora.CRCOn)
|
d.SetCrc(d.loraConf.Crc == lora.CRCOn)
|
||||||
d.SetTxPower(d.loraConf.LoraTxPowerDBm, true)
|
d.SetTxPower(d.loraConf.LoraTxPowerDBm, true)
|
||||||
d.SetLoraHeaderMode(d.loraConf.HeaderType)
|
d.SetHeaderMode(d.loraConf.HeaderType)
|
||||||
d.SetAgcAuto(SX127X_AGC_AUTO_ON)
|
d.SetAgcAuto(SX127X_AGC_AUTO_ON)
|
||||||
|
|
||||||
// set the IRQ mapping DIO0=TxDone DIO1=NOP DIO2=NOP
|
// set the IRQ mapping DIO0=TxDone DIO1=NOP DIO2=NOP
|
||||||
@@ -385,9 +383,8 @@ func (d *Device) LoraTx(pkt []uint8, timeoutMs uint32) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoraRx tries to receive a Lora packet (with timeout in milliseconds)
|
// Rx tries to receive a Lora packet (with timeout in milliseconds)
|
||||||
func (d *Device) LoraRx(timeoutMs uint32) ([]uint8, error) {
|
func (d *Device) Rx(timeoutMs uint32) ([]uint8, error) {
|
||||||
|
|
||||||
if d.loraConf.Freq == 0 {
|
if d.loraConf.Freq == 0 {
|
||||||
return nil, lora.ErrUndefinedLoraConf
|
return nil, lora.ErrUndefinedLoraConf
|
||||||
}
|
}
|
||||||
@@ -400,16 +397,16 @@ func (d *Device) LoraRx(timeoutMs uint32) ([]uint8, error) {
|
|||||||
d.WriteRegister(SX127X_REG_PA_RAMP, (d.ReadRegister(SX127X_REG_PA_RAMP)&0xF0)|0x08) // set PA ramp-up time 50 uSec
|
d.WriteRegister(SX127X_REG_PA_RAMP, (d.ReadRegister(SX127X_REG_PA_RAMP)&0xF0)|0x08) // set PA ramp-up time 50 uSec
|
||||||
d.WriteRegister(SX127X_REG_LNA, SX127X_LNA_MAX_GAIN) // Set Low Noise Amplifier to MAX
|
d.WriteRegister(SX127X_REG_LNA, SX127X_LNA_MAX_GAIN) // Set Low Noise Amplifier to MAX
|
||||||
|
|
||||||
d.SetLoraFrequency(d.loraConf.Freq)
|
d.SetFrequency(d.loraConf.Freq)
|
||||||
d.SetLoraPreamble(d.loraConf.Preamble) //OK
|
d.SetPreamble(d.loraConf.Preamble)
|
||||||
d.SetLoraSyncWord(d.loraConf.SyncWord) // Should be ok
|
d.SetSyncWord(d.loraConf.SyncWord)
|
||||||
d.SetLoraBandwidth(d.loraConf.Bw) // OK
|
d.SetBandwidth(d.loraConf.Bw)
|
||||||
d.SetLoraSpreadingFactor(d.loraConf.Sf) // OK
|
d.SetSpreadingFactor(d.loraConf.Sf)
|
||||||
d.SetLoraIqMode(d.loraConf.Iq) //OK
|
d.SetIqMode(d.loraConf.Iq)
|
||||||
d.SetLoraCodingRate(d.loraConf.Cr)
|
d.SetCodingRate(d.loraConf.Cr)
|
||||||
d.SetLoraCrc(d.loraConf.Crc == lora.CRCOn)
|
d.SetCrc(d.loraConf.Crc == lora.CRCOn)
|
||||||
d.SetTxPower(d.loraConf.LoraTxPowerDBm, true)
|
d.SetTxPower(d.loraConf.LoraTxPowerDBm, true)
|
||||||
d.SetLoraHeaderMode(d.loraConf.HeaderType)
|
d.SetHeaderMode(d.loraConf.HeaderType)
|
||||||
d.SetAgcAuto(SX127X_AGC_AUTO_ON)
|
d.SetAgcAuto(SX127X_AGC_AUTO_ON)
|
||||||
|
|
||||||
// set the IRQ mapping DIO0=RxDone DIO1=RxTimeout DIO2=NOP
|
// set the IRQ mapping DIO0=RxDone DIO1=RxTimeout DIO2=NOP
|
||||||
@@ -462,7 +459,7 @@ func (d *Device) RandomU32() uint32 {
|
|||||||
d.WriteRegister(SX127X_REG_IRQ_FLAGS, 0xFF)
|
d.WriteRegister(SX127X_REG_IRQ_FLAGS, 0xFF)
|
||||||
d.SetOpModeLora()
|
d.SetOpModeLora()
|
||||||
d.SetOpMode(SX127X_OPMODE_SLEEP)
|
d.SetOpMode(SX127X_OPMODE_SLEEP)
|
||||||
d.SetLoraFrequency(d.loraConf.Freq)
|
d.SetFrequency(d.loraConf.Freq)
|
||||||
d.SetOpMode(SX127X_OPMODE_RX)
|
d.SetOpMode(SX127X_OPMODE_RX)
|
||||||
rnd := uint32(0)
|
rnd := uint32(0)
|
||||||
for i := 0; i < 32; i++ {
|
for i := 0; i < 32; i++ {
|
||||||
|
|||||||
Reference in New Issue
Block a user