1、startup.s汇编文件的的中断重定向改为ifdef,通过切换app_debug和app_boot判断是否编译
2、Sx1276Type_t 结构体给定固定值 3、lora通道选择取消,通过修改频率来修改通道 4、增加了修改lora参数的函数 5、将USE_BOOTLOADER的宏定义更改到工程预编译define 6、将BootPara_t结构体定义到bsp.h文件下 7、在bsp.h文件下增加了LoraPara_r,RS485Para_t结构体并声明 8、串口带波特率参数初始化 9、增加了MAIN_DBG_LOG和DATA_DBG_LOG调试打印 10、Update.h的boot参数定义在bsp.h获取 11、当工程是app_boot时调试口为Lpuart0,当工程是app_debug时调试口为uart0 12、设备Mac从bootloader中固定地址0x00002800获取,设备类型、通讯方式、设备标志和设备序号从获取到的mac地址解析 13、debug文件增加了调试指令
This commit is contained in:
+87
-19
@@ -1,22 +1,16 @@
|
||||
#include "sx127x.h"
|
||||
#include "ddl.h"
|
||||
#include "Debug.h"
|
||||
#include "spi.h"
|
||||
#include "bsp.h"
|
||||
|
||||
|
||||
#define LORAChannel 8
|
||||
#define LORARegPreamble 10
|
||||
#include "UartDebug.h"
|
||||
|
||||
#if (LORA_MODULE == SX1278W1)
|
||||
Sx1276Type_t LoRaPara = {
|
||||
.ucChannel = LORAChannel, //4 or 12
|
||||
.ucChannel = 8, //4 or 12
|
||||
.dwFreqHz = FREQ_CENT,
|
||||
.ucPower = 20,
|
||||
.SignalBw = SX1276_BW_250K,
|
||||
.SpreadFactor = SX1276_SF_512,
|
||||
.ErrorCoding = SX1276_EC_4_6,
|
||||
.RegPreamble = LORARegPreamble,//10 or 16
|
||||
.RegPreamble = 10,//10 or 16
|
||||
.ucOpModePrev = RFLR_OPMODE_STANDBY,
|
||||
.bAntSwPrev = RF_ANT_RECEIVER,
|
||||
.RegBuff = 0,
|
||||
@@ -70,6 +64,7 @@ void SX1276WriteBuffer(uint8_t ucAddr, uint8_t *pucBuff, uint8_t ucLen)
|
||||
}
|
||||
LORA_SPI_NSS_SET();
|
||||
}
|
||||
|
||||
void SX1276Write(uint8_t ucAddr, uint8_t ucData)
|
||||
{
|
||||
SX1276WriteBuffer(ucAddr, &ucData, 1);
|
||||
@@ -229,20 +224,18 @@ void SX1276LoRaSetOpMode(Sx1276OpModeType ucOpMode)
|
||||
LoRaPara.ucOpModePrev = LoRaPara.RegBuff.RegOpMode & ~RFLR_OPMODE_MASK;
|
||||
if( ucOpMode != LoRaPara.ucOpModePrev){
|
||||
if(ucOpMode == RFLR_OPMODE_TRANSMITTER){
|
||||
|
||||
//CLR_LORA_RXEN();
|
||||
//SET_LORA_TXEN();
|
||||
|
||||
|
||||
bAntSwStatus = RF_ANT_TRANSMITTER;
|
||||
}
|
||||
else if(ucOpMode == RFLR_OPMODE_RECEIVER){
|
||||
bAntSwStatus = RF_ANT_RECEIVER;
|
||||
|
||||
//CLR_LORA_TXEN();
|
||||
//SET_LORA_RXEN();
|
||||
bAntSwStatus = RF_ANT_RECEIVER;
|
||||
}
|
||||
else {
|
||||
//CLR_LORA_TXEN();
|
||||
//CLR_LORA_RXEN();
|
||||
bAntSwStatus = RF_ANT_CLOSE;
|
||||
}
|
||||
if( bAntSwStatus != LoRaPara.bAntSwPrev ){
|
||||
@@ -305,8 +298,8 @@ void Sx1276LoRaInit(void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen))
|
||||
LoRaPara.RegBuff.RegLna = RFLR_LNA_GAIN_G1;
|
||||
SX1276WriteBuffer(REG_LR_OPMODE, (uint8_t*)&(LoRaPara.RegBuff) + 1, SIZE_OF_REGISTERS);
|
||||
//set the RF settings
|
||||
SX1276LoRaWriteChannel(LoRaPara.ucChannel);
|
||||
//SX1276LoRaSetFreqHz(LoRaPara.dwFreqHz);
|
||||
//SX1276LoRaWriteChannel(LoRaPara.ucChannel);
|
||||
SX1276LoRaSetFreqHz(LoRaPara.dwFreqHz);
|
||||
//REG_LR_MODEMCONFIG1
|
||||
SX1276Read(REG_LR_MODEMCONFIG1, &(LoRaPara.RegBuff.RegModemConfig1));
|
||||
//SignalBandwidth
|
||||
@@ -333,8 +326,14 @@ void Sx1276LoRaInit(void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen))
|
||||
|
||||
//验证寄存器操作是否成功
|
||||
SX1276Write(REG_LR_MODEMCONFIG2, LoRaPara.RegBuff.RegModemConfig2);
|
||||
LoRaPara.RegBuff.RegModemConfig2 = 0;
|
||||
SX1276Read(REG_LR_MODEMCONFIG2, &(LoRaPara.RegBuff.RegModemConfig2));
|
||||
uint8_t Config2 = 0;
|
||||
SX1276Read(REG_LR_MODEMCONFIG2, &Config2);
|
||||
if(LoRaPara.RegBuff.RegModemConfig2 == Config2) {
|
||||
DBG_LOG("Lora OK!\r\n");
|
||||
}
|
||||
else {
|
||||
DBG_LOG("Lora Error!\r\n");
|
||||
}
|
||||
|
||||
SX1276LoRaSetSymbTimeout(0x3FF);
|
||||
LoRaPara.RegBuff.RegPreambleMsb= (LoRaPara.RegPreamble >> 8) & 0x00ff;
|
||||
@@ -363,7 +362,8 @@ void Sx1276LoRaInit(void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen))
|
||||
Sx1276LoRaEnterRx();
|
||||
}
|
||||
|
||||
void IsrSx1276LoRaTxRx(void){
|
||||
void IsrSx1276LoRaTxRx(void)
|
||||
{
|
||||
switch (LoRaPara.State){
|
||||
case SX1276_IDLE:
|
||||
case SX1276_RX:
|
||||
@@ -610,4 +610,72 @@ void SX1276LoCalcRssiSnr(int8_t *pswRssi, int8_t *psbSnr)
|
||||
}
|
||||
*psbSnr= sbSnr;
|
||||
}
|
||||
int GetSx1276RxRetValue(void)
|
||||
{
|
||||
return LoRaPara.RxRet;
|
||||
}
|
||||
|
||||
void Sx1276RxRetValue(void)
|
||||
{
|
||||
LoRaPara.RxRet = -1;
|
||||
}
|
||||
|
||||
bool LoraSetChannel(uint8_t Channel)
|
||||
{
|
||||
if(Channel > 16)
|
||||
return false;
|
||||
LoRaPara.ucChannel = Channel;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoraSetPower(uint8_t Power)
|
||||
{
|
||||
if(Power > 20)
|
||||
return false;
|
||||
LoRaPara.ucPower = Power;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoraSetSignalBw(uint8_t SignalBw)
|
||||
{
|
||||
if(SignalBw > 9)
|
||||
return false;
|
||||
LoRaPara.SignalBw = (SignalBw << 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoraSetSpreadFactor(uint8_t SpreadFactor)
|
||||
{
|
||||
if(SpreadFactor < 4 || SpreadFactor > 12)
|
||||
return false;
|
||||
LoRaPara.SpreadFactor = (SpreadFactor << 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoraSetErrorCoding(uint8_t ErrorCoding)
|
||||
{
|
||||
if(ErrorCoding == 0 || ErrorCoding > 4)
|
||||
return false;
|
||||
LoRaPara.ErrorCoding = ErrorCoding << 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoraSetRegPreamble(uint8_t RegPreamble)
|
||||
{
|
||||
LoRaPara.RegPreamble = RegPreamble;
|
||||
return true;
|
||||
}
|
||||
bool LoraSetFreqCent(uint32_t FreqCent)
|
||||
{
|
||||
if(FreqCent < 410000000 || FreqCent > 525000000)
|
||||
return false;
|
||||
LoRaPara.dwFreqHz = FreqCent;
|
||||
return true;
|
||||
}
|
||||
void LoraInit(void)
|
||||
{
|
||||
Sx1276LoRaInit(LORA_RxCallBack);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+11
-1
@@ -2,6 +2,7 @@
|
||||
#define __SX127X_H
|
||||
|
||||
#include "bsp.h"
|
||||
#include "main.h"
|
||||
|
||||
//Constant values need to compute the RSSI value
|
||||
#define RSSI_OFFSET_LF -155
|
||||
@@ -733,6 +734,7 @@ typedef struct {
|
||||
uint8_t ucTxPacketSize;
|
||||
uint8_t RxTxBuff[LORA_BUFF_SIZE];
|
||||
void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen);
|
||||
int RxRet;
|
||||
}Sx1276Type_t, *pSx1276Type;
|
||||
|
||||
//ISM Freq In China
|
||||
@@ -802,7 +804,6 @@ typedef struct {
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void Sx1276LoRaLoopHandler(void);
|
||||
void Sx1276LoRaInit(void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen));
|
||||
void SX1276LoRaSetFreqHz(uint32_t dwFreqHz);
|
||||
void Sx1276LoRaSendBuffer(uint8_t* pucBuff, uint8_t ucLen);
|
||||
uint8_t SX1276LoRaReadChannel(void);
|
||||
boolean_t SX1276LoRaWriteChannel(uint8_t Channel);
|
||||
@@ -823,5 +824,14 @@ Sx1276StateType_t SX1276LoRaReadStatus(void);
|
||||
void SX1276LoCalcRssiSnr(int8_t *pswRssi, int8_t *psbSnr);
|
||||
void Sx1276LoRaSleep(void);
|
||||
void Sx1276LoRaWakeup(void);
|
||||
|
||||
void LoraInit(void);
|
||||
bool LoraSetChannel(uint8_t Channel);
|
||||
bool LoraSetPower(uint8_t Power);
|
||||
bool LoraSetSignalBw(uint8_t SignalBw);
|
||||
bool LoraSetSpreadFactor(uint8_t SpreadFactor);
|
||||
bool LoraSetErrorCoding(uint8_t ErrorCoding);
|
||||
bool LoraSetRegPreamble(uint8_t RegPreamble);
|
||||
bool LoraSetFreqCent(uint32_t FreqCent);
|
||||
#endif
|
||||
|
||||
|
||||
Submodule Module/LaserTracing_Debug updated: 10f470d791...03e1d001ef
Reference in New Issue
Block a user