U8 LoRaTxData (u8 * pbufs, u8 size, u8 * pcrcbuf, u8 crcflag)
{
U32 I, j;
If (pbufs==0 | | size==0)//there is no data to send
{
return 1;//send fail - returns 1
}
//1. -- -- -- -- -- - & gt; Enter standby
SX1276LoRaSetOpMode (RFLR_OPMODE_STANDBY);
//2. -- -- -- -- -- - & gt; Send the initialization
SX1276LR - & gt; RegIrqFlagsMask=RFLR_IRQFLAGS_RXTIMEOUT |
RFLR_IRQFLAGS_RXDONE |
RFLR_IRQFLAGS_PAYLOADCRCERROR |
RFLR_IRQFLAGS_VALIDHEADER |
//RFLR_IRQFLAGS_TXDONE |//open send complete interrupt (Tx)
RFLR_IRQFLAGS_CADDONE |
RFLR_IRQFLAGS_FHSSCHANGEDCHANNEL |
RFLR_IRQFLAGS_CADDETECTED;
SX1276Write (REG_LR_IRQFLAGSMASK SX1276LR - & gt; RegIrqFlagsMask);
SX1276LR - & gt; RegHopPeriod=0;//frequency jump between the symbols when the cycle is: 0
SX1276Write (REG_LR_HOPPERIOD SX1276LR - & gt; RegHopPeriod);
//initializes the sent data of size
the cacheSX1276LR - & gt; RegPayloadLength=size;//data load length (not including the length of the CRC)
SX1276Write (REG_LR_PAYLOADLENGTH SX1276LR - & gt; RegPayloadLength + 4);//in the implicit model (implicit) in baotou, must be written to the length of the FIFO
SX1276LR - & gt; RegFifoTxBaseAddr=0 x00;//send the base address is set to 0 x00
SX1276Write (REG_LR_FIFOTXBASEADDR SX1276LR - & gt; RegFifoTxBaseAddr);//write send first address
SX1276LR - & gt; RegFifoAddrPtr=SX1276LR - & gt; RegFifoTxBaseAddr;//FIFO address pointer to Tx base address
SX1276Write (REG_LR_FIFOADDRPTR SX1276LR - & gt; RegFifoAddrPtr);//write FIFO access address
//3. -- -- -- -- -- - & gt; Will sent the data written to the FIFO
SX1276WriteFifo (pbufs SX1276LR - & gt; RegPayloadLength);//write to send data
//the last writing 4 byte CRC check values
If (crcflag==1)
{
If (size<(256-4))
SX1276WriteFifo (pcrcbuf, 4);
The else
return 1;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* on ZM470SX - M, DIO4 received 6 feet from the rf switch, send the state after the pin need to pull down,
* so in LoRa mode must be set to: RFLR_DIOMAPPING2_DIO4_00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
///////////////////////////////////////////////////////////////////////////////
//DIO0: TxDone port mapping set
SX1276LR - & gt; RegDioMapping1=RFLR_DIOMAPPING1_DIO0_01 | RFLR_DIOMAPPING1_DIO1_11 |
RFLR_DIOMAPPING1_DIO2_11 | RFLR_DIOMAPPING1_DIO3_11;
SX1276LR - & gt; RegDioMapping2=RFLR_DIOMAPPING2_DIO4_00 | RFLR_DIOMAPPING2_DIO5_11;
SX1276WriteBuffer (REG_LR_DIOMAPPING1, & amp; SX1276LR - & gt; RegDioMapping1, 2);
///////////////////////////////////////////////////////////////////////////////
//4. -- -- -- -- -- - & gt; To send data into the delivery mode,
SX1276LoRaSetOpMode (RFLR_OPMODE_TRANSMITTER);//send the state
//5. -- -- -- -- -- - & gt; Waiting to send complete (detection TxDone interrupt)
I=298000;
While (DIO0==0 & amp; & i !=0)//waiting to send complete timeout or send failure, after the completion of: DIO0 for high level
{
i--;
For (j=0; J & lt; 100; J++);//timeout to wait for about 1 ms
}
//if not
If (I==0)
{
//fail - return 2
return 2;
}
//if send success
The else
{
//6. -- -- -- -- -- - & gt; Send complete into standby mode
SX1276Write (REG_LR_IRQFLAGS RFLR_IRQFLAGS_TXDONE);//remove send complete interrupt
SX1276LoRaSetOpMode (RFLR_OPMODE_STANDBY);//to enter standby state
return 0;//success - returns 0
}
}
CodePudding user response:
Get the building Lord, I want to play, too lora communication recently,CodePudding user response:
Can direct messages to communicate, I before debugging a lora, directly controlled by spi,CodePudding user response:
SX1276LR - & gt; RegIrqFlagsMask=RFLR_IRQFLAGS_RXTIMEOUT |RFLR_IRQFLAGS_RXDONE |
RFLR_IRQFLAGS_PAYLOADCRCERROR |
RFLR_IRQFLAGS_VALIDHEADER |
//RFLR_IRQFLAGS_TXDONE |//open send complete interrupt (Tx)
RFLR_IRQFLAGS_CADDONE |
RFLR_IRQFLAGS_FHSSCHANGEDCHANNEL |
RFLR_IRQFLAGS_CADDETECTED;
This code has a problem,
CodePudding user response:
Hello, can you tell me the solution? I also met this problem