2 Commits

Author SHA1 Message Date
YuanHongbin 078e5731bb docs: sx127x.h补充编译期信道选择注释示例(USE_LORA_CH, 0~119) 2026-09-08 15:31:02 +08:00
YuanHongbin a8d81780e8 feat: LoRa频率设定范围改为433.1~492.6MHz, 步进500KHz
- sx127x.h: CH0~CH45宏表(470.1~492.6MHz, 46信道)替换为算术定义:
  LORA_FREQ_BASE=433100000, LORA_FREQ_STEP=500000, LORA_FREQ_MAX=492600000,
  LORA_CHANNEL_CNT=120(CH0~CH119); FREQ_CENT由编译期USE_LORA_CH(0~119)算术换算,
  未指定时出厂默认CH0=433.1MHz
- sx127x.c: LoraSetFreqCent范围校验放宽至433.1~492.6MHz; LoraSetChannel上限45->119
- main.c: Flash参数BLPara.LoraFreq范围校验同步放宽至433.1~492.6MHz
- 频率公式: Freq = 433100000 + 500000*N, N = 0~119
- 新旧信道号映射: 旧CHn = 新CH(74+n), 例: 旧CH0(470.1MHz) = 新CH74
- 注意: 网关侧需使用相同频率集合
- 所有编辑文件保持UTF-8编码(无BOM)
2026-09-08 09:53:48 +08:00
3 changed files with 27 additions and 149 deletions
+2 -2
View File
@@ -622,7 +622,7 @@ void Sx1276RxRetValue(void)
bool LoraSetChannel(uint8_t Channel)
{
if(Channel > 45)
if(Channel >= LORA_CHANNEL_CNT) //宽带版: 0~119
return false;
LoRaPara.ucChannel = Channel;
return true;
@@ -667,7 +667,7 @@ bool LoraSetRegPreamble(uint8_t RegPreamble)
}
bool LoraSetFreqCent(uint32_t FreqCent)
{
if(FreqCent < 470100000ul || FreqCent > 492600000ul)
if(FreqCent < LORA_FREQ_BASE || FreqCent > LORA_FREQ_MAX) //宽带: 433.1~492.6MHz
return false;
LoRaPara.dwFreqHz = FreqCent;
return true;
+23 -145
View File
@@ -637,7 +637,7 @@ typedef enum{
SX1276_IH_ON= (1)
}Sx1276ImplicitHeaderOnType;
// ɱ
// ?
typedef struct _AutoSfType{
Sx1276SpreadFactorType Sf;
uint8_t ucRssiMin, ucRssiMax;
@@ -745,162 +745,40 @@ typedef struct {
//Down Link:
//CH0-47:500.3-509.7MHz
#define USE_915MHZ 0//=1ʹ 915 =0ʹ 433
#define USE_915MHZ 0//=1? 915 =0? 433
#if (USE_915MHZ == 1)
// Ƶ ʣ Ĭ Ϊ449000000Hz
// ? ? ? ?449000000Hz
#define FREQ_CENT 915000000ul
//860MHz-1GHzʹ PA ţ Ĭ ϲ ʹ
//SX127x 壬HOPERFģ Ҫ
//860MHz-1GHz? PA ? ? ? ?
//SX127x 壬HOPERF? ?
#define USE_LORA_860_PA
#endif
/*
中心频率配置470100000ul ~ 492600000ul步进500000
中心频率配置(宽带版): 433100000ul ~ 492600000ul, 步进500000, 共120信道(CH0~CH119)
频率公式: Freq = 433100000 + 500000*N, N = 0~119
编译期可用 USE_LORA_CH(0~119) 指定频率; 未指定时出厂默认 CH0=433.1MHz
*/
#define CH0 (470100000ul) //出厂默认频率
#define CH1 (470600000ul)
#define CH2 (471100000ul)
#define CH3 (471600000ul)
#define CH4 (472100000ul)
#define CH5 (472600000ul)
#define CH6 (473100000ul)
#define CH7 (473600000ul)
#define CH8 (474100000ul)
#define CH9 (474600000ul)
#define CH10 (475100000ul)
#define CH11 (475600000ul)
#define CH12 (476100000ul)
#define CH13 (476600000ul)
#define CH14 (477100000ul)
#define CH15 (477600000ul)
#define CH16 (478100000ul)
#define CH17 (478600000ul)
#define CH18 (479100000ul)
#define CH19 (479600000ul)
#define CH20 (480100000ul)
#define CH21 (480600000ul)
#define CH22 (481100000ul)
#define CH23 (481600000ul)
#define CH24 (482100000ul)
#define CH25 (482600000ul)
#define CH26 (483100000ul)
#define CH27 (483600000ul)
#define CH28 (484100000ul)
#define CH29 (484600000ul)
#define CH30 (485100000ul)
#define CH31 (485600000ul)
#define CH32 (486100000ul)
#define CH33 (486600000ul)
#define CH34 (487100000ul)
#define CH35 (487600000ul)
#define CH36 (488100000ul)
#define CH37 (488600000ul)
#define CH38 (489100000ul)
#define CH39 (489600000ul)
#define CH40 (490100000ul)
#define CH41 (490600000ul)
#define CH42 (491100000ul)
#define CH43 (491600000ul)
#define CH44 (492100000ul)
#define CH45 (492600000ul)
#define LORA_FREQ_BASE (433100000ul)
#define LORA_FREQ_STEP (500000ul)
#define LORA_FREQ_MAX (492600000ul)
#define LORA_CHANNEL_CNT (120)
#if (USE_LORA_CH == 0)
#define FREQ_CENT CH0
#elif (USE_LORA_CH == 1)
#define FREQ_CENT CH1
#elif (USE_LORA_CH == 2)
#define FREQ_CENT CH2
#elif (USE_LORA_CH == 3)
#define FREQ_CENT CH3
#elif (USE_LORA_CH == 4)
#define FREQ_CENT CH4
#elif (USE_LORA_CH == 5)
#define FREQ_CENT CH5
#elif (USE_LORA_CH == 6)
#define FREQ_CENT CH6
#elif (USE_LORA_CH == 7)
#define FREQ_CENT CH7
#elif (USE_LORA_CH == 8)
#define FREQ_CENT CH8
#elif (USE_LORA_CH == 9)
#define FREQ_CENT CH9
#elif (USE_LORA_CH == 10)
#define FREQ_CENT CH10
#elif (USE_LORA_CH == 11)
#define FREQ_CENT CH11
#elif (USE_LORA_CH == 12)
#define FREQ_CENT CH12
#elif (USE_LORA_CH == 13)
#define FREQ_CENT CH13
#elif (USE_LORA_CH == 14)
#define FREQ_CENT CH14
#elif (USE_LORA_CH == 15)
#define FREQ_CENT CH15
#elif (USE_LORA_CH == 16)
#define FREQ_CENT CH16
#elif (USE_LORA_CH == 17)
#define FREQ_CENT CH17
#elif (USE_LORA_CH == 18)
#define FREQ_CENT CH18
#elif (USE_LORA_CH == 19)
#define FREQ_CENT CH19
#elif (USE_LORA_CH == 20)
#define FREQ_CENT CH20
#elif (USE_LORA_CH == 21)
#define FREQ_CENT CH21
#elif (USE_LORA_CH == 22)
#define FREQ_CENT CH22
#elif (USE_LORA_CH == 23)
#define FREQ_CENT CH23
#elif (USE_LORA_CH == 24)
#define FREQ_CENT CH24
#elif (USE_LORA_CH == 25)
#define FREQ_CENT CH25
#elif (USE_LORA_CH == 26)
#define FREQ_CENT CH26
#elif (USE_LORA_CH == 27)
#define FREQ_CENT CH27
#elif (USE_LORA_CH == 28)
#define FREQ_CENT CH28
#elif (USE_LORA_CH == 29)
#define FREQ_CENT CH29
#elif (USE_LORA_CH == 30)
#define FREQ_CENT CH30
#elif (USE_LORA_CH == 31)
#define FREQ_CENT CH31
#elif (USE_LORA_CH == 32)
#define FREQ_CENT CH32
#elif (USE_LORA_CH == 33)
#define FREQ_CENT CH33
#elif (USE_LORA_CH == 34)
#define FREQ_CENT CH34
#elif (USE_LORA_CH == 35)
#define FREQ_CENT CH35
#elif (USE_LORA_CH == 36)
#define FREQ_CENT CH36
#elif (USE_LORA_CH == 37)
#define FREQ_CENT CH37
#elif (USE_LORA_CH == 38)
#define FREQ_CENT CH38
#elif (USE_LORA_CH == 39)
#define FREQ_CENT CH39
#elif (USE_LORA_CH == 40)
#define FREQ_CENT CH40
#elif (USE_LORA_CH == 41)
#define FREQ_CENT CH41
#elif (USE_LORA_CH == 42)
#define FREQ_CENT CH42
#elif (USE_LORA_CH == 43)
#define FREQ_CENT CH43
#elif (USE_LORA_CH == 44)
#define FREQ_CENT CH44
#elif (USE_LORA_CH == 45)
#define FREQ_CENT CH45
#define CH0 LORA_FREQ_BASE //出厂默认频率
//#define USE_LORA_CH 1
#if defined(USE_LORA_CH)
#if (USE_LORA_CH >= 0 && USE_LORA_CH < LORA_CHANNEL_CNT)
#define FREQ_CENT (LORA_FREQ_BASE + (uint32_t)(USE_LORA_CH) * LORA_FREQ_STEP)
#else
#error "USE_LORA_CH out of range, valid: 0 ~ 119"
#endif
#endif
#if !defined FREQ_CENT
#define FREQ_CENT (470100000ul)//500000
#define FREQ_CENT (CH0)//500000
#endif
#if !defined FREQ_DEV
#define FREQ_DEV 1000000ul
+2 -2
View File
@@ -137,10 +137,10 @@ static void AppInit(void)
App.Para.Layout.FPOTimeStart = 0;
}
if(App.Para.BLPara.LoraFreq < 470100000ul || App.Para.BLPara.LoraFreq > 492600000ul)
if(App.Para.BLPara.LoraFreq < LORA_FREQ_BASE || App.Para.BLPara.LoraFreq > LORA_FREQ_MAX) //宽带: 433.1~492.6MHz
App.Para.BLPara.LoraFreq = CH0;
App.Para.Lora.FreqCent = App.Para.BLPara.LoraFreq;
SX1276LoRaWriteFreq(App.Para.Lora.FreqCent); //Lora频率:470100000ul + 500000*N
SX1276LoRaWriteFreq(App.Para.Lora.FreqCent); //Lora频率:433100000ul + 500000*N, 范围433.1~492.6MHz
if(App.Para.Rs485Ch1.Addr > 16 || App.Para.Rs485Ch1.Addr < 1){
App.Para.Rs485Ch1.Addr = 1;