9 Commits

Author SHA1 Message Date
YuanHongbin 73eccc6762 refactor: 将子模块 Module/LaserTracing_Debug 转换为普通目录纳入主仓库管理 2026-07-13 14:32:44 +08:00
YuanHongbin d64379caf7 fix: 修复24小时重复注册时未启动注册定时器的bug 2026-06-17 14:19:13 +08:00
YuanHongbin 725e9ce1f2 fix: 修复调试配置、中文乱码与上传重试逻辑问题
1. 更新Keil调试器的SWO时钟与flash配置
2. 修复main.c中全角乱码为正常中文注释
3. 修正上传失败重试的计数判断逻辑
4. 调整部分定时器延时参数与调试日志描述
2026-06-15 11:56:04 +08:00
YuanHongbin 6be01d6032 添加注释 2026-05-21 11:05:05 +08:00
YuanHongbin 3faf9baf67 1、修复了打开激光后无法保持的bug
2、未注册时无需向网关发送已打开激光指令
3、开启和关闭激光时会向网关上报状态
2026-05-20 15:02:36 +08:00
YuanHongbin 2efab2862f 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文件增加了调试指令
2026-05-20 13:41:07 +08:00
YuanHongbin cd594e3d69 debug目录文件转为子模块 2026-05-15 15:55:41 +08:00
YuanHongbin f3205e1cf7 1、Algorithm文件的isAllZero函数改为可改对比参数的is_all_byte
2、针对旧版本boot程序的升级兼容
2026-05-11 18:23:00 +08:00
YuanHongbin 9b06145341 1、sx127x.h增加了频率可调函数
2、删除了bsp.h的lora通道配置宏定义
3、删除了SGCP.h中MAC的组成参数定义,改为在main.c中进行定义,当使用bootloader时通过读取BootPara结构体参数获取本机MAC,否则将通过App程序自定义MAC
4、BootPara结构体参数增加
2026-05-11 10:10:13 +08:00
21 changed files with 2547 additions and 236 deletions
+21
View File
@@ -0,0 +1,21 @@
/*
* Auto generated Run-Time-Environment Configuration File
* *** Do not modify ! ***
*
* Project: 'hc32l17x'
* Target: 'HC32L17X_boot'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "HC32L170JATA.h"
#endif /* RTE_COMPONENTS_H */
+21
View File
@@ -0,0 +1,21 @@
/*
* Auto generated Run-Time-Environment Configuration File
* *** Do not modify ! ***
*
* Project: 'hc32l17x'
* Target: 'HC32L17X_debug'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "HC32L170JATA.h"
#endif /* RTE_COMPONENTS_H */
+251 -8
View File
@@ -22,7 +22,7 @@
</DaveTm> </DaveTm>
<Target> <Target>
<TargetName>HC32L17X</TargetName> <TargetName>HC32L17X_debug</TargetName>
<ToolsetNumber>0x4</ToolsetNumber> <ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName> <ToolsetName>ARM-ADS</ToolsetName>
<TargetOption> <TargetOption>
@@ -75,7 +75,7 @@
<OPTFL> <OPTFL>
<tvExp>1</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget> <IsCurrentTarget>0</IsCurrentTarget>
</OPTFL> </OPTFL>
<CpuCode>255</CpuCode> <CpuCode>255</CpuCode>
<DebugOpt> <DebugOpt>
@@ -125,7 +125,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>CMSIS_AGDI</Key> <Key>CMSIS_AGDI</Key>
<Name>-X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name> <Name>-X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO31 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@@ -250,6 +250,249 @@
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>App.LaserFlag,0x0A</ItemText> <ItemText>App.LaserFlag,0x0A</ItemText>
</Ww> </Ww>
<Ww>
<count>19</count>
<WinNumber>1</WinNumber>
<ItemText>BLPara,0x10</ItemText>
</Ww>
<Ww>
<count>20</count>
<WinNumber>1</WinNumber>
<ItemText>argv1,0x10</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
<Mm>
<WinNumber>1</WinNumber>
<SubType>0</SubType>
<ItemText>0x1fe00</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
</MemoryWindow1>
<MemoryWindow2>
<Mm>
<WinNumber>2</WinNumber>
<SubType>2</SubType>
<ItemText>0x20000f35</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
</MemoryWindow2>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
<vrSel>0</vrSel>
<aSym>0</aSym>
<aTbox>0</aTbox>
<AscS1>0</AscS1>
<AscS2>0</AscS2>
<AscS3>0</AscS3>
<aSer3>0</aSer3>
<eProf>0</eProf>
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
<uProt>0</uProt>
</DebugFlag>
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
<bLintAuto>0</bLintAuto>
<bAutoGenD>0</bAutoGenD>
<LntExFlags>0</LntExFlags>
<pMisraName></pMisraName>
<pszMrule></pszMrule>
<pSingCmds></pSingCmds>
<pMultCmds></pMultCmds>
<pMisraNamep></pMisraNamep>
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>
<EnableLog>0</EnableLog>
<Protocol>2</Protocol>
<DbgClock>10000000</DbgClock>
</DebugDescription>
</TargetOption>
</Target>
<Target>
<TargetName>HC32L17X_boot</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<CLKADS>12000000</CLKADS>
<OPTTT>
<gFlags>1</gFlags>
<BeepAtEnd>1</BeepAtEnd>
<RunSim>0</RunSim>
<RunTarget>1</RunTarget>
<RunAbUc>0</RunAbUc>
</OPTTT>
<OPTHX>
<HexSelection>1</HexSelection>
<FlashByte>65535</FlashByte>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
</OPTHX>
<OPTLEX>
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath>.\output\release\</ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
<CreateAListing>1</CreateAListing>
<CreateLListing>1</CreateLListing>
<CreateIListing>0</CreateIListing>
<AsmCond>1</AsmCond>
<AsmSymb>1</AsmSymb>
<AsmXref>0</AsmXref>
<CCond>1</CCond>
<CCode>0</CCode>
<CListInc>0</CListInc>
<CSymb>0</CSymb>
<LinkerCodeListing>0</LinkerCodeListing>
</ListingPage>
<OPTXL>
<LMap>1</LMap>
<LComments>1</LComments>
<LGenerateSymbols>1</LGenerateSymbols>
<LLibSym>1</LLibSym>
<LLines>1</LLines>
<LLocSym>1</LLocSym>
<LPubSym>1</LPubSym>
<LXref>0</LXref>
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>255</CpuCode>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>
<sLdApp>1</sLdApp>
<sGomain>1</sGomain>
<sRbreak>1</sRbreak>
<sRwatch>1</sRwatch>
<sRmem>1</sRmem>
<sRfunc>1</sRfunc>
<sRbox>1</sRbox>
<tLdApp>1</tLdApp>
<tGomain>1</tGomain>
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
<tRfunc>0</tRfunc>
<tRbox>1</tRbox>
<tRtrace>1</tRtrace>
<sRSysVw>1</sRSysVw>
<tRSysVw>1</tRSysVw>
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>12</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
<sDlgPa></sDlgPa>
<sIfile></sIfile>
<tDll></tDll>
<tDllPa></tDllPa>
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>BIN\CMSIS_AGDI.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>CMSIS_AGDI</Key>
<Name>-X"Any" -UAny -O206 -S9 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO14 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>UL2CM3</Key>
<Name>UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0FlashHC32L17X_128K -FL020000 -FS00 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>JL2CM3</Key>
<Name>-U4294967295 -O78 -S1 -ZTIFSpeedSel10000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMRTXEVENTFLAGS</Key>
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>App,0x0A</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>LocalMAC</ItemText>
</Ww>
<Ww>
<count>2</count>
<WinNumber>1</WinNumber>
<ItemText>SGCP.LoginOk</ItemText>
</Ww>
<Ww>
<count>3</count>
<WinNumber>1</WinNumber>
<ItemText>SGCP.UploadOk</ItemText>
</Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>App.Login_LPTimer0</ItemText>
</Ww>
<Ww>
<count>5</count>
<WinNumber>1</WinNumber>
<ItemText>App.Upload_LPTimer0</ItemText>
</Ww>
</WatchWindow1> </WatchWindow1>
<MemoryWindow1> <MemoryWindow1>
<Mm> <Mm>
@@ -314,7 +557,7 @@
<EnableFlashSeq>0</EnableFlashSeq> <EnableFlashSeq>0</EnableFlashSeq>
<EnableLog>0</EnableLog> <EnableLog>0</EnableLog>
<Protocol>2</Protocol> <Protocol>2</Protocol>
<DbgClock>10000000</DbgClock> <DbgClock>5000000</DbgClock>
</DebugDescription> </DebugDescription>
</TargetOption> </TargetOption>
</Target> </Target>
@@ -657,7 +900,7 @@
<Group> <Group>
<GroupName>Debug</GroupName> <GroupName>Debug</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@@ -668,7 +911,7 @@
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\Module\Debug\UartDebug.c</PathWithFileName> <PathWithFileName>..\Module\LaserTracing_Debug\UartDebug.c</PathWithFileName>
<FilenameWithoutPath>UartDebug.c</FilenameWithoutPath> <FilenameWithoutPath>UartDebug.c</FilenameWithoutPath>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
@@ -729,7 +972,7 @@
<Group> <Group>
<GroupName>LORA</GroupName> <GroupName>LORA</GroupName>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@@ -737,7 +980,7 @@
<GroupNumber>7</GroupNumber> <GroupNumber>7</GroupNumber>
<FileNumber>31</FileNumber> <FileNumber>31</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\Module\LORA\sx127x.c</PathWithFileName> <PathWithFileName>..\Module\LORA\sx127x.c</PathWithFileName>
+636 -6
View File
@@ -7,7 +7,598 @@
<Targets> <Targets>
<Target> <Target>
<TargetName>HC32L17X</TargetName> <TargetName>HC32L17X_debug</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pArmCC>6160000::V6.16::ARMCLANG</pArmCC>
<pCCUsed>6160000::V6.16::ARMCLANG</pCCUsed>
<uAC6>1</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>HC32L170JATA</Device>
<Vendor>HDSC</Vendor>
<PackID>HDSC.HC32L17X.1.0.1</PackID>
<PackURL>https://raw.githubusercontent.com/hdscmcu/pack/master/</PackURL>
<Cpu>IRAM(0x20000000,0x4000) IROM(0x00000000,0x20000) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM))</FlashDriverDll>
<DeviceId>0</DeviceId>
<RegisterFile>$$Device:HC32L170JATA$Device\Include\HC32L170JATA.h</RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
<Linker></Linker>
<OHString></OHString>
<InfinionOptionDll></InfinionOptionDll>
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<SFDFile>$$Device:HC32L170JATA$SVD\HC32L170JATA.sfr</SFDFile>
<bCustSvd>1</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
<IncludePath></IncludePath>
<LibPath></LibPath>
<RegisterFilePath></RegisterFilePath>
<DBRegisterFilePath></DBRegisterFilePath>
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
<ButtonStop>0</ButtonStop>
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\output\</OutputDirectory>
<OutputName>hc32l17x</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>1</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
<ListingPath>.\output\release\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
<nStopU2X>0</nStopU2X>
</BeforeCompile>
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopB1X>0</nStopB1X>
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>1</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name>D:\Keil5\ARM\ARMCC\bin\fromelf.exe --bin -o .\output\app.bin .\output\hc32l17x.axf</UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>0</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>0</AlwaysBuild>
<GenerateAssemblyFile>0</GenerateAssemblyFile>
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<DllOption>
<SimDllName>SARMCM3.DLL</SimDllName>
<SimDllArguments> </SimDllArguments>
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
<SimDlgDllArguments>-pCM0+</SimDlgDllArguments>
<TargetDllName>SARMCM3.DLL</TargetDllName>
<TargetDllArguments> </TargetDllArguments>
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
<TargetDlgDllArguments>-pCM0+</TargetDlgDllArguments>
</DllOption>
<DebugOption>
<OPTHX>
<HexSelection>1</HexSelection>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
</DebugOption>
<Utilities>
<Flash1>
<UseTargetDll>1</UseTargetDll>
<UseExternalTool>0</UseExternalTool>
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>4096</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3>"" ()</Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
<pFcArmRoot></pFcArmRoot>
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
<ArmAdsMisc>
<GenerateListings>0</GenerateListings>
<asHll>1</asHll>
<asAsm>1</asAsm>
<asMacX>1</asMacX>
<asSyms>1</asSyms>
<asFals>1</asFals>
<asDbgD>1</asDbgD>
<asForm>1</asForm>
<ldLst>0</ldLst>
<ldmm>1</ldmm>
<ldXref>1</ldXref>
<BigEnd>0</BigEnd>
<AdsALst>0</AdsALst>
<AdsACrf>0</AdsACrf>
<AdsANop>0</AdsANop>
<AdsANot>0</AdsANot>
<AdsLLst>1</AdsLLst>
<AdsLmap>1</AdsLmap>
<AdsLcgr>0</AdsLcgr>
<AdsLsym>1</AdsLsym>
<AdsLszi>1</AdsLszi>
<AdsLtoi>1</AdsLtoi>
<AdsLsun>0</AdsLsun>
<AdsLven>0</AdsLven>
<AdsLsxf>0</AdsLsxf>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M0+"</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
<hadIROM>1</hadIROM>
<hadIRAM>1</hadIRAM>
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<RvdsMve>0</RvdsMve>
<RvdsCdeCp>0</RvdsCdeCp>
<nBranchProt>0</nBranchProt>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
<useUlib>1</useUlib>
<EndSel>0</EndSel>
<uLtcg>0</uLtcg>
<nSecure>0</nSecure>
<RoSelD>3</RoSelD>
<RwSelD>3</RwSelD>
<CodeSel>0</CodeSel>
<OptFeed>0</OptFeed>
<NoZi1>0</NoZi1>
<NoZi2>0</NoZi2>
<NoZi3>0</NoZi3>
<NoZi4>0</NoZi4>
<NoZi5>0</NoZi5>
<Ro1Chk>0</Ro1Chk>
<Ro2Chk>0</Ro2Chk>
<Ro3Chk>0</Ro3Chk>
<Ir1Chk>1</Ir1Chk>
<Ir2Chk>0</Ir2Chk>
<Ra1Chk>0</Ra1Chk>
<Ra2Chk>0</Ra2Chk>
<Ra3Chk>0</Ra3Chk>
<Im1Chk>1</Im1Chk>
<Im2Chk>0</Im2Chk>
<OnChipMemories>
<Ocm1>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm1>
<Ocm2>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm2>
<Ocm3>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm3>
<Ocm4>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm4>
<Ocm5>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm5>
<Ocm6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm6>
<IRAM>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x4000</Size>
</IRAM>
<IROM>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x20000</Size>
</IROM>
<XRAM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</XRAM>
<OCR_RVCT1>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT1>
<OCR_RVCT2>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT2>
<OCR_RVCT3>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x20000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT5>
<OCR_RVCT6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT6>
<OCR_RVCT7>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT7>
<OCR_RVCT8>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT8>
<OCR_RVCT9>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x4000</Size>
</OCR_RVCT9>
<OCR_RVCT10>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT10>
</OnChipMemories>
<RvctStartVector></RvctStartVector>
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
<Strict>0</Strict>
<EnumInt>1</EnumInt>
<PlainCh>0</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>3</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uGnu>1</uGnu>
<useXO>0</useXO>
<v6Lang>4</v6Lang>
<v6LangP>5</v6LangP>
<vShortEn>0</vShortEn>
<vShortWch>0</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath>..\mcu\common;..\source;..\driver\inc;..\source\inc;..\Module\LaserTracing_Debug;..\Module\lsm6dsl;..\Module\MMC5983;..\Module\LORA;..\Module\Imu</IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>1</interw>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<thumb>0</thumb>
<SplitLS>0</SplitLS>
<SwStkChk>0</SwStkChk>
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<ClangAsOpt>4</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
<LDads>
<umfTarg>1</umfTarg>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
<TextAddressRange>0x00000000</TextAddressRange>
<DataAddressRange>0x20000000</DataAddressRange>
<pXoBase></pXoBase>
<ScatterFile>template.sct</ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc>--keep=*Handler</Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
</TargetArmAds>
</TargetOption>
<Groups>
<Group>
<GroupName>common</GroupName>
<Files>
<File>
<FileName>startup_hc32l17x.s</FileName>
<FileType>2</FileType>
<FilePath>.\startup_hc32l17x.s</FilePath>
</File>
<File>
<FileName>system_hc32l17x.c</FileName>
<FileType>1</FileType>
<FilePath>..\mcu\common\system_hc32l17x.c</FilePath>
</File>
<File>
<FileName>interrupts_hc32l17x.c</FileName>
<FileType>1</FileType>
<FilePath>..\mcu\common\interrupts_hc32l17x.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>source</GroupName>
<Files>
<File>
<FileName>main.c</FileName>
<FileType>1</FileType>
<FilePath>..\source\Src\main.c</FilePath>
</File>
<File>
<FileName>bsp.c</FileName>
<FileType>1</FileType>
<FilePath>..\source\src\bsp.c</FilePath>
</File>
<File>
<FileName>Algorithm.c</FileName>
<FileType>1</FileType>
<FilePath>..\source\src\Algorithm.c</FilePath>
</File>
<File>
<FileName>SGCP.c</FileName>
<FileType>1</FileType>
<FilePath>..\source\src\SGCP.c</FilePath>
</File>
<File>
<FileName>Update.c</FileName>
<FileType>1</FileType>
<FilePath>..\source\src\Update.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>driver</GroupName>
<Files>
<File>
<FileName>dmac.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\dmac.c</FilePath>
</File>
<File>
<FileName>flash.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\flash.c</FilePath>
</File>
<File>
<FileName>gpio.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\gpio.c</FilePath>
</File>
<File>
<FileName>lpm.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\lpm.c</FilePath>
</File>
<File>
<FileName>lpuart.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\lpuart.c</FilePath>
</File>
<File>
<FileName>spi.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\spi.c</FilePath>
</File>
<File>
<FileName>uart.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\uart.c</FilePath>
</File>
<File>
<FileName>wdt.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\wdt.c</FilePath>
</File>
<File>
<FileName>ddl.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\ddl.c</FilePath>
</File>
<File>
<FileName>sysctrl.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\sysctrl.c</FilePath>
</File>
<File>
<FileName>reset.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\reset.c</FilePath>
</File>
<File>
<FileName>lptim.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\lptim.c</FilePath>
</File>
<File>
<FileName>rtc.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\rtc.c</FilePath>
</File>
<File>
<FileName>trim.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\trim.c</FilePath>
</File>
<File>
<FileName>i2c.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\i2c.c</FilePath>
</File>
<File>
<FileName>bt.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\bt.c</FilePath>
</File>
<File>
<FileName>adc.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\adc.c</FilePath>
</File>
<File>
<FileName>bgr.c</FileName>
<FileType>1</FileType>
<FilePath>..\driver\src\bgr.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>Debug</GroupName>
<Files>
<File>
<FileName>UartDebug.c</FileName>
<FileType>1</FileType>
<FilePath>..\Module\LaserTracing_Debug\UartDebug.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>LSM6DSL</GroupName>
<Files>
<File>
<FileName>lsm6dsl_reg.c</FileName>
<FileType>1</FileType>
<FilePath>..\Module\lsm6dsl\lsm6dsl_reg.c</FilePath>
</File>
<File>
<FileName>lsm6dsl_app.c</FileName>
<FileType>1</FileType>
<FilePath>..\Module\lsm6dsl\lsm6dsl_app.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>MMC5893</GroupName>
<Files>
<File>
<FileName>mmc5983.c</FileName>
<FileType>1</FileType>
<FilePath>..\Module\MMC5983\mmc5983.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>LORA</GroupName>
<Files>
<File>
<FileName>sx127x.c</FileName>
<FileType>1</FileType>
<FilePath>..\Module\LORA\sx127x.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>Imu</GroupName>
<Files>
<File>
<FileName>Imu.c</FileName>
<FileType>1</FileType>
<FilePath>..\Module\Imu\Imu.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>ReadMe</GroupName>
<Files>
<File>
<FileName>ReadMe.txt</FileName>
<FileType>5</FileType>
<FilePath>..\ReadMe.txt</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
</Groups>
</Target>
<Target>
<TargetName>HC32L17X_boot</TargetName>
<ToolsetNumber>0x4</ToolsetNumber> <ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName> <ToolsetName>ARM-ADS</ToolsetName>
<pArmCC>6160000::V6.16::ARMCLANG</pArmCC> <pArmCC>6160000::V6.16::ARMCLANG</pArmCC>
@@ -330,7 +921,7 @@
<uC99>1</uC99> <uC99>1</uC99>
<uGnu>0</uGnu> <uGnu>0</uGnu>
<useXO>0</useXO> <useXO>0</useXO>
<v6Lang>3</v6Lang> <v6Lang>4</v6Lang>
<v6LangP>5</v6LangP> <v6LangP>5</v6LangP>
<vShortEn>0</vShortEn> <vShortEn>0</vShortEn>
<vShortWch>0</vShortWch> <vShortWch>0</vShortWch>
@@ -339,9 +930,9 @@
<v6Rtti>0</v6Rtti> <v6Rtti>0</v6Rtti>
<VariousControls> <VariousControls>
<MiscControls></MiscControls> <MiscControls></MiscControls>
<Define></Define> <Define>USE_BOOTLOADER,</Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>..\mcu\common;..\source;..\driver\inc;..\source\inc;..\Module\Debug;..\Module\lsm6dsl;..\Module\MMC5983;..\Module\LORA;..\Module\Imu</IncludePath> <IncludePath>..\mcu\common;..\source;..\driver\inc;..\source\inc;..\Module\LaserTracing_Debug;..\Module\lsm6dsl;..\Module\MMC5983;..\Module\LORA;..\Module\Imu</IncludePath>
</VariousControls> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@@ -389,6 +980,44 @@
<FileName>startup_hc32l17x.s</FileName> <FileName>startup_hc32l17x.s</FileName>
<FileType>2</FileType> <FileType>2</FileType>
<FilePath>.\startup_hc32l17x.s</FilePath> <FilePath>.\startup_hc32l17x.s</FilePath>
<FileOption>
<CommonProperty>
<UseCPPCompiler>2</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>2</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
<Aads>
<interw>2</interw>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<thumb>2</thumb>
<SplitLS>2</SplitLS>
<SwStkChk>2</SwStkChk>
<NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc>
<useXO>2</useXO>
<ClangAsOpt>0</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define>USE_BOOTLOADER</Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
</FileArmAds>
</FileOption>
</File> </File>
<File> <File>
<FileName>system_hc32l17x.c</FileName> <FileName>system_hc32l17x.c</FileName>
@@ -533,7 +1162,7 @@
<File> <File>
<FileName>UartDebug.c</FileName> <FileName>UartDebug.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\Module\Debug\UartDebug.c</FilePath> <FilePath>..\Module\LaserTracing_Debug\UartDebug.c</FilePath>
</File> </File>
</Files> </Files>
</Group> </Group>
@@ -605,7 +1234,8 @@
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device"> <component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/> <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
<targetInfos> <targetInfos>
<targetInfo name="HC32L17X"/> <targetInfo name="HC32L17X_boot"/>
<targetInfo name="HC32L17X_debug"/>
</targetInfos> </targetInfos>
</component> </component>
</components> </components>
+5 -1
View File
@@ -162,7 +162,11 @@ Reset_Handler PROC
RAMCODE RAMCODE
; reset Vector table address. ; reset Vector table address.
LDR R0, =0xE000ED08 LDR R0, =0xE000ED08
LDR R2, =new_vect_table ;升级时打开
IF :DEF:USE_BOOTLOADER
LDR R2, =new_vect_table ;使用boot程序时
ENDIF
STR R2, [R0] STR R2, [R0]
LDR R0, =SystemInit LDR R0, =SystemInit
+87 -19
View File
@@ -1,22 +1,16 @@
#include "sx127x.h" #include "sx127x.h"
#include "ddl.h" #include "ddl.h"
#include "Debug.h" #include "UartDebug.h"
#include "spi.h"
#include "bsp.h"
#define LORAChannel 8
#define LORARegPreamble 10
#if (LORA_MODULE == SX1278W1) #if (LORA_MODULE == SX1278W1)
Sx1276Type_t LoRaPara = { Sx1276Type_t LoRaPara = {
.ucChannel = LORAChannel, //4 or 12 .ucChannel = 8, //4 or 12
.dwFreqHz = FREQ_CENT, .dwFreqHz = FREQ_CENT,
.ucPower = 20, .ucPower = 20,
.SignalBw = SX1276_BW_250K, .SignalBw = SX1276_BW_250K,
.SpreadFactor = SX1276_SF_512, .SpreadFactor = SX1276_SF_512,
.ErrorCoding = SX1276_EC_4_6, .ErrorCoding = SX1276_EC_4_6,
.RegPreamble = LORARegPreamble,//10 or 16 .RegPreamble = 10,//10 or 16
.ucOpModePrev = RFLR_OPMODE_STANDBY, .ucOpModePrev = RFLR_OPMODE_STANDBY,
.bAntSwPrev = RF_ANT_RECEIVER, .bAntSwPrev = RF_ANT_RECEIVER,
.RegBuff = 0, .RegBuff = 0,
@@ -70,6 +64,7 @@ void SX1276WriteBuffer(uint8_t ucAddr, uint8_t *pucBuff, uint8_t ucLen)
} }
LORA_SPI_NSS_SET(); LORA_SPI_NSS_SET();
} }
void SX1276Write(uint8_t ucAddr, uint8_t ucData) void SX1276Write(uint8_t ucAddr, uint8_t ucData)
{ {
SX1276WriteBuffer(ucAddr, &ucData, 1); SX1276WriteBuffer(ucAddr, &ucData, 1);
@@ -229,20 +224,18 @@ void SX1276LoRaSetOpMode(Sx1276OpModeType ucOpMode)
LoRaPara.ucOpModePrev = LoRaPara.RegBuff.RegOpMode & ~RFLR_OPMODE_MASK; LoRaPara.ucOpModePrev = LoRaPara.RegBuff.RegOpMode & ~RFLR_OPMODE_MASK;
if( ucOpMode != LoRaPara.ucOpModePrev){ if( ucOpMode != LoRaPara.ucOpModePrev){
if(ucOpMode == RFLR_OPMODE_TRANSMITTER){ if(ucOpMode == RFLR_OPMODE_TRANSMITTER){
//CLR_LORA_RXEN(); //CLR_LORA_RXEN();
//SET_LORA_TXEN(); //SET_LORA_TXEN();
bAntSwStatus = RF_ANT_TRANSMITTER; bAntSwStatus = RF_ANT_TRANSMITTER;
} }
else if(ucOpMode == RFLR_OPMODE_RECEIVER){ else if(ucOpMode == RFLR_OPMODE_RECEIVER){
bAntSwStatus = RF_ANT_RECEIVER;
//CLR_LORA_TXEN(); //CLR_LORA_TXEN();
//SET_LORA_RXEN(); //SET_LORA_RXEN();
bAntSwStatus = RF_ANT_RECEIVER;
} }
else { else {
//CLR_LORA_TXEN();
//CLR_LORA_RXEN();
bAntSwStatus = RF_ANT_CLOSE; bAntSwStatus = RF_ANT_CLOSE;
} }
if( bAntSwStatus != LoRaPara.bAntSwPrev ){ 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; LoRaPara.RegBuff.RegLna = RFLR_LNA_GAIN_G1;
SX1276WriteBuffer(REG_LR_OPMODE, (uint8_t*)&(LoRaPara.RegBuff) + 1, SIZE_OF_REGISTERS); SX1276WriteBuffer(REG_LR_OPMODE, (uint8_t*)&(LoRaPara.RegBuff) + 1, SIZE_OF_REGISTERS);
//set the RF settings //set the RF settings
SX1276LoRaWriteChannel(LoRaPara.ucChannel); //SX1276LoRaWriteChannel(LoRaPara.ucChannel);
//SX1276LoRaSetFreqHz(LoRaPara.dwFreqHz); SX1276LoRaSetFreqHz(LoRaPara.dwFreqHz);
//REG_LR_MODEMCONFIG1 //REG_LR_MODEMCONFIG1
SX1276Read(REG_LR_MODEMCONFIG1, &(LoRaPara.RegBuff.RegModemConfig1)); SX1276Read(REG_LR_MODEMCONFIG1, &(LoRaPara.RegBuff.RegModemConfig1));
//SignalBandwidth //SignalBandwidth
@@ -333,8 +326,14 @@ void Sx1276LoRaInit(void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen))
//验证寄存器操作是否成功 //验证寄存器操作是否成功
SX1276Write(REG_LR_MODEMCONFIG2, LoRaPara.RegBuff.RegModemConfig2); SX1276Write(REG_LR_MODEMCONFIG2, LoRaPara.RegBuff.RegModemConfig2);
LoRaPara.RegBuff.RegModemConfig2 = 0; uint8_t Config2 = 0;
SX1276Read(REG_LR_MODEMCONFIG2, &(LoRaPara.RegBuff.RegModemConfig2)); 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); SX1276LoRaSetSymbTimeout(0x3FF);
LoRaPara.RegBuff.RegPreambleMsb= (LoRaPara.RegPreamble >> 8) & 0x00ff; LoRaPara.RegBuff.RegPreambleMsb= (LoRaPara.RegPreamble >> 8) & 0x00ff;
@@ -363,7 +362,8 @@ void Sx1276LoRaInit(void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen))
Sx1276LoRaEnterRx(); Sx1276LoRaEnterRx();
} }
void IsrSx1276LoRaTxRx(void){ void IsrSx1276LoRaTxRx(void)
{
switch (LoRaPara.State){ switch (LoRaPara.State){
case SX1276_IDLE: case SX1276_IDLE:
case SX1276_RX: case SX1276_RX:
@@ -610,4 +610,72 @@ void SX1276LoCalcRssiSnr(int8_t *pswRssi, int8_t *psbSnr)
} }
*psbSnr= sbSnr; *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 #endif
+11
View File
@@ -2,6 +2,7 @@
#define __SX127X_H #define __SX127X_H
#include "bsp.h" #include "bsp.h"
#include "main.h"
//Constant values need to compute the RSSI value //Constant values need to compute the RSSI value
#define RSSI_OFFSET_LF -155 #define RSSI_OFFSET_LF -155
@@ -733,6 +734,7 @@ typedef struct {
uint8_t ucTxPacketSize; uint8_t ucTxPacketSize;
uint8_t RxTxBuff[LORA_BUFF_SIZE]; uint8_t RxTxBuff[LORA_BUFF_SIZE];
void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen); void (*RxCallBack)(uint8_t *rBuff, uint8_t rlen);
int RxRet;
}Sx1276Type_t, *pSx1276Type; }Sx1276Type_t, *pSx1276Type;
//ISM Freq In China //ISM Freq In China
@@ -822,5 +824,14 @@ Sx1276StateType_t SX1276LoRaReadStatus(void);
void SX1276LoCalcRssiSnr(int8_t *pswRssi, int8_t *psbSnr); void SX1276LoCalcRssiSnr(int8_t *pswRssi, int8_t *psbSnr);
void Sx1276LoRaSleep(void); void Sx1276LoRaSleep(void);
void Sx1276LoRaWakeup(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 #endif
+130
View File
@@ -0,0 +1,130 @@
# ---> IAR
# Compiled binaries
*.o
*.bin
*.elf
*.hex
*.map
*.out
*.obj
# Trash
*.bak
thumbs.db
*.~*
# IAR Settings
**/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos
# IAR Debug Exe
**/Exe/*.sim
# IAR Debug Obj
**/Obj/*.pbd
**/Obj/*.pbd.*
**/Obj/*.pbi
**/Obj/*.pbi.*
# IAR project "Debug" directory
Debug/
# IAR project "Release" directory
Release/
# IAR project settings directory
settings/
# IAR backup files
Backup*
# IAR .dep files
*.dep
# ---> IAR_EWARM
# gitignore template for the IAR EWARM
# website: https://www.iar.com/knowledge/support/technical-notes/ide/which-files-should-be-version-controlled/
# Some tools will put the EWARM files
# under a subdirectory with the same name
# as the configuration.
# Example
# EWARM/Config1/Obj /List /Exe
# EWARM/Config2/Obj /List /Exe
EWARM/**/Obj
EWARM/**/List
EWARM/**/Exe
# Autogenerated project files
*.dep
*.ewt
# Autogenerated folder for debugger
EWARM/settings
# ---> uVision
# git ignore file for Keil µVision Project
# µVision 5 and µVision 4 Project screen layout file
*.uvguix.*
*.uvgui.*
# Listing Files
*.i
*.lst
*.m51
*.m66
*.map
# Object Files
*.axf
*.b[0-2][0-9]
*.b3[0-1]
*.bak
*.build_log.htm
*.crf
*.d
*.dep
*.elf
*.htm
*.iex
*.lnp
*.o
*.obj
*.sbr
# Firmware Files
*.bin
*.h86
*.hex
# Build Files
.bat
# Debugger Files
.ini
# JLink Files
JLinkLog.txt
# Other Files
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
+4
View File
@@ -0,0 +1,4 @@
# LaserTracing_Debug
# 适用于LaserTracing项目
# 单片机HC32L170
# 转换为模块仓库 2026-05-15
File diff suppressed because it is too large Load Diff
+59
View File
@@ -0,0 +1,59 @@
#ifndef __DEBUG_H
#define __DEBUG_H
#include "bsp.h"
#if (USE_DEBUG != 0)
#define DEBUG_BUFSIZE 200
#define DEBUG_BUFF_SIZE_MAX 512
#define DebugUartSend(X) LPUartSend(X)
void vcom_Send( char *format, ... );
void vcom_Send2(uint8_t *sData, uint16_t len);
#define DBG_LOG2(x, y) vcom_Send2(x, y) //打印长度超过缓存DEBUG_BUFF_SIZE_MAX的信息
#define DBG_LOG(...) vcom_Send(__VA_ARGS__)
#define DBG_LOG_F(fmt,arg...) LOG("[%s] "fmt,__FUNCTION__,##arg)
#define DBG_ARRAY(ARRAY,SIZE) { \
if(ARRAY != NULL) { \
for(int i = 0; i < SIZE; i++) { \
DBG_LOG("%02x ",ARRAY[i]); \
} \
DBG_LOG("\r\n"); \
} \
}
typedef enum {
DBG_CH_UART0 = 0, //默认串口调试方式 Uart0Init
DBG_CH_RS485_1, //RS485_1 (LPUART0)
}DebugChannel_e;
extern volatile DebugChannel_e gDebugChannel;
typedef void (*DebugExec)(int argc, char *argv[]);
typedef struct{
char *DBGCmd;
DebugExec DBGExec;
}DBGFunType;
void DebugUartIRQ(uint8_t Data);
void DebugLoopHandler(void);
void Debug1mSRoutine(void);
//void ReadBootPara(BootPara rData);
//void WriteBootPara(BootPara wData);
//extern BootPara_t BLPara;
#else
#define DBG_LOG2(x, y)
#define DBG_LOG(...)
#define DBG_LOG_F(fmt,arg...)
#define DBG_ARRAY(ARRAY,SIZE)
#endif
#endif
+1 -1
View File
@@ -48,7 +48,7 @@ bool count_greater(int32_t *arr, uint8_t size, int32_t target);
bool count_smaller(int32_t *arr, uint8_t size, int32_t target); bool count_smaller(int32_t *arr, uint8_t size, int32_t target);
uint16_t CRC_Modbus(uint16_t wBase, uint8_t *para, uint16_t length); uint16_t CRC_Modbus(uint16_t wBase, uint8_t *para, uint16_t length);
uint8_t CRC_Sum(uint8_t *_pbuff, uint16_t _cmdLen); uint8_t CRC_Sum(uint8_t *_pbuff, uint16_t _cmdLen);
bool isAllZero(uint8_t *arr, int size); bool is_all_byte(const uint8_t *data, size_t len, uint8_t val);
#endif #endif
+1 -7
View File
@@ -6,12 +6,6 @@
#define WORK_MODE 1 //工作模式选择,0、本机为查询模式,1、本机为上报模式(低功耗) #define WORK_MODE 1 //工作模式选择,0、本机为查询模式,1、本机为上报模式(低功耗)
#define SGCP_SELECT 1 //协议选择,0、本机为单个主设备接多个子设备,1、本机为单个主设备不接子设备,2、本机为单个子设备 #define SGCP_SELECT 1 //协议选择,0、本机为单个主设备接多个子设备,1、本机为单个主设备不接子设备,2、本机为单个子设备
#define LocalDataLen sizeof(SGCP.DevData.LaserTracing)//本机设备数据长度
#define LocalType LASER_TRACING //本机设备类型
#define CommWay LORA //本机通讯方式
#define DeviceSign MASTER //本机设备标志
#define AddNumber (0x000017 + DeviceSign)//本机地址编号,数字部分对应唯一地址编号
//09 00 01 00 00 00
typedef struct {//网关与主设备固定帧 typedef struct {//网关与主设备固定帧
uint8_t Header; uint8_t Header;
@@ -179,7 +173,7 @@ typedef enum {
RS485 = 0x02, //0x02 RS485通讯 RS485 = 0x02, //0x02 RS485通讯
RS232 = 0x03, //0x03 RS232通讯 RS232 = 0x03, //0x03 RS232通讯
CAN = 0x04, //0x04 CAN通讯 CAN = 0x04, //0x04 CAN通讯
_4G = 0x05, //0x05 _4G通讯 CATONE = 0x05, //0x05 _4G通讯
BLE = 0x06, //0x06 BLE通讯 BLE = 0x06, //0x06 BLE通讯
WIFI = 0x07, //0x07 WIFI通讯 WIFI = 0x07, //0x07 WIFI通讯
UART = 0x08, //0x08 UART通讯 UART = 0x08, //0x08 UART通讯
+2 -11
View File
@@ -3,7 +3,6 @@
#include <stdint.h> #include <stdint.h>
#include "bsp.h" #include "bsp.h"
#include "UartDebug.h"
#define APP_START_FLAG 0x55AA5A5A #define APP_START_FLAG 0x55AA5A5A
#define APP_UPDATE_FLAG 0xA5A5AA55 #define APP_UPDATE_FLAG 0xA5A5AA55
@@ -24,14 +23,6 @@
#define BOOT_PARA_ADDRESS (0x0001FC00)//(FLASH_BASE + BOOT_SIZE) #define BOOT_PARA_ADDRESS (0x0001FC00)//(FLASH_BASE + BOOT_SIZE)
#define BOOT_PARA_SIZE (FLASH_SECTOR_SIZE) #define BOOT_PARA_SIZE (FLASH_SECTOR_SIZE)
typedef struct {
uint32_t AppFlag;
uint32_t UpdateFlag;
uint32_t PackageCnt;
uint32_t AppSize;
uint32_t Crc32Check;
}BootPara_t, *BootPara;
//主机下发升级请求载荷结构体 //主机下发升级请求载荷结构体
typedef struct { typedef struct {
uint16_t PackageNum; uint16_t PackageNum;
@@ -52,8 +43,8 @@ typedef struct {
#define U_DBG_LOG(...) DBG_LOG(__VA_ARGS__) #define U_DBG_LOG(...) DBG_LOG(__VA_ARGS__)
#define U_DELAY_MS(x) delay_ms(x) #define U_DELAY_MS(x) delay_ms(x)
#define U_SYSTEM_TESET() SystemReset() #define U_SYSTEM_TESET() SystemReset()
#define SAVE_BOOT_PARA(addr) FlashWrite(BOOT_PARA_ADDRESS, addr, sizeof(BLPara) / 4) #define SAVE_BOOT_PARA(addr) SAVE_APP_PARA(addr)
#define READ_BOOT_PARA(addr) FlashRead(BOOT_PARA_ADDRESS, addr, sizeof(BLPara) / 4) #define READ_BOOT_PARA(addr) READ_APP_PARA(addr)
//输出接口 //输出接口
void Update(uint8_t *PayLoad); void Update(uint8_t *PayLoad);
+44 -10
View File
@@ -6,6 +6,7 @@
#include <time.h> #include <time.h>
#include "gpio.h" #include "gpio.h"
#include "spi.h" #include "spi.h"
#include "Update.h"
/*模块启用与关闭*/ /*模块启用与关闭*/
#define USE_DEBUG 1 //调试串口选择,0、关闭,1、启用 #define USE_DEBUG 1 //调试串口选择,0、关闭,1、启用
@@ -23,8 +24,7 @@
#define USE_SPI0 1 //SPI1开关,0、关闭,1、启用 #define USE_SPI0 1 //SPI1开关,0、关闭,1、启用
#define USE_SPI1 0 //SPI1开关,0、关闭,1、启用 #define USE_SPI1 0 //SPI1开关,0、关闭,1、启用
#define USE_BOOTLOADER 1 //BOOTLOADER开关,0、关闭,1、启用 //#define USE_BOOTLOADER 1 //BOOTLOADER开关,0、关闭,1、启用
#define USE_LORA_CH 1 //0为测试通道
//<<---------------------------- MCU -------------------------------->> //<<---------------------------- MCU -------------------------------->>
//< UART0 //< UART0
@@ -209,12 +209,22 @@
extern float VBAT_8V4; extern float VBAT_8V4;
extern uint8_t VBAT_Percentage; extern uint8_t VBAT_Percentage;
typedef struct {
uint32_t AppFlag;
uint32_t UpdateFlag;
uint32_t PackageCnt;
uint32_t AppSize;
uint32_t Crc32Check;
uint32_t FirstRunFlag;//第一次运行
uint8_t DevMac[6];//设备MAC
uint32_t LoraFreq;//Lora频率
}BootPara_t, *BootPara;
typedef struct { typedef struct {
uint16_t CollectTime; //数据采集时间间隔,设置范围30*N秒,1<=N<=240(默认5分钟,N=10) uint16_t CollectTime; //数据采集时间间隔,设置范围30*N秒,1<=N<=240(默认300秒,N=10)
uint16_t ReportInterval; //上报时间间隔,设置范围,30*N秒,10<=N<=1440(默认20分钟,N=40 uint16_t ReportInterval; //上报时间间隔,设置范围,30*N秒,10<=N<=1440(默认1200秒,N=40
uint8_t ERInterval; //紧急上报时间间隔,设置范围,30*N秒,2<=N<=10(默认2分钟,N=4 uint8_t ERInterval; //紧急上报时间间隔,设置范围,30*N秒,2<=N<=10(默认120秒,N=4
uint8_t ERTime; //紧急上报时长,设置范围,30*N秒,20<=N<=240(默认20分钟,N=40 uint8_t ERTime; //紧急上报时长,设置范围,30*N秒,20<=N<=240(默认1200秒,N=40
uint32_t TimeStamp; //网关返回RTC时间戳 uint32_t TimeStamp; //网关返回RTC时间戳
}__attribute__((packed))LayoutPara_t,*LayoutPara;//上位机下发的配置参数 }__attribute__((packed))LayoutPara_t,*LayoutPara;//上位机下发的配置参数
@@ -225,16 +235,39 @@ typedef struct {
}__attribute__ ((packed))CalibratePara_t, *CalibratePara; }__attribute__ ((packed))CalibratePara_t, *CalibratePara;
typedef struct { typedef struct {
bool OnOff;
uint8_t ucChannel;
int8_t ucPower;
uint8_t SignalBw;
uint8_t SpreadFactor;
uint8_t ErrorCoding;
uint8_t RegPreamble;
uint32_t FreqCent;
}__attribute__ ((packed))LoraPara_t, *pLoraPara;
typedef struct {
bool Enable; //串口使能
bool UpgradeEnable;//升级功能使能
uint32_t Addr; //本机485地址
uint32_t BaudRate;
}__attribute__((packed))RS485Para_t, *RS485Para;
typedef struct {
BootPara_t BLPara;
LayoutPara_t Layout; LayoutPara_t Layout;
CalibratePara_t CaliPara; CalibratePara_t CaliPara;
uint32_t RS485Addr; //本机485地址 RS485Para_t Rs485Ch1;
RS485Para_t Rs485Ch2;
uint32_t FactoryFlag;//出厂标志位 uint32_t FactoryFlag;//出厂标志位
LoraPara_t Lora;
}AppPara_T, *pAppPara; }AppPara_T, *pAppPara;
#define APP_PARA_ADDRESS (0x0001FE00) //#define APP_PARA_ADDRESS (0x0001FC00)
#define SAVE_APP_PARA(addr) FlashWrite(APP_PARA_ADDRESS, addr, sizeof(App.Para) / 4) #define SAVE_APP_PARA(addr) FlashWrite(BOOT_PARA_ADDRESS, addr, sizeof(App.Para) / 4)
#define READ_APP_PARA(addr) FlashRead(APP_PARA_ADDRESS, addr, sizeof(App.Para) / 4) #define READ_APP_PARA(addr) FlashRead(BOOT_PARA_ADDRESS, addr, sizeof(App.Para) / 4)
void BspInit(void); void BspInit(void);
void LpUart0Init(uint32_t Baud);
void Uart0Init(uint32_t Baud);
void EnterDeepSleep(void); void EnterDeepSleep(void);
void DBGUartSendByte(uint8_t sData); void DBGUartSendByte(uint8_t sData);
void DBGUartSend(uint8_t *sData, int sLen); void DBGUartSend(uint8_t *sData, int sLen);
@@ -269,3 +302,4 @@ void LORAIntDisable(void);
void ACCandMMCIntEnable(void); void ACCandMMCIntEnable(void);
void ACCandMMCIntDisable(void); void ACCandMMCIntDisable(void);
#endif #endif
+13 -5
View File
@@ -2,8 +2,16 @@
#define __MAIN_H #define __MAIN_H
#include "bsp.h" #include "bsp.h"
#include "UartDebug.h" #include "UartDebug.h"
#include "Update.h"
#include "Imu.h" #include "Imu.h"
#define SOFTWARE_VERSION 12 //软件版本
#define HARDWARE_VERSION 11 //硬件版本
#define MAIN_DBG_LOG(...) { if(MainDispEn) DBG_LOG(__VA_ARGS__);}
#define DATA_DBG_LOG(...) { if(DataDispEn) DBG_LOG(__VA_ARGS__);}
#define X 0 #define X 0
#define Y 1 #define Y 1
#define Z 2 #define Z 2
@@ -93,15 +101,15 @@ typedef struct {
bool CaliFlag; //标校标志位 bool CaliFlag; //标校标志位
int16_t Nonce; //随机数 int16_t Nonce; //随机数
uint32_t TestTimeCnt;
uint8_t Tcnt;
bool LaserFlag;
}AppDetect_t; }AppDetect_t;
extern AppDetect_t App; extern AppDetect_t App;
void MainDBGOnOff(bool OnOff);
void DataDBGOnOff(bool OnOff);
#endif #endif
+13 -13
View File
@@ -729,23 +729,23 @@ uint8_t CRC_Sum(uint8_t *_pbuff, uint16_t _cmdLen)
return cmd_sum; return cmd_sum;
} }
/***************************************************************************************** /**
* 函数名称: isAllZero * @brief 检查缓冲区是否全部等于指定字节值
* 功能描述: 判断一个数组的值是否全部为0 * @param data : 待检查的数据指针
* : arr,数组 * @param len : 数据长度(字节数)
size,长度 * @param val : 期望的字节值 (0x00 ~ 0xFF)
* 返 回 值: true或false * @return true : 全部等于 val
*****************************************************************************************/ * false: 存在不等于 val 的字节
bool isAllZero(uint8_t *arr, int size) */
bool is_all_byte(const uint8_t *data, size_t len, uint8_t val)
{ {
for (int i = 0; i < size; i++) { for (size_t i = 0; i < len; i++) {
if (arr[i] != 0) { if (data[i] != val) {
return false; // 如果数组中有一个元素不为0,则返回false return false;
} }
} }
return true; // 遍历完数组后,若所有元素都为0,则返回true return true;
} }
/***************************************************************************************** /*****************************************************************************************
* 函数名称: HexToAscii * 函数名称: HexToAscii
* 功能描述: 16进制转ASCII码 * 功能描述: 16进制转ASCII码
+17 -9
View File
@@ -11,11 +11,15 @@ IROM1
串口升级打开USE_BOOTLOADER和点s文件中的LDR R2, =new_vect_table ;升级时打开 串口升级打开USE_BOOTLOADER和点s文件中的LDR R2, =new_vect_table ;升级时打开
*/ */
uint32_t LocalType; //本机设备类型
uint32_t CommWay; //本机通讯方式
uint32_t DeviceSign; //本机设备标志
uint32_t AddNumber; //本机地址编号,数字部分对应唯一地址编号
//09 00 01 00 00 00 //09 00 01 00 00 00
uint8_t LocalMAC[6] = {LocalType & 0xFF, (LocalType >> 8) & 0xFF, CommWay, (AddNumber >> 16) & 0xFF, (AddNumber >> 8) & 0xFF, AddNumber & 0xFF}; //本机MAC地址 uint8_t LocalMAC[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};//本机MAC地址
uint8_t GatewayMAC[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //网关MAC地址,注册时全为0 uint8_t GatewayMAC[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //网关MAC地址,注册时全为0
uint8_t LocalDataPack[LocalDataLen]; //本机数据包 uint8_t LocalDataPack[sizeof(SGCP.DevData.LaserTracing)]; //本机数据包
uint8_t LocalDataLen = sizeof(SGCP.DevData.LaserTracing); //本机设备数据长度
SGCP_t SGCP; SGCP_t SGCP;
@@ -754,7 +758,7 @@ static void MasRevHandler(void)
return; return;
} }
if(SFHeader->Addr != App.Para.RS485Addr) if(SFHeader->Addr != App.Para.Rs485Ch1.Addr)
{ {
if(SFHeader->Addr != 0x00) if(SFHeader->Addr != 0x00)
{ {
@@ -877,7 +881,7 @@ static void GWRevHandler(void)
if(memcmp(GFHeader->MDAddr, LocalMAC, sizeof(GFHeader->MDAddr)) != false) if(memcmp(GFHeader->MDAddr, LocalMAC, sizeof(GFHeader->MDAddr)) != false)
{ {
if(isAllZero(GFHeader->MDAddr, sizeof(GFHeader->MDAddr)) != true) if(is_all_byte(GFHeader->MDAddr, sizeof(GFHeader->MDAddr), 0x00) != true)
{ {
DBG_LOG("Gateway Master Device MAC Err...\r\n"); DBG_LOG("Gateway Master Device MAC Err...\r\n");
return; return;
@@ -1116,7 +1120,7 @@ static void InRevHandler(void)
} }
else else
{ {
App.Para.RS485Addr = temp; App.Para.Rs485Ch1.Addr = temp;
SAVE_APP_PARA((uint32_t *)&App.Para); SAVE_APP_PARA((uint32_t *)&App.Para);
if(SGCP.InStatus == IN_STATUS_IDLE) if(SGCP.InStatus == IN_STATUS_IDLE)
{ {
@@ -1721,7 +1725,7 @@ void GwRevLoopHandler(void)
memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], &SGCP.DevData.LaserTracing.MasterDev, sizeof(SGCP.DevData.LaserTracing.MasterDev)); memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], &SGCP.DevData.LaserTracing.MasterDev, sizeof(SGCP.DevData.LaserTracing.MasterDev));
SGCP.DeviceDataLen += sizeof(SGCP.DevData.LaserTracing.MasterDev); SGCP.DeviceDataLen += sizeof(SGCP.DevData.LaserTracing.MasterDev);
if(isAllZero(LocalDataPack, LocalDataLen) == false) if(is_all_byte(LocalDataPack, LocalDataLen, 0x00) == false)
{ {
memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], LocalDataPack, sizeof(LocalDataPack)); memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], LocalDataPack, sizeof(LocalDataPack));
SGCP.DeviceDataLen = SGCP.DeviceDataLen + DevGetDataMess(LocalType, LocalDataPack);; SGCP.DeviceDataLen = SGCP.DeviceDataLen + DevGetDataMess(LocalType, LocalDataPack);;
@@ -1774,7 +1778,7 @@ void GwRevLoopHandler(void)
SGCP.DeviceMAC[SGCP.ReadDataAdd][0],SGCP.DeviceMAC[SGCP.ReadDataAdd][1],SGCP.DeviceMAC[SGCP.ReadDataAdd][2], SGCP.DeviceMAC[SGCP.ReadDataAdd][0],SGCP.DeviceMAC[SGCP.ReadDataAdd][1],SGCP.DeviceMAC[SGCP.ReadDataAdd][2],
SGCP.DeviceMAC[SGCP.ReadDataAdd][3],SGCP.DeviceMAC[SGCP.ReadDataAdd][4],SGCP.DeviceMAC[SGCP.ReadDataAdd][5]); SGCP.DeviceMAC[SGCP.ReadDataAdd][3],SGCP.DeviceMAC[SGCP.ReadDataAdd][4],SGCP.DeviceMAC[SGCP.ReadDataAdd][5]);
if(isAllZero(LocalDataPack, LocalDataLen) == false) if(is_all_byte(LocalDataPack, LocalDataLen, 0x00) == false)
{ {
memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], LocalDataPack, sizeof(LocalDataPack)); memcpy(&SGCP.DeviceData[SGCP.DeviceDataLen], LocalDataPack, sizeof(LocalDataPack));
SGCP.DeviceDataLen = DevGetDataMess(LocalType, LocalDataPack); SGCP.DeviceDataLen = DevGetDataMess(LocalType, LocalDataPack);
@@ -1817,11 +1821,15 @@ void GwRevLoopHandler(void)
PrintfMess(); PrintfMess();
if(SGCP.LaserOnOff == true) if(SGCP.LaserOnOff == true)
{ {
LASER1_ON();
if(SGCP.LoginOk == true)
ToGWLaserRes(SGCP.LaserOnOff); ToGWLaserRes(SGCP.LaserOnOff);
DBG_LOG("The laser has been activated!\r\n"); DBG_LOG("The laser has been activated!\r\n");
} }
else if(SGCP.LaserOnOff == false) else if(SGCP.LaserOnOff == false)
{ {
LASER1_OFF();
if(SGCP.LoginOk == true)
ToGWLaserRes(SGCP.LaserOnOff); ToGWLaserRes(SGCP.LaserOnOff);
DBG_LOG("The laser has been turned off!\r\n"); DBG_LOG("The laser has been turned off!\r\n");
} }
@@ -2191,7 +2199,7 @@ void InRevLoopHandler(void)
case IN_STATUS_ALTER_485ADDR:{ case IN_STATUS_ALTER_485ADDR:{
PrintfMess(); PrintfMess();
Alter485AddrRes(LocalMAC, true); Alter485AddrRes(LocalMAC, true);
DBG_LOG("Alter RS485Addr:%X\r\n", App.Para.RS485Addr); DBG_LOG("Alter RS485Addr:%X\r\n", App.Para.Rs485Ch1.Addr);
SGCP.InStatus = IN_STATUS_IDLE; SGCP.InStatus = IN_STATUS_IDLE;
break;} break;}
+15 -15
View File
@@ -1,7 +1,7 @@
#include "Update.h" #include "Update.h"
#include "UartDebug.h" #include "UartDebug.h"
#include "main.h"
static BootPara_t BLPara; #include "bsp.h"
/***************************************************************************************** /*****************************************************************************************
* 函数名称: Update * 函数名称: Update
@@ -14,19 +14,19 @@ void Update(uint8_t *PayLoad)
UpDataRequset_t Req; UpDataRequset_t Req;
memcpy(&Req, PayLoad, sizeof(UpDataRequset_t)); memcpy(&Req, PayLoad, sizeof(UpDataRequset_t));
BLPara.AppSize = Req.AppSize; App.Para.BLPara.AppSize = Req.AppSize;
BLPara.Crc32Check = Req.AppCrc32; App.Para.BLPara.Crc32Check = Req.AppCrc32;
BLPara.PackageCnt = Req.PackageNum; App.Para.BLPara.PackageCnt = Req.PackageNum;
BLPara.AppFlag = 0; App.Para.BLPara.AppFlag = 0;
BLPara.UpdateFlag = APP_UPDATE_FLAG; App.Para.BLPara.UpdateFlag = APP_UPDATE_FLAG;
U_DBG_LOG("Receive upgrade command:\r\n"); U_DBG_LOG("Receive upgrade command:\r\n");
U_DBG_LOG("PackageNum: %d\r\n", BLPara.PackageCnt); U_DBG_LOG("PackageNum: %d\r\n", App.Para.BLPara.PackageCnt);
U_DBG_LOG("AppSize: %d\r\n", BLPara.AppSize); U_DBG_LOG("AppSize: %d\r\n", App.Para.BLPara.AppSize);
U_DBG_LOG("AppCrc32: 0x%08x\r\n", BLPara.Crc32Check); U_DBG_LOG("AppCrc32: 0x%08x\r\n", App.Para.BLPara.Crc32Check);
U_DBG_LOG("System Reset!\r\n"); U_DBG_LOG("System Reset!\r\n");
SAVE_BOOT_PARA((uint32_t *)&BLPara); SAVE_BOOT_PARA((uint32_t *)&App.Para);
U_DELAY_MS(200); U_DELAY_MS(200);
U_SYSTEM_TESET(); U_SYSTEM_TESET();
} }
@@ -39,10 +39,10 @@ void Update(uint8_t *PayLoad)
*****************************************************************************************/ *****************************************************************************************/
void UpdateInit(void) void UpdateInit(void)
{ {
READ_BOOT_PARA((uint32_t *)&BLPara); READ_BOOT_PARA((uint32_t *)&App.Para);
if(BLPara.AppFlag != APP_START_FLAG) { if(App.Para.BLPara.AppFlag != APP_START_FLAG) {
BLPara.AppFlag = APP_START_FLAG; App.Para.BLPara.AppFlag = APP_START_FLAG;
SAVE_BOOT_PARA((uint32_t *)&BLPara); SAVE_BOOT_PARA((uint32_t *)&App.Para);
} }
} }
+23 -9
View File
@@ -89,7 +89,7 @@ static void SystemRCLInit(void)
Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE); ///< 使能RCL时钟 Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE); ///< 使能RCL时钟
} }
static void Uart0Init(void) void Uart0Init(uint32_t Baud)
{ {
stc_gpio_cfg_t stcGpioCfg; stc_gpio_cfg_t stcGpioCfg;
stc_uart_cfg_t stcCfg; stc_uart_cfg_t stcCfg;
@@ -116,7 +116,7 @@ static void Uart0Init(void)
stcCfg.enMmdorCk = UartMskEven; ///<偶校验 stcCfg.enMmdorCk = UartMskEven; ///<偶校验
stcCfg.stcBaud.u32Pclk = Sysctrl_GetPClkFreq(); ///<PCLK获取 stcCfg.stcBaud.u32Pclk = Sysctrl_GetPClkFreq(); ///<PCLK获取
stcCfg.stcBaud.enClkDiv = UartMsk8Or16Div; ///<采样分频 stcCfg.stcBaud.enClkDiv = UartMsk8Or16Div; ///<采样分频
stcCfg.stcBaud.u32Baud = 500000; ///<波特率 stcCfg.stcBaud.u32Baud = Baud; ///<波特率
stcCfg.enRunMode = UartMskMode1; ///<工作模式 stcCfg.enRunMode = UartMskMode1; ///<工作模式
Uart_Init(M0P_UART0, &stcCfg); Uart_Init(M0P_UART0, &stcCfg);
@@ -166,7 +166,7 @@ static void Uart1Init(void)
Uart_EnableIrq(M0P_UART1, UartRxIrq); ///<使能接收中断 Uart_EnableIrq(M0P_UART1, UartRxIrq); ///<使能接收中断
EnableNvic(UART1_3_IRQn, IrqLevel3, TRUE); ///<系统中断使能 EnableNvic(UART1_3_IRQn, IrqLevel3, TRUE); ///<系统中断使能
} }
static void LpUart0Init(void) void LpUart0Init(uint32_t Baud)
{ {
stc_gpio_cfg_t stcGpioCfg; stc_gpio_cfg_t stcGpioCfg;
stc_lpuart_cfg_t stcCfg; stc_lpuart_cfg_t stcCfg;
@@ -193,7 +193,7 @@ static void LpUart0Init(void)
stcCfg.stcBaud.enSclkSel = LPUartMskRcl; ///<传输时钟源 stcCfg.stcBaud.enSclkSel = LPUartMskRcl; ///<传输时钟源
stcCfg.stcBaud.u32Sclk = 38400; ///<PCLK获取 stcCfg.stcBaud.u32Sclk = 38400; ///<PCLK获取
stcCfg.stcBaud.enSclkDiv = LPUartMsk4Or8Div; ///<采样分频 stcCfg.stcBaud.enSclkDiv = LPUartMsk4Or8Div; ///<采样分频
stcCfg.stcBaud.u32Baud = 9600; ///<波特率 stcCfg.stcBaud.u32Baud = Baud; ///<波特率
stcCfg.enRunMode = LPUartMskMode1; ///<工作模式 stcCfg.enRunMode = LPUartMskMode1; ///<工作模式
LPUart_Init(M0P_LPUART0, &stcCfg); LPUart_Init(M0P_LPUART0, &stcCfg);
@@ -703,9 +703,22 @@ void PrintfMess(void)
} }
void DBGUartSendByte(uint8_t sData) void DBGUartSendByte(uint8_t sData)
{ {
#if USE_BOOTLOADER
LPUart_SendData(M0P_LPUART0, sData);
#else
Uart_SendDataPoll(M0P_UART0, sData); Uart_SendDataPoll(M0P_UART0, sData);
#endif
}
void DBGUartSend(uint8_t *sData, int sLen)
{
#if USE_BOOTLOADER
LPUart0SendArray(sData, sLen);
#else
for(int i = 0; i < sLen; i++) {
Uart_SendDataPoll(M0P_UART0, sData[i]);
}
#endif
} }
void LPUart0SendArray(uint8_t *sData, uint8_t sLen) void LPUart0SendArray(uint8_t *sData, uint8_t sLen)
{ {
RS485_CTRL_TX(); RS485_CTRL_TX();
@@ -783,6 +796,7 @@ void LpUart0_IRQHandler(void)
LPUart_ClrStatus(M0P_LPUART0, LPUartRC); ///<清接收中断请求 LPUart_ClrStatus(M0P_LPUART0, LPUartRC); ///<清接收中断请求
uint8_t u8RxData = LPUart_ReceiveData(M0P_LPUART0); ///读取数据 uint8_t u8RxData = LPUart_ReceiveData(M0P_LPUART0); ///读取数据
LPUartRx_CallBack(u8RxData); LPUartRx_CallBack(u8RxData);
DebugUartIRQ(u8RxData);
} }
} }
@@ -791,7 +805,7 @@ void Uart0_IRQHandler(void)
if(Uart_GetStatus(M0P_UART0, UartRC)) { ///接收数据 if(Uart_GetStatus(M0P_UART0, UartRC)) { ///接收数据
Uart_ClrStatus(M0P_UART0, UartRC); ///<清接收中断请求 Uart_ClrStatus(M0P_UART0, UartRC); ///<清接收中断请求
uint8_t u8RxData = Uart_ReceiveData(M0P_UART0); ///读取数据 uint8_t u8RxData = Uart_ReceiveData(M0P_UART0); ///读取数据
DebugUartIRQ(u8RxData); //DebugUartIRQ(u8RxData);
} }
} }
@@ -876,7 +890,7 @@ void WakeUpInit(void)
AdcInit(); AdcInit();
#endif #endif
#if (USE_UART0 == 1) #if (USE_UART0 == 1)
Uart0Init(); Uart0Init(500000);
#endif #endif
#if (USE_SPI0 == 1) #if (USE_SPI0 == 1)
SPI0Init(); SPI0Init();
@@ -908,7 +922,7 @@ void BspInit(void)
AdcInit(); AdcInit();
#endif #endif
#if (USE_UART0 == 1)//< DEBUG #if (USE_UART0 == 1)//< DEBUG
Uart0Init(); Uart0Init(500000);
#endif #endif
#if (USE_RTC == 1)//< RTC #if (USE_RTC == 1)//< RTC
RTCInit(30); RTCInit(30);
@@ -923,7 +937,7 @@ void BspInit(void)
SPI1Init(); SPI1Init();
#endif #endif
#if (USE_LPUART0 == 1)//< LPUART0 #if (USE_LPUART0 == 1)//< LPUART0
LpUart0Init(); LpUart0Init(9600);
#endif #endif
#if(USE_I2C0 == 1) #if(USE_I2C0 == 1)
I2C0Init(); I2C0Init();
+175 -115
View File
File diff suppressed because one or more lines are too long