Skip to content

Commit 41a6670

Browse files
committed
fixed no receive on slave
1 parent 5dd1e35 commit 41a6670

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

drivers/lora/sx126x.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@ int setRfChannel(const struct device *dev, uint32_t freq) {
531531
SX126xWaitOnBusy();
532532
SX126xSetStandby(STDBY_RC);
533533
SX126xSetPacketType(PACKET_TYPE_LORA);
534+
//SX126xSetRfFrequency(freq);
535+
536+
//SX126xSetFs();
537+
SX126xWaitOnBusy();
534538
SX126xSetRfFrequency(freq);
535539
SX126xWaitOnBusy();
536540
return 0;
@@ -547,7 +551,7 @@ int setSleep(const struct device *dev) {
547551
SX126xWaitOnBusy();
548552
SX126xSetStandby(STDBY_XOSC);
549553
SleepParams_t sleep = {
550-
.Fields.WarmStart = 0,
554+
.Fields.WarmStart = 1,
551555
.Fields.Reset = 0,
552556
.Fields.WakeUpRTC = 0,
553557
.Fields.Reserved = 0,
@@ -622,7 +626,15 @@ int setRxContinuous(const struct device *dev) {
622626
SX126xSetDioIrqParams(0xff, 0xff, 0x00, 0x00);
623627
SX126xWriteRegister(0x08, 0x04); //syncword
624628
SX126xSetOperatingMode(MODE_RX);
625-
SX126xSetRx(0);
629+
//SX126xSetRx(0);
630+
631+
SX126xSetDioIrqParams( IRQ_RADIO_ALL, //IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT,
632+
IRQ_RADIO_ALL, //IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT,
633+
IRQ_RADIO_NONE,
634+
IRQ_RADIO_NONE );
635+
636+
SX126xSetRxBoosted(0);
637+
626638
//Wait for IRQ RxDone2 or Timeout: the chip will stay in Rx and look for a new packet if the continuous mode is selected
627639
//otherwise it will goes to STDBY_RC mode.
628640

@@ -640,11 +652,12 @@ void setModParams(const struct lora_modem_config *config) {
640652
int n = 4;
641653
uint8_t buf[n];
642654
//buf[0] = modulationParams->Params.LoRa.SpreadingFactor;
643-
buf[0] = config->datarate;
655+
//buf[0] = config->datarate;
656+
buf[0] = SF_11;
644657
//buf[1] = modulationParams->Params.LoRa.Bandwidth;
645-
buf[1] = config->bandwidth;
658+
buf[1] = BW_125_KHZ;
646659
//buf[2] = modulationParams->Params.LoRa.CodingRate;
647-
buf[2] = config->coding_rate;
660+
buf[2] = CR_4_5;
648661
//buf[3] = modulationParams->Params.LoRa.LowDatarateOptimize;
649662
buf[3] = 0x01;
650663
SX126xWriteCommand( RADIO_SET_MODULATIONPARAMS, buf, n );
@@ -653,12 +666,12 @@ void setModParams(const struct lora_modem_config *config) {
653666
void setPacketParams(const struct lora_modem_config *config, uint8_t size) {
654667
int n = 6;
655668
uint8_t buf[n];
656-
buf[0] = ( config->preamble_len >> 8 ) & 0xFF;
657-
buf[1] = config->preamble_len;
669+
buf[0] = ( 0x00 >> 8 ) & 0xFF; //Preamble length
670+
buf[1] = 0x06; //Preamble length
658671
buf[2] = 0x01; //Implicit header
659-
buf[3] = size;
660-
buf[4] = LORA_CRC_ON;
661-
buf[5] = config->iq_inverted;
672+
buf[3] = 0x06; //Payload length
673+
buf[4] = LORA_CRC_ON; //CRC on
674+
buf[5] = false; //Invert IQ
662675
SX126xWriteCommand( RADIO_SET_PACKETPARAMS, buf, n );
663676
}
664677

0 commit comments

Comments
 (0)