update
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,835 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
|
||||
|
||||
<SchemaVersion>1.0</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Extensions>
|
||||
<cExt>*.c</cExt>
|
||||
<aExt>*.s*; *.src; *.a*</aExt>
|
||||
<oExt>*.obj; *.o</oExt>
|
||||
<lExt>*.lib</lExt>
|
||||
<tExt>*.txt; *.h; *.inc; *.md</tExt>
|
||||
<pExt>*.plm</pExt>
|
||||
<CppX>*.cpp; *.cc; *.cxx</CppX>
|
||||
<nMigrate>0</nMigrate>
|
||||
</Extensions>
|
||||
|
||||
<DaveTm>
|
||||
<dwLowDateTime>0</dwLowDateTime>
|
||||
<dwHighDateTime>0</dwHighDateTime>
|
||||
</DaveTm>
|
||||
|
||||
<Target>
|
||||
<TargetName>leakage_system</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></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>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>0</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>0</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
<sDlgPa></sDlgPa>
|
||||
<sIfile></sIfile>
|
||||
<tDll></tDll>
|
||||
<tDllPa></tDllPa>
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile></tIfile>
|
||||
<pMon>BIN\UL2CM3.DLL</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM))</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
</Tracepoint>
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>0</periodic>
|
||||
<aLwin>0</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>0</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>1</EnableFlashSeq>
|
||||
<EnableLog>0</EnableLog>
|
||||
<Protocol>2</Protocol>
|
||||
<DbgClock>10000000</DbgClock>
|
||||
</DebugDescription>
|
||||
</TargetOption>
|
||||
</Target>
|
||||
|
||||
<Group>
|
||||
<GroupName>Application/MDK-ARM</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>1</FileNumber>
|
||||
<FileType>2</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>startup_stm32f407xx.s</PathWithFileName>
|
||||
<FilenameWithoutPath>startup_stm32f407xx.s</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Application/User/Core</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>2</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/main.c</PathWithFileName>
|
||||
<FilenameWithoutPath>main.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>3</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/gpio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gpio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/dma.c</PathWithFileName>
|
||||
<FilenameWithoutPath>dma.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/spi.c</PathWithFileName>
|
||||
<FilenameWithoutPath>spi.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/usart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>usart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/stm32f4xx_it.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_it.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/stm32f4xx_hal_msp.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_msp.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Drivers/STM32F4xx_HAL_Driver</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_spi.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_rcc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_rcc_ex.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_flash.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_flash_ex.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_flash_ramfunc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_gpio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_dma_ex.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_dma.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_pwr.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_pwr_ex.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_cortex.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_exti.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_tim.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_tim_ex.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>stm32f4xx_hal_uart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Drivers/CMSIS</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/system_stm32f4xx.c</PathWithFileName>
|
||||
<FilenameWithoutPath>system_stm32f4xx.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>app</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\app\usr_config.h</PathWithFileName>
|
||||
<FilenameWithoutPath>usr_config.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\app\app.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\app\gas_data.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gas_data.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\app\app_timer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_timer.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\app\app_leakage.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_leakage.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\app\app_com.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_com.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>algo</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\algo\algo_queue.c</PathWithFileName>
|
||||
<FilenameWithoutPath>algo_queue.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>bsp</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_Delay.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_Delay.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_Led.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_Led.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_Wdg.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_Wdg.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_Flash.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_Flash.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_uart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_w25q.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_w25q.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_DS1302.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_DS1302.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_W5500.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_W5500.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_buzzer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_buzzer.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\bsp\bsp_relay.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bsp_relay.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>gui</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\gui\gui_tjc_hmi.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gui_tjc_hmi.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>protocol</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\protocol\proto_modbus_lib.c</PathWithFileName>
|
||||
<FilenameWithoutPath>proto_modbus_lib.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>46</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\protocol\proto_print.c</PathWithFileName>
|
||||
<FilenameWithoutPath>proto_print.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>47</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\protocol\proto_modbus_slave_ex.c</PathWithFileName>
|
||||
<FilenameWithoutPath>proto_modbus_slave_ex.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>48</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\usr\protocol\proto_modbus_master_leakage.c</PathWithFileName>
|
||||
<FilenameWithoutPath>proto_modbus_master_leakage.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>1</RteFlg>
|
||||
</Group>
|
||||
|
||||
</ProjectOpt>
|
||||
@@ -755,16 +755,16 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\usr\protocol\proto_print.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>proto_modbus_slave_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\usr\protocol\proto_modbus_slave_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>proto_modbus_master_leakage.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\usr\protocol\proto_modbus_master_leakage.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>proto_modbus_tcp_slave_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\usr\protocol\proto_modbus_tcp_slave_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,7 @@
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x400
|
||||
Stack_Size EQU 0x800
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
@@ -40,7 +40,7 @@ __initial_sp
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x200
|
||||
Heap_Size EQU 0x400
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
#include "proto_modbus_master_leakage.h"
|
||||
#include "proto_modbus_slave_ex.h"
|
||||
#include "proto_modbus_tcp_slave_ex.h"
|
||||
|
||||
#include "gui_tjc_hmi.h"
|
||||
|
||||
@@ -58,7 +58,7 @@ app_timer_class_t app_timer_task[] =
|
||||
void app_init(void)
|
||||
{
|
||||
/*flash*/
|
||||
Usr_Flash.Init();
|
||||
w25q32.init();
|
||||
|
||||
/*<2A><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>*/
|
||||
com_uart1.init(&com_uart1);
|
||||
@@ -82,12 +82,17 @@ void app_init(void)
|
||||
modbus_leakage[APP_COM3].init(&modbus_leakage[APP_COM3]);
|
||||
modbus_leakage[APP_COM4].init(&modbus_leakage[APP_COM4]);
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD>ͨѶ*/
|
||||
/*<2A><><EFBFBD><EFBFBD>*/
|
||||
DS1302.Init();
|
||||
relay.init();
|
||||
buzzer.init();
|
||||
led.init();
|
||||
|
||||
leakage.init();
|
||||
/*com<6F>ڰ<EFBFBD><DAB0><EFBFBD>*/
|
||||
app_com.init();
|
||||
history.init_history();
|
||||
|
||||
/*<2A><>ʱ<EFBFBD><CAB1><EFBFBD>ã<EFBFBD>ʱ<EFBFBD><CAB1>Ƭ<EFBFBD><C6AC>ѯ*/
|
||||
app_timer.init(APP_TIMER_TASK_NUM,app_timer_task);
|
||||
|
||||
@@ -115,6 +120,7 @@ void task_idle(void)
|
||||
com_uart3.rx_task(&com_uart3);
|
||||
com_uart4.rx_task(&com_uart4);
|
||||
com_uart6.rx_task(&com_uart6);
|
||||
W5500.Task();
|
||||
}
|
||||
|
||||
void task_10ms(void)
|
||||
@@ -139,7 +145,10 @@ void task_200ms(void)
|
||||
void task_500ms(void)
|
||||
{
|
||||
led.task();
|
||||
//tdlas.tx_task();
|
||||
modbus_leakage[APP_COM1].tx_task(&modbus_leakage[APP_COM1]);
|
||||
modbus_leakage[APP_COM2].tx_task(&modbus_leakage[APP_COM2]);
|
||||
modbus_leakage[APP_COM3].tx_task(&modbus_leakage[APP_COM3]);
|
||||
// modbus_leakage[APP_COM4].tx_task(&modbus_leakage[APP_COM4]);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +156,6 @@ void task_1s(void)
|
||||
{
|
||||
leakage.task();
|
||||
DS1302.Task();
|
||||
|
||||
buzzer.task();
|
||||
relay.task();
|
||||
}
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
#include "app_alarm.h"
|
||||
#include "app_leakage.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "bsp_w25q.h"
|
||||
#include "bsp_buzzer.h"
|
||||
#include "bsp_relay.h"
|
||||
|
||||
static void history_clear_all(void);
|
||||
static u8 history_read_record(u32 record_index, app_leakage_history_alarm_t *record);
|
||||
static void history_init(void);
|
||||
static void history_save_metadata(void);
|
||||
|
||||
app_leakage_t leakage =
|
||||
{
|
||||
.region_num = 0,
|
||||
.sub_device_num = 0,
|
||||
.init = NULL,
|
||||
.task = app_leakage_task
|
||||
};
|
||||
app_leakage_t *p_leakage = &leakage;
|
||||
|
||||
app_hitory_t history =
|
||||
{
|
||||
.read_history = history_read_record,
|
||||
@@ -24,91 +17,75 @@ app_hitory_t history =
|
||||
.init_history = history_init
|
||||
};
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>࣬<EFBFBD><EFBFBD>ͬһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>һ<EFBFBD><EFBFBD>*/
|
||||
void app_leakage_region_classify(void)
|
||||
/*<2A><><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <20><> <20>̵<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
static void app_leakage_alarm_contorl(void)
|
||||
{
|
||||
u16 i,j;
|
||||
u8 add_region_flag;
|
||||
if(0 != leakage.alarm_state)
|
||||
{
|
||||
buzzer.set.on();
|
||||
relay.set(BSP_RELAY_CH_ERROR_STATE,USR_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
buzzer.set.off();
|
||||
relay.set(BSP_RELAY_CH_ERROR_STATE,USR_OFF);
|
||||
}
|
||||
|
||||
/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
p_leakage->region_num = 0;
|
||||
p_leakage->sub_device_num = 0;
|
||||
memset(p_leakage->region_data,0,sizeof(p_leakage->region_data));
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ*/
|
||||
for(i=0;i<APP_LEAKAGE_SUB_DEVICE_NUM;i++)
|
||||
/*©Һ״̬*/
|
||||
if(leakage.alarm_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
add_region_flag = 1; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
/*<2A>豸ʹ<E8B1B8><CAB9>*/
|
||||
if(ENABLE == p_leakage->sub_device_data[i].flash_data.state)
|
||||
relay.set(BSP_RELAY_CH_LEAKAGE,USR_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_leakage->sub_device_num++;/*<2A><>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>++*/
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
for(j=0;j<APP_LEAKAGE_SUB_DEVICE_NUM;j++)
|
||||
relay.set(BSP_RELAY_CH_LEAKAGE,USR_OFF);
|
||||
}
|
||||
/*<2A>ϴ<EFBFBD>״̬*/
|
||||
if(leakage.alarm_state & APP_LEAKAGE_SUB_DEVICE_STATE_OPEN)
|
||||
{
|
||||
if(0 == memcmp(p_leakage->region_data[j].name,p_leakage->sub_device_data[i].flash_data.region_name, APP_LEAKAGE_STRING_NANE_LEN))/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ*/
|
||||
relay.set(BSP_RELAY_CH_OPEN,USR_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸*/
|
||||
p_leakage->region_data[j].sub_device_index[p_leakage->region_data[j].leakage_num] = i;/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>*/
|
||||
p_leakage->region_data[j].sub_device_num++; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>++*/
|
||||
add_region_flag = 0;/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
break;
|
||||
relay.set(BSP_RELAY_CH_OPEN,USR_OFF);
|
||||
}
|
||||
/*ͨѶ<CDA8><D1B6>ʱ*/
|
||||
if(leakage.alarm_state & APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
relay.set(BSP_RELAY_CH_COMMINCAION,USR_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
relay.set(BSP_RELAY_CH_COMMINCAION,USR_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
/*û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>*/
|
||||
if(add_region_flag)/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
{
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
memcpy(p_leakage->region_data[p_leakage->region_num].name,p_leakage->sub_device_data[i].flash_data.region_name, APP_LEAKAGE_STRING_NANE_LEN);
|
||||
p_leakage->region_data[p_leakage->region_num].sub_device_index[p_leakage->region_data[p_leakage->region_num].leakage_num] = i;/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>*/
|
||||
p_leakage->region_data[p_leakage->region_num].sub_device_num++; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>++*/
|
||||
p_leakage->region_num++; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>++*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*<2A>쳣״̬<D7B4>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>*/
|
||||
void app_leakage_task(void)
|
||||
{
|
||||
static u16 prev_ch_state[APP_LEAKAGE_SUB_DEVICE_NUM][APP_LEAKAGE_SUB_DEVICE_CH_NUM] = {0};
|
||||
u16 i, j, k, sub_device_index;
|
||||
static u8 initialized = 0;
|
||||
|
||||
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʷģ<CAB7><C4A3> */
|
||||
if(!initialized)
|
||||
{
|
||||
history.init_history();
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣ͳ<ECB3A3><CDB3> */
|
||||
for(i = 0; i < p_leakage->region_num; i++)
|
||||
{
|
||||
p_leakage->region_data[i].leakage_num = 0;
|
||||
p_leakage->region_data[i].open_num = 0;
|
||||
p_leakage->region_data[i].time_out_num = 0;
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>״̬<D7B4>仯<EFBFBD><E4BBAF>ͳ<EFBFBD><CDB3><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD> */
|
||||
for(i = 0; i < p_leakage->region_num; i++)
|
||||
for(i = 0; i < leakage.region_num; i++)
|
||||
{
|
||||
for(j = 0; j < p_leakage->region_data[i].sub_device_num; j++)
|
||||
for(j = 0; j < leakage.region_data[i].sub_device_num; j++)
|
||||
{
|
||||
sub_device_index = p_leakage->region_data[i].sub_device_index[j];
|
||||
sub_device_index = leakage.region_data[i].sub_device_index[j];
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if(p_leakage->sub_device_data[sub_device_index].flash_data.state != ENABLE)
|
||||
if(leakage.sub_device_data[sub_device_index].flash_data.state != ENABLE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/*<2A><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD>洢*/
|
||||
for(k = 0; k < APP_LEAKAGE_SUB_DEVICE_CH_NUM; k++)
|
||||
{
|
||||
u16 current_state = p_leakage->sub_device_data[sub_device_index].ch_data[k].state;
|
||||
u16 current_state = leakage.sub_device_data[sub_device_index].ch_data[k].state;
|
||||
u16 prev_state = prev_ch_state[sub_device_index][k];
|
||||
u16 leak_distance = p_leakage->sub_device_data[sub_device_index].ch_data[k].distance;
|
||||
u16 leak_distance = leakage.sub_device_data[sub_device_index].ch_data[k].distance;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>״̬<D7B4>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD> */
|
||||
if((current_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE) &&
|
||||
@@ -136,28 +113,10 @@ void app_leakage_task(void)
|
||||
prev_ch_state[sub_device_index][k] = current_state;
|
||||
}
|
||||
|
||||
/* ͳ<><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD> - <20><><EFBFBD>豸ͳ<E8B1B8><CDB3> */
|
||||
|
||||
for(k = 0; k < APP_LEAKAGE_SUB_DEVICE_CH_NUM; k++)
|
||||
{
|
||||
u16 current_state = p_leakage->sub_device_data[sub_device_index].ch_data[k].state;
|
||||
|
||||
if(current_state & APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
p_leakage->region_data[i].time_out_num++;
|
||||
continue; /* ͨѶ<CDA8><D1B6>ʱ<EFBFBD><CAB1><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD><EFBFBD>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣 */
|
||||
}
|
||||
if(current_state & APP_LEAKAGE_SUB_DEVICE_STATE_OPEN)
|
||||
{
|
||||
p_leakage->region_data[i].open_num++;
|
||||
}
|
||||
if(current_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
p_leakage->region_data[i].leakage_num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ⱨ<EFBFBD><E2B1A8>*/
|
||||
app_leakage_alarm_contorl();
|
||||
}
|
||||
|
||||
/* <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1> */
|
||||
|
||||
@@ -2,57 +2,7 @@
|
||||
#define _APP_ALARM_H_
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#define ENABLE (1)
|
||||
#define DISABLE (0)
|
||||
|
||||
#define APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE (0x0001) /*©Һ״̬*/
|
||||
#define APP_LEAKAGE_SUB_DEVICE_STATE_OPEN (0x0002) /*<2A>ϴ<EFBFBD>״̬*/
|
||||
#define APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT (0xf000) /*ͨѶ<CDA8><D1B6>ʱ*/
|
||||
|
||||
#define APP_LEAKAGE_STRING_NANE_LEN (10)
|
||||
#define APP_LEAKAGE_SUB_DEVICE_NUM (32)
|
||||
#define APP_LEAKAGE_SUB_DEVICE_CH_NUM (4)
|
||||
|
||||
void app_leakage_task(void);
|
||||
void app_leakage_region_classify(void);
|
||||
void history_add_alarm_record(u8 region_idx, u8 device_idx, u8 channel, u16 alarm_type, u16 leak_distance);
|
||||
|
||||
|
||||
/*<2A><><EFBFBD>豸<EFBFBD>洢<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>*/
|
||||
typedef struct
|
||||
{
|
||||
u8 state; /*״̬ ʹ<><CAB9> <20><>ʹ<EFBFBD><CAB9>*/
|
||||
u8 com_port; /*<2A>˿<EFBFBD>*/
|
||||
u8 modbus_id; /*modbus id*/
|
||||
u8 device_name[APP_LEAKAGE_STRING_NANE_LEN]; /*<2A>豸<EFBFBD><E8B1B8>*/
|
||||
u8 region_name[APP_LEAKAGE_STRING_NANE_LEN]; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
}app_leakage_sub_device_flash_data_t;
|
||||
|
||||
/*<2A><><EFBFBD>豸<EFBFBD><E8B1B8>Ϣ*/
|
||||
typedef struct
|
||||
{
|
||||
app_leakage_sub_device_flash_data_t flash_data; /*flash<73>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD>*/
|
||||
struct
|
||||
{
|
||||
u16 state; /*״̬*/
|
||||
u16 distance; /*©Һ<C2A9><D2BA><EFBFBD><EFBFBD>*/
|
||||
}ch_data[APP_LEAKAGE_SUB_DEVICE_CH_NUM]; /*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
u8 heartbeat; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-59ѭ<39><D1AD>*/
|
||||
u8 test_mode; /*<2A><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>0=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1-4=<3D><><EFBFBD>Զ<EFBFBD>Ӧͨ<D3A6><CDA8>*/
|
||||
}app_leakage_sub_device_class_t;
|
||||
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ*/
|
||||
typedef struct
|
||||
{
|
||||
u8 leakage_num; /*©Һ<C2A9><D2BA><EFBFBD><EFBFBD>*/
|
||||
u8 open_num; /*<2A>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
u8 time_out_num; /*ͨѶ<CDA8><D1B6>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>*/
|
||||
u8 sub_device_num; /*<2A>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
u8 name[APP_LEAKAGE_STRING_NANE_LEN]; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
u8 sub_device_index[APP_LEAKAGE_SUB_DEVICE_NUM]; /*<2A>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
}app_leakage_region_data_class_t;
|
||||
#include "app_leakage.h"
|
||||
|
||||
/* <20><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ṹ */
|
||||
typedef struct
|
||||
@@ -75,18 +25,6 @@ typedef struct
|
||||
u32 max_records; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC> */
|
||||
} app_leakage_history_metadata_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 region_num;
|
||||
u8 sub_device_num;
|
||||
app_leakage_region_data_class_t region_data[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
app_leakage_sub_device_class_t sub_device_data[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
|
||||
app_leakage_history_metadata_t history_metadata;
|
||||
|
||||
void (*init)(void); /*<2A><>ʼ<EFBFBD><CABC>*/
|
||||
void (*task)(void); /*ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
}app_leakage_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -8,34 +8,33 @@ bsp_uart_t *com_to_uart[APP_COM_NUM] =
|
||||
&com_uart4,
|
||||
&com_uart2,
|
||||
&com_uart3,
|
||||
&com_uart1,
|
||||
&com_uart6,
|
||||
};
|
||||
|
||||
static void app_com_uart_baud_rate_set(app_com_class_t * p_com,u16 baud_rate);
|
||||
static void app_com_uart_class_rate_set(app_com_class_t * p_com,u16 baud_rate);
|
||||
static void app_com_class_update(void );
|
||||
static void app_com_init(app_com_class_t * p_com);
|
||||
static void app_com_init(void);
|
||||
|
||||
app_com_t app_com=
|
||||
{
|
||||
|
||||
.init = app_com_init,
|
||||
.class_update = app_com_class_update,
|
||||
};
|
||||
|
||||
static void app_com_init(app_com_class_t * p_com)
|
||||
static void app_com_init(void)
|
||||
{
|
||||
if(p_com == &app_com.com[APP_COM1])
|
||||
p_com->com_uart = com_to_uart[APP_COM1];
|
||||
else if(p_com == &app_com.com[APP_COM2])
|
||||
p_com->com_uart = com_to_uart[APP_COM2];
|
||||
else if(p_com == &app_com.com[APP_COM3])
|
||||
p_com->com_uart = com_to_uart[APP_COM3];
|
||||
else if(p_com == &app_com.com[APP_COM4])
|
||||
p_com->com_uart = com_to_uart[APP_COM4];
|
||||
u8 i;
|
||||
for(i=0;i<APP_COM_NUM;i++)
|
||||
{
|
||||
app_com.com[i].com_uart = com_to_uart[i];
|
||||
}
|
||||
app_com_class_update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
static void app_com_uart_baud_rate_set(app_com_class_t * p_com,u16 baud_rate)
|
||||
static void app_com_class_baud_rate_set(app_com_class_t * p_com,u16 baud_rate)
|
||||
{
|
||||
p_com->com_uart->set.baud_rate(p_com->com_uart,baud_rate);
|
||||
}
|
||||
|
||||
@@ -28,12 +28,13 @@ struct app_com_class_t
|
||||
{
|
||||
void (*baud_rate)(app_com_class_t *,u16); /*<2A><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
}set;
|
||||
void (*init)(app_com_class_t *); /*<2A><>ʼ<EFBFBD><CABC>*/
|
||||
//void (*init)(app_com_class_t *); /*<2A><>ʼ<EFBFBD><CABC>*/
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
app_com_class_t com[APP_COM_NUM];
|
||||
void (*init)(void); /*<2A><>ʼ<EFBFBD><CABC>*/
|
||||
void (*class_update)(void ); /*com<6F><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
}app_com_t;
|
||||
|
||||
|
||||
@@ -2,18 +2,23 @@
|
||||
|
||||
#include <string.h>
|
||||
#include "bsp_w25q.h"
|
||||
#include "bsp_buzzer.h"
|
||||
#include "bsp_relay.h"
|
||||
|
||||
static void history_clear_all(void);
|
||||
static u8 history_read_record(u32 record_index, app_leakage_history_alarm_t *record);
|
||||
static void history_init(void);
|
||||
static void history_save_metadata(void);
|
||||
|
||||
static void app_leakage_init(void);
|
||||
|
||||
app_leakage_t leakage =
|
||||
{
|
||||
.region_num = 0,
|
||||
.sub_device_num = 0,
|
||||
.init = NULL,
|
||||
.task = app_leakage_task
|
||||
.init = app_leakage_init,
|
||||
.task = app_leakage_task,
|
||||
.class_update = app_leakage_region_classify,
|
||||
};
|
||||
app_leakage_t *p_leakage = &leakage;
|
||||
|
||||
@@ -24,6 +29,12 @@ app_hitory_t history =
|
||||
.init_history = history_init
|
||||
};
|
||||
|
||||
|
||||
static void app_leakage_init(void)
|
||||
{
|
||||
app_leakage_region_classify();
|
||||
}
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>࣬<EFBFBD><E0A3AC>ͬһ<CDAC><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>ֵ<EFBFBD>һ<EFBFBD><D2BB>*/
|
||||
void app_leakage_region_classify(void)
|
||||
{
|
||||
@@ -66,26 +77,60 @@ void app_leakage_region_classify(void)
|
||||
p_leakage->region_data[p_leakage->region_num].sub_device_num++; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>++*/
|
||||
p_leakage->region_num++; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>++*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD> <20><> <20><> <20>̵<EFBFBD><CCB5><EFBFBD> <20><><EFBFBD><EFBFBD>*/
|
||||
static void app_leakage_alarm_contorl(void)
|
||||
{
|
||||
if(0 != p_leakage->alarm_state)
|
||||
{
|
||||
buzzer.set.on();
|
||||
relay.set(BSP_RELAY_CH_ERROR_STATE,USR_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
buzzer.set.off();
|
||||
relay.set(BSP_RELAY_CH_ERROR_STATE,USR_OFF);
|
||||
}
|
||||
|
||||
/*©Һ״̬*/
|
||||
if(p_leakage->alarm_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
relay.set(BSP_RELAY_CH_LEAKAGE,USR_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
relay.set(BSP_RELAY_CH_LEAKAGE,USR_OFF);
|
||||
}
|
||||
/*<2A>ϴ<EFBFBD>״̬*/
|
||||
if(p_leakage->alarm_state & APP_LEAKAGE_SUB_DEVICE_STATE_OPEN)
|
||||
{
|
||||
relay.set(BSP_RELAY_CH_OPEN,USR_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
relay.set(BSP_RELAY_CH_OPEN,USR_OFF);
|
||||
}
|
||||
/*ͨѶ<CDA8><D1B6>ʱ*/
|
||||
if(p_leakage->alarm_state & APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
relay.set(BSP_RELAY_CH_COMMINCAION,USR_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
relay.set(BSP_RELAY_CH_COMMINCAION,USR_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*<2A>쳣״̬<D7B4>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>*/
|
||||
void app_leakage_task(void)
|
||||
{
|
||||
static u16 prev_ch_state[APP_LEAKAGE_SUB_DEVICE_NUM][APP_LEAKAGE_SUB_DEVICE_CH_NUM] = {0};
|
||||
u16 i, j, k, sub_device_index;
|
||||
static u8 initialized = 0;
|
||||
|
||||
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʷģ<CAB7><C4A3> */
|
||||
if(!initialized)
|
||||
{
|
||||
history.init_history();
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣ͳ<ECB3A3><CDB3> */
|
||||
for(i = 0; i < p_leakage->region_num; i++)
|
||||
@@ -94,7 +139,7 @@ void app_leakage_task(void)
|
||||
p_leakage->region_data[i].open_num = 0;
|
||||
p_leakage->region_data[i].time_out_num = 0;
|
||||
}
|
||||
|
||||
p_leakage->alarm_state = 0;
|
||||
/* <20><><EFBFBD><EFBFBD>״̬<D7B4>仯<EFBFBD><E4BBAF>ͳ<EFBFBD><CDB3><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD> */
|
||||
for(i = 0; i < p_leakage->region_num; i++)
|
||||
{
|
||||
@@ -108,6 +153,7 @@ void app_leakage_task(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*<2A><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD>洢*/
|
||||
for(k = 0; k < APP_LEAKAGE_SUB_DEVICE_CH_NUM; k++)
|
||||
{
|
||||
u16 current_state = p_leakage->sub_device_data[sub_device_index].ch_data[k].state;
|
||||
@@ -141,7 +187,6 @@ void app_leakage_task(void)
|
||||
}
|
||||
|
||||
/* ͳ<><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD> - <20><><EFBFBD>豸ͳ<E8B1B8><CDB3> */
|
||||
|
||||
for(k = 0; k < APP_LEAKAGE_SUB_DEVICE_CH_NUM; k++)
|
||||
{
|
||||
u16 current_state = p_leakage->sub_device_data[sub_device_index].ch_data[k].state;
|
||||
@@ -149,19 +194,24 @@ void app_leakage_task(void)
|
||||
if(current_state & APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT)
|
||||
{
|
||||
p_leakage->region_data[i].time_out_num++;
|
||||
continue; /* ͨѶ<CDA8><D1B6>ʱ<EFBFBD><CAB1><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD><EFBFBD>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣 */
|
||||
p_leakage->alarm_state |= APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT;
|
||||
}
|
||||
if(current_state & APP_LEAKAGE_SUB_DEVICE_STATE_OPEN)
|
||||
else if(current_state & APP_LEAKAGE_SUB_DEVICE_STATE_OPEN)
|
||||
{
|
||||
p_leakage->region_data[i].open_num++;
|
||||
p_leakage->alarm_state |= APP_LEAKAGE_SUB_DEVICE_STATE_OPEN;
|
||||
}
|
||||
if(current_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
else if(current_state & APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE)
|
||||
{
|
||||
p_leakage->region_data[i].leakage_num++;
|
||||
p_leakage->alarm_state |= APP_LEAKAGE_SUB_DEVICE_STATE_OPEN;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ⱨ<EFBFBD><E2B1A8>*/
|
||||
app_leakage_alarm_contorl();
|
||||
}
|
||||
|
||||
/* <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1> */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#define APP_LEAKAGE_SUB_DEVICE_STATE_LEAKAGE (0x0001) /*©Һ״̬*/
|
||||
#define APP_LEAKAGE_SUB_DEVICE_STATE_OPEN (0x0002) /*<2A>ϴ<EFBFBD>״̬*/
|
||||
#define APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT (0xf000) /*ͨѶ<CDA8><D1B6>ʱ*/
|
||||
#define APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT (0x8000) /*ͨѶ<CDA8><D1B6>ʱ*/
|
||||
|
||||
#define APP_LEAKAGE_STRING_NANE_LEN (10)
|
||||
#define APP_LEAKAGE_SUB_DEVICE_NUM (32)
|
||||
@@ -79,13 +79,18 @@ typedef struct
|
||||
{
|
||||
u8 region_num;
|
||||
u8 sub_device_num;
|
||||
app_leakage_region_data_class_t region_data[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
app_leakage_sub_device_class_t sub_device_data[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
u16 alarm_state; /*ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>״̬*/
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD>*/
|
||||
app_leakage_region_data_class_t region_data[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
/*<2A><><EFBFBD>豸*/
|
||||
app_leakage_sub_device_class_t sub_device_data[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
/*<2A><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>*/
|
||||
app_leakage_history_metadata_t history_metadata;
|
||||
|
||||
void (*init)(void); /*<2A><>ʼ<EFBFBD><CABC>*/
|
||||
void (*task)(void); /*ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
void (*class_update)(void);
|
||||
}app_leakage_t;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/**********************************************************************************
|
||||
* <20>ļ<EFBFBD><C4BC><EFBFBD> <20><>W5500.c
|
||||
* <20><><EFBFBD><EFBFBD> <20><>W5500 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD>汾 <20><>ST_v3.5
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ģ<EFBFBD>鿪<EFBFBD><E9BFAA><EFBFBD>Ŷ<EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD> <20><>http://nirenelec.blog.163.com
|
||||
* <20>Ա<EFBFBD> <20><>http://nirenelec.taobao.com
|
||||
**********************************************************************************/
|
||||
|
||||
//#include "stm32f1xx.h"
|
||||
//#include "stm32f1xx_hal_spi.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "bsp_W5500.h"
|
||||
#include "usart.h"
|
||||
#include "stdio.h"
|
||||
#include "spi.h"
|
||||
//#include "bsp_print.h"
|
||||
|
||||
|
||||
#define BSP_W5500_SPI_CS_LOW
|
||||
@@ -41,12 +27,10 @@ static void Write_SOCK_Data_Buffer(bsp_W5500_Class_t *pW5500_Class, u8 *dat_ptr,
|
||||
|
||||
bsp_W5500_t W5500 =
|
||||
{
|
||||
.Gateway_IP = {192,168,1,1},
|
||||
.Gateway_IP = {192,168,100,1}, /*<2A><><EFBFBD><EFBFBD>IP<49><50>ַ*/
|
||||
.Sub_Mask = {255,255,255,0}, /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
.Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x01},
|
||||
|
||||
//.IP_Addr = {169,254,107,101},
|
||||
.IP_Addr = {192,168,100,101},
|
||||
.Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x01}, /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ(MAC)*/
|
||||
.IP_Addr = {192,168,100,101}, /*<2A><><EFBFBD><EFBFBD>IP<49><50>ַ*/
|
||||
|
||||
.Interrupt_Process = bsp_W5500_Interrupt_Process,
|
||||
|
||||
@@ -57,18 +41,8 @@ bsp_W5500_t W5500 =
|
||||
.W5500_Class[0] =
|
||||
{
|
||||
.SocketPort = 0, /*ʹ<>ö˿<C3B6>0*/
|
||||
.ConfigData.Gateway_IP = {192,168,1,1},
|
||||
.ConfigData.Sub_Mask = {255,255,255,0},
|
||||
.ConfigData.Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x01},
|
||||
|
||||
.ConfigData.IP_Addr = {192,168,100,101},
|
||||
.ConfigData.Port = {0x13,0x88},
|
||||
|
||||
// .ConfigData.DIP = {192,168,1,32},
|
||||
// .ConfigData.DPort = {0x03,0x09},
|
||||
|
||||
.ConfigData.Port = {0x01,0xF6},
|
||||
.Run_Mode = BSP_W5500_PORT_RUN_MODE_TCP_SERVER,
|
||||
// .Rx_DataAnalysis = proto_HSMS_Rx_DataAnalysis,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -798,9 +772,10 @@ static void bsp_W5500_Task(void)
|
||||
// Write_SOCK_Data_Buffer(&pW5500->W5500_Class[i], pW5500->W5500_Class[i].Rx_Buffer, Len);
|
||||
// printf("RX");
|
||||
// Debug_UartSend(pW5500->W5500_Class[i].Rx_Buffer, Len);
|
||||
|
||||
if(pW5500->W5500_Class[i].Rx_DataAnalysis != NULL)
|
||||
{
|
||||
pW5500->W5500_Class[i].Rx_DataAnalysis(&pW5500->W5500_Class[i],pW5500->W5500_Class[i].Rx_Buffer,Len);/*<2A><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>*/
|
||||
pW5500->W5500_Class[i].Rx_DataAnalysis(pW5500->W5500_Class[i].Rx_Buffer,Len,&pW5500->W5500_Class[i]);/*<2A><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,11 +215,10 @@
|
||||
#define W5500_INT_PORT W5500_INT_GPIO_Port
|
||||
|
||||
typedef u8 SOCKET; // <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>˿ں<CBBF><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#define BSP_W5500_PORT_NUM 1
|
||||
#define BSP_W5500_DATA_LEN 2048
|
||||
|
||||
|
||||
#define BSP_W5500_TX_DATA_LEN 2048
|
||||
#define BSP_W5500_RX_DATA_LEN 2048
|
||||
|
||||
typedef struct bsp_W5500_Class_t bsp_W5500_Class_t;
|
||||
|
||||
@@ -229,10 +228,6 @@ struct bsp_W5500_Class_t
|
||||
struct
|
||||
{
|
||||
/***************----- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -----***************/
|
||||
u8 Gateway_IP[4]; /*<2A><><EFBFBD><EFBFBD>IP<49><50>ַ*/
|
||||
u8 Sub_Mask[4]; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
u8 Phy_Addr[6]; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ(MAC)*/
|
||||
u8 IP_Addr[4]; /*<2A><><EFBFBD><EFBFBD>IP<49><50>ַ*/
|
||||
u8 Port[2]; /*<2A>˿<EFBFBD>0<EFBFBD>Ķ˿ں<CBBF>(5000) */
|
||||
u8 DIP[4]; /*<2A>˿<EFBFBD>0Ŀ<30><C4BF>IP<49><50>ַ*/
|
||||
u8 DPort[2]; /*<2A>˿<EFBFBD>0Ŀ<30>Ķ˿ں<CBBF>(6000)*/
|
||||
@@ -247,12 +242,12 @@ struct bsp_W5500_Class_t
|
||||
/***************----- <20>˿<EFBFBD><CBBF>շ<EFBFBD><D5B7><EFBFBD><EFBFBD>ݵ<EFBFBD>״̬ -----***********/
|
||||
u8 TR_Data_State;
|
||||
/***************----- <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD> -----***************/
|
||||
u8 Rx_Buffer[BSP_W5500_DATA_LEN]; // <20>˿ڽ<CBBF><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 Tx_Buffer[BSP_W5500_DATA_LEN]; // <20>˿ڷ<CBBF><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 Rx_Buffer[BSP_W5500_RX_DATA_LEN]; // <20>˿ڽ<CBBF><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 Tx_Buffer[BSP_W5500_TX_DATA_LEN]; // <20>˿ڷ<CBBF><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
u8 Interrupt; // W5500<30>жϱ<D0B6>־(0:<3A><><EFBFBD>ж<EFBFBD>,1:<3A><><EFBFBD>ж<EFBFBD>)
|
||||
|
||||
void (*Rx_DataAnalysis)(bsp_W5500_Class_t *,u8 *,u16 );
|
||||
void (*Rx_DataAnalysis)(u8 *,u16 ,void *);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -340,20 +340,21 @@ static void bsp_uart_dma_send(bsp_uart_t *p_uart, u8 *p_data, u16 len)
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> */
|
||||
memcpy(p_uart->tx_addr, p_data, len);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD> */
|
||||
HAL_UART_Transmit_DMA(p_uart->uart, p_uart->tx_addr, len);
|
||||
|
||||
/* <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
|
||||
tick_start = HAL_GetTick();
|
||||
while(!p_uart->tx_dma_complete_flag)
|
||||
{
|
||||
tick = HAL_GetTick();
|
||||
if((tick - tick_start) > 200) /* 200ms<6D><73>ʱ */
|
||||
{
|
||||
p_uart->tx_dma_complete_flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
HAL_UART_Transmit(p_uart->uart, p_uart->tx_addr, len,50);
|
||||
// /* <20><><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD> */
|
||||
// HAL_UART_Transmit_DMA(p_uart->uart, p_uart->tx_addr, len);
|
||||
//
|
||||
// /* <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
|
||||
// tick_start = HAL_GetTick();
|
||||
// while(!p_uart->tx_dma_complete_flag)
|
||||
// {
|
||||
// tick = HAL_GetTick();
|
||||
// if((tick - tick_start) > 200) /* 200ms<6D><73>ʱ */
|
||||
// {
|
||||
// p_uart->tx_dma_complete_flag = 1;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/******************************************
|
||||
@@ -520,10 +521,10 @@ static void bsp_uart_rx_task(bsp_uart_t *p_uart)
|
||||
{
|
||||
p_uart->rx_data_analysis(rx_temp_buff, p_uart->rx_len, p_uart);
|
||||
}
|
||||
if(p_uart == &com_uart6)
|
||||
{
|
||||
p_uart->send(p_uart, rx_temp_buff, p_uart->rx_len);
|
||||
}
|
||||
// if(p_uart == &com_uart6)
|
||||
// {
|
||||
// p_uart->send(p_uart, rx_temp_buff, p_uart->rx_len);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "bsp_w25q.h"
|
||||
|
||||
#include "spi.h"
|
||||
#include "main.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "app_leakage.h"
|
||||
|
||||
/* spi flash Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD> - pb12 */
|
||||
#define W25Q32_CS_LOW() HAL_GPIO_WritePin(SPI2_CS_GPIO_Port, SPI2_CS_Pin, GPIO_PIN_RESET)
|
||||
@@ -46,10 +50,57 @@ w25q32_t w25q32 = {
|
||||
};
|
||||
|
||||
|
||||
/* <20><>W25Q32<33><32>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2>app_leakage */
|
||||
static void gui_tjc_hmi_read_device_info_from_w25q(void)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
app_leakage_sub_device_flash_data_t temp_buffer[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
|
||||
/* һ<><D2BB><EFBFBD>Զ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>Ϣ */
|
||||
w25q32.read(W25Q32_DEVICE_INFO_ADDR,
|
||||
(uint8_t*)temp_buffer,
|
||||
DEVICE_INFO_STORAGE_SIZE);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7> */
|
||||
uint8_t data_valid = 1;
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶζ<D6B6><CEB6><EFBFBD>0xFF<46><46>˵<EFBFBD><CBB5><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if(temp_buffer[i].state == 0xFF &&
|
||||
temp_buffer[i].com == 0xFF &&
|
||||
temp_buffer[i].modbus_id == 0xFF)
|
||||
{
|
||||
data_valid = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(data_valid)
|
||||
{
|
||||
/* <20><><EFBFBD>Ƶ<EFBFBD>app_leakage<67>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD> */
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
leakage.sub_device_data[i].flash_data = temp_buffer[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FlashΪ<68>գ<EFBFBD><D5A3><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>豸<EFBFBD><E8B1B8>ϢΪĬ<CEAA><C4AC>ֵ */
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
memset(&leakage.sub_device_data[i].flash_data, 0,
|
||||
sizeof(app_leakage_sub_device_flash_data_t));
|
||||
leakage.sub_device_data[i].flash_data.state = DISABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
static void w25q32_init(void) {
|
||||
W25Q32_CS_HIGH(); /* <20><>ʼʱƬѡ<C6AC><D1A1><EFBFBD><EFBFBD> */
|
||||
w25q32_wake_up(); /* <20><><EFBFBD><EFBFBD>оƬ */
|
||||
gui_tjc_hmi_read_device_info_from_w25q();
|
||||
}
|
||||
|
||||
/* <20><>ȡоƬid */
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
#include "bsp_W5500.h"
|
||||
#include "bsp_uart.h"
|
||||
#include "bsp_DS1302.h"
|
||||
#include "bsp_buzzer.h"
|
||||
|
||||
#include "app_leakage.h"
|
||||
#include "app_com.h"
|
||||
|
||||
/*<2A><><EFBFBD>ڷ<EFBFBD><DAB7>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
#define HMI_TX_BUFFER_NUM (2048)
|
||||
@@ -47,7 +49,6 @@
|
||||
|
||||
static void gui_tjc_hmi_init(void);
|
||||
static void gui_tjc_hmi_communication_data_analysis(u8 *p_data, u16 len, void *rx_uart);
|
||||
static void gui_tjc_hmi_read_device_info_from_w25q(void);
|
||||
|
||||
/*<2A><><EFBFBD>ڷ<EFBFBD><DAB7>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
static u8 hmi_tx_buffer[HMI_TX_BUFFER_NUM];
|
||||
@@ -84,13 +85,18 @@ gui_tjc_hmi_t tjc_hmi =
|
||||
gui_tjc_hmi_t *p_tjc_hmi = &tjc_hmi;
|
||||
|
||||
|
||||
static void gui_tjc_hmi_class_update(void)
|
||||
{
|
||||
leakage.class_update();
|
||||
app_com.class_update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*<2A><>ĻЭ<C4BB><D0AD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>*/
|
||||
static void gui_tjc_hmi_init(void)
|
||||
{
|
||||
com_uart1.rx_data_analysis = gui_tjc_hmi_communication_data_analysis;
|
||||
gui_tjc_hmi_read_device_info_from_w25q();
|
||||
history.init_history();
|
||||
}
|
||||
|
||||
|
||||
@@ -125,54 +131,6 @@ static void gui_tjc_hmi_save_password_to_w25q(void)
|
||||
w25q32.write(W25Q32_PASSWORD_ADDR, p_tjc_hmi->password, 4);
|
||||
}
|
||||
|
||||
/* <20><>W25Q32<33><32>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2>app_leakage */
|
||||
static void gui_tjc_hmi_read_device_info_from_w25q(void)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
app_leakage_sub_device_flash_data_t temp_buffer[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
|
||||
/* һ<><D2BB><EFBFBD>Զ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>Ϣ */
|
||||
w25q32.read(W25Q32_DEVICE_INFO_ADDR,
|
||||
(uint8_t*)temp_buffer,
|
||||
DEVICE_INFO_STORAGE_SIZE);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7> */
|
||||
uint8_t data_valid = 1;
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶζ<D6B6><CEB6><EFBFBD>0xFF<46><46>˵<EFBFBD><CBB5><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if(temp_buffer[i].state == 0xFF &&
|
||||
temp_buffer[i].com == 0xFF &&
|
||||
temp_buffer[i].modbus_id == 0xFF)
|
||||
{
|
||||
data_valid = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(data_valid)
|
||||
{
|
||||
/* <20><><EFBFBD>Ƶ<EFBFBD>app_leakage<67>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD> */
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
leakage.sub_device_data[i].flash_data = temp_buffer[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FlashΪ<68>գ<EFBFBD><D5A3><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>豸<EFBFBD><E8B1B8>ϢΪĬ<CEAA><C4AC>ֵ */
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
memset(&leakage.sub_device_data[i].flash_data, 0,
|
||||
sizeof(app_leakage_sub_device_flash_data_t));
|
||||
leakage.sub_device_data[i].flash_data.state = DISABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
app_leakage_region_classify();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2>app_leakage<67><65><EFBFBD>浽W25Q32 */
|
||||
static void gui_tjc_hmi_save_device_info_to_w25q(void)
|
||||
{
|
||||
@@ -258,12 +216,13 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
}
|
||||
|
||||
char time[20];
|
||||
sprintf(time,"20%d-%02d-%02d %02d:%02d",
|
||||
sprintf(time,"20%d-%02d-%02d %02d:%02d:%02d",
|
||||
DS1302.Time.Year,
|
||||
DS1302.Time.Month,
|
||||
DS1302.Time.Day,
|
||||
DS1302.Time.Hour,
|
||||
DS1302.Time.Minute);
|
||||
DS1302.Time.Minute,
|
||||
DS1302.Time.Second);
|
||||
len += gui_tjc_hmi_tx_text_display(0,0,(char *)&hmi_tx_buffer[len],"%s",time);
|
||||
|
||||
if(HMI_PROTO_CMD_GET == cmd)/*<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>*/
|
||||
@@ -359,10 +318,12 @@ static void gui_tjc_hmi_main_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
if(0x01 == p_data[0])
|
||||
{
|
||||
/*01<30><EFBFBD><F2BFAAB7><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
buzzer.set.enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
/*00<30>رշ<D8B1><D5B7><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
buzzer.set.disable();
|
||||
}
|
||||
}
|
||||
default:return;
|
||||
@@ -1549,7 +1510,7 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
new_device.state = ENABLE;
|
||||
leakage.sub_device_data[x].flash_data = new_device;
|
||||
gui_tjc_hmi_save_device_info_to_w25q();
|
||||
app_leakage_region_classify();
|
||||
gui_tjc_hmi_class_update();
|
||||
field_count++;
|
||||
}
|
||||
}
|
||||
@@ -1568,7 +1529,7 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
gui_tjc_hmi_save_device_info_to_w25q();
|
||||
|
||||
/*<2A><><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
app_leakage_region_classify();
|
||||
gui_tjc_hmi_class_update();
|
||||
|
||||
}
|
||||
else
|
||||
@@ -1654,7 +1615,7 @@ static void gui_tjc_hmi_device_config_send(u8 cmd,u8 opa,u8 *p_data)
|
||||
gui_tjc_hmi_save_device_info_to_w25q();
|
||||
|
||||
/*<2A><><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
app_leakage_region_classify();
|
||||
gui_tjc_hmi_class_update();
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>Ӧ*/
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#define BIG_ENDIAN (0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define LITTLE_ENDIAN (1)//С<><D0A1><EFBFBD><EFBFBD>
|
||||
|
||||
#define MODBUS_TCP_PROTO_TYPE (0x0000)
|
||||
|
||||
|
||||
typedef struct {
|
||||
u8 send_buffer[MODBUS_SENDBUF_LEN];
|
||||
u16 len;
|
||||
|
||||
@@ -114,16 +114,22 @@ static void proto_leakage_tx_curr_data_get(proto_leakage_t *p_leakage)
|
||||
|
||||
static void proto_leakage_tx_task(proto_leakage_t *p_leakage)
|
||||
{
|
||||
|
||||
u16 i;
|
||||
proto_sensor_class_t *p_sensor;
|
||||
|
||||
p_sensor = &p_leakage->sensor[p_leakage->sensor_index];
|
||||
if(0 == p_leakage->sensor_num)/*û<>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>COM<4F>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(0 == (p_sensor->comm.sensor_state_code & (0x00000001 << PROTO_LEAKAGE_STATE_CODE_TIME_OUT)))
|
||||
if(0 == (p_sensor->comm.sensor_state_code & (PROTO_LEAKAGE_STATE_CODE_TIME_OUT)))
|
||||
{
|
||||
if((++p_sensor->comm.tx_time_out_count) > 20)/*500ms<EFBFBD><EFBFBD>ѯ 10<EFBFBD><EFBFBD>ͨѶ<EFBFBD><EFBFBD>ʱ*/
|
||||
if((++p_sensor->comm.tx_time_out_count) > 10)/*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ10<EFBFBD><EFBFBD> ͨѶ<EFBFBD><EFBFBD>ʱ*/
|
||||
{
|
||||
p_sensor->comm.sensor_state_code |= (0x00000001 << PROTO_LEAKAGE_STATE_CODE_TIME_OUT);
|
||||
p_sensor->comm.sensor_state_code |= (PROTO_LEAKAGE_STATE_CODE_TIME_OUT);
|
||||
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
//memset(&gas_data[p_sensor->sensor_index],0,sizeof(gas_data_t));
|
||||
}
|
||||
@@ -131,6 +137,10 @@ static void proto_leakage_tx_task(proto_leakage_t *p_leakage)
|
||||
|
||||
switch(p_sensor->comm.state)
|
||||
{
|
||||
case PROTO_LEAKAGE_COMM_STATE_INIT:
|
||||
{
|
||||
|
||||
}break;
|
||||
case PROTO_LEAKAGE_COMM_STATE_CURR_DATA_GET:
|
||||
{
|
||||
proto_leakage_tx_curr_data_get(p_leakage);
|
||||
@@ -140,14 +150,34 @@ static void proto_leakage_tx_task(proto_leakage_t *p_leakage)
|
||||
|
||||
}break;
|
||||
}
|
||||
|
||||
/*ͨѶ<CDA8><D1B6>ʱ*/
|
||||
if(p_sensor->comm.sensor_state_code & (PROTO_LEAKAGE_STATE_CODE_TIME_OUT))
|
||||
{
|
||||
for(i=0;i<APP_LEAKAGE_SUB_DEVICE_CH_NUM;i++)
|
||||
{
|
||||
leakage.sub_device_data[p_sensor->comm.leakage_data_index].ch_data[i].state |= APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<APP_LEAKAGE_SUB_DEVICE_CH_NUM;i++)
|
||||
{
|
||||
leakage.sub_device_data[p_sensor->comm.leakage_data_index].ch_data[i].state &= (~APP_LEAKAGE_SUB_DEVICE_STATE_TIME_OUT);
|
||||
}
|
||||
}
|
||||
|
||||
p_sensor->comm.state_send_time++;
|
||||
if(p_sensor->comm.state_send_time >= 3) /*<2A><><EFBFBD><EFBFBD><EFBFBD>쳣*/
|
||||
{
|
||||
p_sensor->comm.sensor_state_code |= (0x00000001 << p_sensor->comm.sensor_state_code);/*<2A><>¼<EFBFBD>쳣״̬*/
|
||||
p_sensor->comm.sensor_state_code |= (p_sensor->comm.sensor_state_code);/*<2A><>¼<EFBFBD>쳣״̬*/
|
||||
p_sensor->comm.state_send_time = 0;
|
||||
p_sensor->comm.sensor_state_code = PROTO_LEAKAGE_COMM_STATE_DEFAULT;
|
||||
p_sensor->comm.state = PROTO_LEAKAGE_COMM_STATE_DEFAULT;
|
||||
proto_leakage_switch(p_leakage); /*<2A>л<EFBFBD><D0BB>豸*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void proto_leakage_rx_task(u8 *p_data,u16 len,void *other_data)
|
||||
@@ -209,7 +239,7 @@ static void proto_leakage_rx_task(u8 *p_data,u16 len,void *other_data)
|
||||
|
||||
|
||||
p_sensor->comm.tx_time_out_count = 0;
|
||||
p_sensor->comm.sensor_state_code &= (~(0x00000001 << PROTO_LEAKAGE_STATE_CODE_TIME_OUT));
|
||||
p_sensor->comm.sensor_state_code &= (~PROTO_LEAKAGE_STATE_CODE_TIME_OUT);
|
||||
|
||||
switch(p_sensor->comm.state)
|
||||
{
|
||||
@@ -220,7 +250,7 @@ static void proto_leakage_rx_task(u8 *p_data,u16 len,void *other_data)
|
||||
case PROTO_LEAKAGE_COMM_STATE_CURR_DATA_GET:
|
||||
{
|
||||
/*<2A><><EFBFBD>㵱ǰ<E3B5B1>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>*/
|
||||
u8 sensor_index = p_leakage->sensor_index;
|
||||
u8 sensor_index = p_sensor->comm.leakage_data_index;
|
||||
u16 ch_addr_offset[4] = {0,4,8,11}; /*©Һ<C2A9><D2BA><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַƫ<D6B7><C6AB>*/
|
||||
u16 temp;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#define PROTO_LEAKAGE_COMM_STATE_DEFAULT PROTO_LEAKAGE_COMM_STATE_CURR_DATA_GET
|
||||
|
||||
#define PROTO_LEAKAGE_STATE_CODE_TIME_OUT (30U) /*ͨѶ<CDA8><D1B6>ʱ*/
|
||||
#define PROTO_LEAKAGE_STATE_CODE_TIME_OUT (0x8000) /*ͨѶ<CDA8><D1B6>ʱ*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -1,326 +0,0 @@
|
||||
/*<2A><><EFBFBD><EFBFBD>ͨѶ modbus<75>ӻ<EFBFBD>*/
|
||||
#include "proto_modbus_slave_ex.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "app_timer.h"
|
||||
#include "bsp_relay.h"
|
||||
#include "bsp_Uart.h"
|
||||
#include "bsp_Flash.h"
|
||||
|
||||
#include "proto_print.h"
|
||||
#include "proto_modbus_master_leakage.h"
|
||||
|
||||
static modbus_analysis_data_t modbus_analysis_data;//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
||||
static modbus_communication_send_buf_t send_struct;//<2F><><EFBFBD>ͽṹ<CDBD><E1B9B9>
|
||||
|
||||
static void proto_modbus_communication_data_analysis(u8 *pData, u16 len, void *data);
|
||||
static void proto_modbus_communication_data_send(u8 *pData, u16 len);
|
||||
static void proto_modbus_init(void);
|
||||
static void proto_modbus_task(void);
|
||||
static modbus_error_code_e proto_modbus_data_write(u16 Addr, u16 Value);
|
||||
static u16 proto_modbus_data_read(u16 Addr);
|
||||
|
||||
proto_Modbus_t modbus_slave_ex=
|
||||
{
|
||||
.id = 0x01,
|
||||
.data_read = proto_modbus_data_read,
|
||||
.data_write = proto_modbus_data_write,
|
||||
.data_analysis = proto_modbus_communication_data_analysis,
|
||||
.init = proto_modbus_init,
|
||||
.task = proto_modbus_task,
|
||||
};
|
||||
|
||||
static proto_Modbus_t *p_modbus = &modbus_slave_ex;
|
||||
static bsp_uart_t * p_rx_uart;
|
||||
|
||||
static void proto_modbus_communication_data_send(u8 *p_data, u16 len)
|
||||
{
|
||||
if(p_rx_uart != NULL)
|
||||
{
|
||||
p_rx_uart->send(p_rx_uart,p_data,len);
|
||||
}
|
||||
}
|
||||
|
||||
static void proto_modbus_init(void)
|
||||
{
|
||||
p_modbus->id = Usr_Flash.FlashData.modbus_id;
|
||||
com_uart1.rx_data_analysis = proto_modbus_communication_data_analysis;
|
||||
com_uart4.rx_data_analysis = proto_modbus_communication_data_analysis;
|
||||
}
|
||||
static void proto_modbus_task(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void proto_modbus_communication_data_analysis(u8 *pData, u16 len,void *other_data)
|
||||
{
|
||||
modbus_error_code_e error_code;
|
||||
u16 inx;
|
||||
u16 TempAddr, TempData, crc_16;
|
||||
|
||||
|
||||
if (0 == modbus_lib_analysis(&modbus_analysis_data, pData, len))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> У<><D0A3><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ
|
||||
return;
|
||||
if (p_modbus->id != modbus_analysis_data.id && modbus_analysis_data.id != 0xe8)//<2F>ж<EFBFBD>ID<49>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ
|
||||
return;
|
||||
|
||||
error_code = ModbusErrorCode_Success;
|
||||
|
||||
|
||||
/* //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>Ƿ<C7B7><F1B3ACB3><EFBFBD>Χ
|
||||
if ((modbus_analysis_data.start_addr >= MODBUS_REG_LEN) || (modbus_analysis_data.reg_number >= MODBUS_REG_LEN) ||
|
||||
(modbus_analysis_data.start_addr + modbus_analysis_data.reg_number >= MODBUS_REG_LEN))
|
||||
{
|
||||
ErrorCode = ModbusErrorCode_IllegalAddr;
|
||||
goto Error;
|
||||
}
|
||||
*/
|
||||
p_rx_uart = (bsp_uart_t*)other_data;
|
||||
switch (modbus_analysis_data.func)
|
||||
{
|
||||
case 0x03:
|
||||
case 0x04:
|
||||
{
|
||||
TempAddr = modbus_analysis_data.start_addr;
|
||||
send_struct.send_buffer[0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[1] = modbus_analysis_data.func;
|
||||
send_struct.send_buffer[2] = 2 * modbus_analysis_data.reg_number;
|
||||
for (inx = 0; inx < modbus_analysis_data.reg_number; inx++)
|
||||
{
|
||||
TempData = proto_modbus_data_read(TempAddr);
|
||||
send_struct.send_buffer[3 + 2 * inx] = (TempData >> 8) & 0xff;
|
||||
send_struct.send_buffer[4 + 2 * inx] = TempData & 0xff;
|
||||
TempAddr++;
|
||||
}
|
||||
crc_16 = modbus_lib_crc16(send_struct.send_buffer, 3 + send_struct.send_buffer[2]);
|
||||
send_struct.send_buffer[3 + send_struct.send_buffer[2]] = crc_16 & 0xff;
|
||||
send_struct.send_buffer[4 + send_struct.send_buffer[2]] = (crc_16 >> 8) & 0xff;
|
||||
send_struct.len = 5 + send_struct.send_buffer[2];
|
||||
}goto Success;
|
||||
/*<2A><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD>*/
|
||||
case 0x41:
|
||||
{
|
||||
TempAddr = modbus_analysis_data.start_addr;
|
||||
send_struct.send_buffer[0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[1] = modbus_analysis_data.func;
|
||||
send_struct.send_buffer[2] = modbus_analysis_data.start_addr >> 8;
|
||||
send_struct.send_buffer[3] = modbus_analysis_data.start_addr & 0xff;
|
||||
send_struct.send_buffer[4] = (2 * modbus_analysis_data.reg_number) >> 8;
|
||||
send_struct.send_buffer[5] = (2 * modbus_analysis_data.reg_number) & 0xff;
|
||||
for (inx = 0; inx < modbus_analysis_data.reg_number; inx++)
|
||||
{
|
||||
TempData = proto_modbus_data_read(TempAddr);
|
||||
send_struct.send_buffer[6 + 2 * inx] = (TempData >> 8) & 0xff;
|
||||
send_struct.send_buffer[7 + 2 * inx] = TempData & 0xff;
|
||||
TempAddr++;
|
||||
}
|
||||
crc_16 = modbus_lib_crc16(send_struct.send_buffer, 6 + 2 * modbus_analysis_data.reg_number);
|
||||
send_struct.send_buffer[6 + 2 * modbus_analysis_data.reg_number] = crc_16 & 0xff;
|
||||
send_struct.send_buffer[7 + 2 * modbus_analysis_data.reg_number] = (crc_16 >> 8) & 0xff;
|
||||
send_struct.len = 8 + 2 * modbus_analysis_data.reg_number;
|
||||
}goto Success;
|
||||
|
||||
case 0x06:
|
||||
{
|
||||
TempAddr = modbus_analysis_data.start_addr;
|
||||
TempData = (modbus_analysis_data.write_data_addr[0] << 8) | modbus_analysis_data.write_data_addr[1];
|
||||
error_code = proto_modbus_data_write(TempAddr, TempData);
|
||||
if (error_code)
|
||||
{
|
||||
goto Error;
|
||||
}
|
||||
|
||||
send_struct.len = 8;
|
||||
send_struct.send_buffer[0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[1] = modbus_analysis_data.func;
|
||||
send_struct.send_buffer[2] = modbus_analysis_data.start_addr >> 8;
|
||||
send_struct.send_buffer[3] = modbus_analysis_data.start_addr & 0xff;
|
||||
send_struct.send_buffer[4] = modbus_analysis_data.write_data_addr[0];
|
||||
send_struct.send_buffer[5] = modbus_analysis_data.write_data_addr[1];
|
||||
crc_16 = modbus_lib_crc16(send_struct.send_buffer, 6);
|
||||
send_struct.send_buffer[6] = crc_16 & 0xff;
|
||||
send_struct.send_buffer[7] = (crc_16 >> 8) & 0xff;
|
||||
}break;
|
||||
|
||||
case 0x10:
|
||||
{
|
||||
TempAddr = modbus_analysis_data.start_addr;
|
||||
for (inx = 0; inx < modbus_analysis_data.reg_number; inx++)
|
||||
{
|
||||
TempData = modbus_analysis_data.write_data_addr[2 * inx];
|
||||
TempData = (TempData << 8) | modbus_analysis_data.write_data_addr[2 * inx + 1];
|
||||
error_code = proto_modbus_data_write(TempAddr, TempData);
|
||||
TempAddr++;
|
||||
if (error_code)
|
||||
{
|
||||
goto Error;
|
||||
}
|
||||
}
|
||||
send_struct.len = 8;
|
||||
send_struct.send_buffer[0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[1] = modbus_analysis_data.func;
|
||||
send_struct.send_buffer[2] = modbus_analysis_data.start_addr >> 8;
|
||||
send_struct.send_buffer[3] = modbus_analysis_data.start_addr & 0xff;
|
||||
send_struct.send_buffer[4] = modbus_analysis_data.reg_number >> 8;
|
||||
send_struct.send_buffer[5] = modbus_analysis_data.reg_number & 0xff;
|
||||
crc_16 = modbus_lib_crc16(send_struct.send_buffer, 6);
|
||||
send_struct.send_buffer[6] = crc_16 & 0xff;
|
||||
send_struct.send_buffer[7] = (crc_16 >> 8) & 0xff;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
error_code = ModbusErrorCode_IllegalFunction;
|
||||
}
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Success:
|
||||
proto_modbus_communication_data_send(send_struct.send_buffer, send_struct.len);
|
||||
return;
|
||||
|
||||
Error:
|
||||
send_struct.len = 5;
|
||||
send_struct.send_buffer[0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[1] = modbus_analysis_data.func | 0x80;
|
||||
send_struct.send_buffer[2] = error_code;
|
||||
crc_16 = modbus_lib_crc16(send_struct.send_buffer, 3);
|
||||
send_struct.send_buffer[3] = crc_16 & 0xff;
|
||||
send_struct.send_buffer[4] = (crc_16 >> 8) & 0xff;
|
||||
proto_modbus_communication_data_send(send_struct.send_buffer, send_struct.len);
|
||||
}
|
||||
|
||||
/******************************************
|
||||
* <20><><EFBFBD><EFBFBD>: proto_modbus_data_write
|
||||
* <20><><EFBFBD><EFBFBD>: Modbusд<73>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: Addr: <20><>ַ
|
||||
Value:<3A><><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
******************************************/
|
||||
static modbus_error_code_e proto_modbus_data_write(u16 addr, u16 data)
|
||||
{
|
||||
modbus_error_code_e error_code;
|
||||
u8 temp_point,cali_point;
|
||||
|
||||
error_code = ModbusErrorCode_Success;
|
||||
|
||||
switch(addr)
|
||||
{
|
||||
case 1 ... 4:
|
||||
{
|
||||
relay.set(addr-1,data);
|
||||
}break;
|
||||
|
||||
/*sn*/
|
||||
case 20000 ... 20004:
|
||||
{
|
||||
Usr_Flash.FlashData.sn[addr - 20000] = data;
|
||||
Usr_Flash.Write();
|
||||
}break;
|
||||
/*modbus_id*/
|
||||
case 20005:
|
||||
{
|
||||
Usr_Flash.FlashData.modbus_id = data;
|
||||
modbus_slave_ex.id = Usr_Flash.FlashData.modbus_id;
|
||||
Usr_Flash.Write();
|
||||
}break;
|
||||
/*modbus_read_reg_num*/
|
||||
case 20006:
|
||||
{
|
||||
if(data > 1000)
|
||||
{
|
||||
error_code = ModbusErrorCode_IllegalData;
|
||||
}
|
||||
else
|
||||
{
|
||||
Usr_Flash.FlashData.modbus_read_reg_num = data;
|
||||
Usr_Flash.Write();
|
||||
}
|
||||
}break;
|
||||
case 20007:
|
||||
{
|
||||
if(data > 16)
|
||||
{
|
||||
error_code = ModbusErrorCode_IllegalData;
|
||||
}
|
||||
else
|
||||
{
|
||||
Usr_Flash.FlashData.modbus_read_sensor_num = data;
|
||||
Usr_Flash.Write();
|
||||
}
|
||||
}break;
|
||||
/*FC<46><43>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
case 252:
|
||||
{
|
||||
print.set(data);
|
||||
}break;
|
||||
}
|
||||
return error_code;
|
||||
}
|
||||
|
||||
/******************************************
|
||||
* <20><><EFBFBD><EFBFBD>: proto_modbus_data_read
|
||||
* <20><><EFBFBD><EFBFBD>: Modbus<75><73><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: Addr: <20><>ַ
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>ַ<EFBFBD><D6B7>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
******************************************/
|
||||
static u16 proto_modbus_data_read(u16 addr)
|
||||
{
|
||||
u16 data = 0;
|
||||
u16 *p_data;
|
||||
u16 num,offset;
|
||||
|
||||
switch(addr)
|
||||
{
|
||||
case 1 ... 4:
|
||||
{
|
||||
data = relay.state[addr - 1];
|
||||
}break;
|
||||
// /*ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>*/
|
||||
// case 0 ... 639:
|
||||
// {
|
||||
// u16 size;
|
||||
// size = sizeof(gas_data_t);
|
||||
// /* TDLASĬ<53>϶<EFBFBD>ȡ*/
|
||||
// if( size== (2 * Usr_Flash.FlashData.modbus_read_reg_num))
|
||||
// {
|
||||
// p_data = (u16 *)&gas_data;
|
||||
// data = p_data[addr];
|
||||
// }
|
||||
// else if((2 * Usr_Flash.FlashData.modbus_read_reg_num )< sizeof(gas_data_t))/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
// {
|
||||
// num = addr / Usr_Flash.FlashData.modbus_read_reg_num;
|
||||
// offset = addr % Usr_Flash.FlashData.modbus_read_reg_num;
|
||||
// p_data = (u16 *)&gas_data[num];
|
||||
// data = p_data[offset];
|
||||
// }
|
||||
//
|
||||
// }break;
|
||||
//
|
||||
// /*sn*/
|
||||
// case 20000 ... 20004:
|
||||
// {
|
||||
// data = Usr_Flash.FlashData.sn[addr - 20000];
|
||||
// }break;
|
||||
// /*modbus_id*/
|
||||
// case 20005:
|
||||
// {
|
||||
// data = Usr_Flash.FlashData.modbus_id;
|
||||
// }break;
|
||||
// /*modbus_read_reg_num*/
|
||||
// case 20006:
|
||||
// {
|
||||
// data = Usr_Flash.FlashData.modbus_read_reg_num;
|
||||
// }break;
|
||||
// case 20007:
|
||||
// {
|
||||
// data = Usr_Flash.FlashData.modbus_read_sensor_num;
|
||||
// }break;
|
||||
default:data = 0;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
299
leakage_system/usr/protocol/proto_modbus_tcp_slave_ex.c
Normal file
299
leakage_system/usr/protocol/proto_modbus_tcp_slave_ex.c
Normal file
@@ -0,0 +1,299 @@
|
||||
/*<2A><><EFBFBD><EFBFBD>ͨѶ modbus<75>ӻ<EFBFBD>*/
|
||||
#include "proto_modbus_tcp_slave_ex.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "app_timer.h"
|
||||
#include "app_leakage.h"
|
||||
|
||||
#include "bsp_relay.h"
|
||||
#include "bsp_Uart.h"
|
||||
#include "bsp_Flash.h"
|
||||
#include "bsp_W5500.h"
|
||||
|
||||
#include "proto_print.h"
|
||||
#include "proto_modbus_master_leakage.h"
|
||||
|
||||
static modbus_analysis_data_t modbus_analysis_data;//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
||||
static modbus_communication_send_buf_t send_struct;//<2F><><EFBFBD>ͽṹ<CDBD><E1B9B9>
|
||||
|
||||
static void proto_modbus_communication_data_analysis(u8 *pData, u16 len, void *data);
|
||||
static void proto_modbus_communication_data_send(u8 *pData, u16 len);
|
||||
static void proto_modbus_init(void);
|
||||
static void proto_modbus_task(void);
|
||||
static modbus_error_code_e proto_modbus_data_write(u16 Addr, u16 Value);
|
||||
static u16 proto_modbus_data_read(u16 Addr);
|
||||
|
||||
proto_Modbus_t modbus_slave_ex=
|
||||
{
|
||||
.id = 0x01,
|
||||
.data_read = proto_modbus_data_read,
|
||||
.data_write = proto_modbus_data_write,
|
||||
.data_analysis = proto_modbus_communication_data_analysis,
|
||||
.init = proto_modbus_init,
|
||||
.task = proto_modbus_task,
|
||||
};
|
||||
|
||||
static proto_Modbus_t *p_modbus = &modbus_slave_ex;
|
||||
bsp_W5500_Class_t *p_W5500_Class = NULL;
|
||||
|
||||
static void proto_modbus_communication_data_send(u8 *p_data, u16 len)
|
||||
{
|
||||
if(NULL != p_W5500_Class)
|
||||
{
|
||||
W5500.Socket_Send(p_W5500_Class,p_data,len);
|
||||
}
|
||||
}
|
||||
|
||||
static void proto_modbus_init(void)
|
||||
{
|
||||
W5500.W5500_Class[0].Rx_DataAnalysis = proto_modbus_communication_data_analysis;
|
||||
}
|
||||
static void proto_modbus_task(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void proto_modbus_communication_data_analysis(u8 *pData, u16 len,void *other_data)
|
||||
{
|
||||
modbus_error_code_e error_code;
|
||||
u16 inx;
|
||||
u16 TempAddr, TempData, crc_16;
|
||||
u16 send_buff_index_offset = 0;
|
||||
|
||||
u16 transaction_type,proto_type,proto_len;
|
||||
|
||||
/*mobuds_tcpУ<70><D0A3>*/
|
||||
transaction_type = pData[0] << 8 | pData[1]; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
proto_type = pData[2] << 8 | pData[3]; /*Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
proto_len = pData[4] << 8 | pData[5]; /*Э<>鳤<EFBFBD><E9B3A4>*/
|
||||
|
||||
/*Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>*/
|
||||
if(MODBUS_TCP_PROTO_TYPE != proto_type || proto_len != (len - 6))
|
||||
{
|
||||
return;
|
||||
}
|
||||
p_W5500_Class = (bsp_W5500_Class_t *)other_data;
|
||||
/*<2A><><EFBFBD><EFBFBD>modbusЭ<73><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
modbus_analysis_data.id = pData[6];
|
||||
modbus_analysis_data.func = pData[7];
|
||||
modbus_analysis_data.start_addr = pData[8] << 8 | pData[9];
|
||||
modbus_analysis_data.reg_number = pData[10] << 8 | pData[11];
|
||||
|
||||
send_buff_index_offset = 6;
|
||||
memcpy(send_struct.send_buffer,pData,send_buff_index_offset);
|
||||
|
||||
error_code = ModbusErrorCode_Success;
|
||||
|
||||
/* //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>Ƿ<C7B7><F1B3ACB3><EFBFBD>Χ
|
||||
if ((modbus_analysis_data.start_addr >= MODBUS_REG_LEN) || (modbus_analysis_data.reg_number >= MODBUS_REG_LEN) ||
|
||||
(modbus_analysis_data.start_addr + modbus_analysis_data.reg_number >= MODBUS_REG_LEN))
|
||||
{
|
||||
ErrorCode = ModbusErrorCode_IllegalAddr;
|
||||
goto Error;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
switch (modbus_analysis_data.func)
|
||||
{
|
||||
case 0x03:
|
||||
case 0x04:
|
||||
{
|
||||
TempAddr = modbus_analysis_data.start_addr;
|
||||
send_struct.send_buffer[send_buff_index_offset + 0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[send_buff_index_offset + 1] = modbus_analysis_data.func;
|
||||
send_struct.send_buffer[send_buff_index_offset + 2] = 2 * modbus_analysis_data.reg_number;
|
||||
for (inx = 0; inx < modbus_analysis_data.reg_number; inx++)
|
||||
{
|
||||
TempData = proto_modbus_data_read(TempAddr);
|
||||
send_struct.send_buffer[send_buff_index_offset + 3 + 2 * inx] = (TempData >> 8) & 0xff;
|
||||
send_struct.send_buffer[send_buff_index_offset + 4 + 2 * inx] = TempData & 0xff;
|
||||
TempAddr++;
|
||||
}
|
||||
send_struct.len =send_buff_index_offset + 3 + send_struct.send_buffer[send_buff_index_offset + 2];
|
||||
}goto Success;
|
||||
/*<2A><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD>*/
|
||||
case 0x41:
|
||||
{
|
||||
TempAddr = modbus_analysis_data.start_addr;
|
||||
send_struct.send_buffer[send_buff_index_offset + 0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[send_buff_index_offset + 1] = modbus_analysis_data.func;
|
||||
send_struct.send_buffer[send_buff_index_offset + 2] = modbus_analysis_data.start_addr >> 8;
|
||||
send_struct.send_buffer[send_buff_index_offset + 3] = modbus_analysis_data.start_addr & 0xff;
|
||||
send_struct.send_buffer[send_buff_index_offset + 4] = (2 * modbus_analysis_data.reg_number) >> 8;
|
||||
send_struct.send_buffer[send_buff_index_offset + 5] = (2 * modbus_analysis_data.reg_number) & 0xff;
|
||||
for (inx = 0; inx < modbus_analysis_data.reg_number; inx++)
|
||||
{
|
||||
TempData = proto_modbus_data_read(TempAddr);
|
||||
send_struct.send_buffer[send_buff_index_offset + 6 + 2 * inx] = (TempData >> 8) & 0xff;
|
||||
send_struct.send_buffer[send_buff_index_offset + 7 + 2 * inx] = TempData & 0xff;
|
||||
TempAddr++;
|
||||
}
|
||||
send_struct.len = send_buff_index_offset + 6 + 2 * modbus_analysis_data.reg_number;
|
||||
}goto Success;
|
||||
|
||||
case 0x06:
|
||||
{
|
||||
TempAddr = modbus_analysis_data.start_addr;
|
||||
TempData = (modbus_analysis_data.write_data_addr[0] << 8) | modbus_analysis_data.write_data_addr[1];
|
||||
error_code = proto_modbus_data_write(TempAddr, TempData);
|
||||
if (error_code)
|
||||
{
|
||||
goto Error;
|
||||
}
|
||||
|
||||
send_struct.len = send_buff_index_offset + 6;
|
||||
send_struct.send_buffer[send_buff_index_offset + 0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[send_buff_index_offset + 1] = modbus_analysis_data.func;
|
||||
send_struct.send_buffer[send_buff_index_offset + 2] = modbus_analysis_data.start_addr >> 8;
|
||||
send_struct.send_buffer[send_buff_index_offset + 3] = modbus_analysis_data.start_addr & 0xff;
|
||||
send_struct.send_buffer[send_buff_index_offset + 4] = modbus_analysis_data.write_data_addr[0];
|
||||
send_struct.send_buffer[send_buff_index_offset + 5] = modbus_analysis_data.write_data_addr[1];
|
||||
}break;
|
||||
|
||||
case 0x10:
|
||||
{
|
||||
TempAddr = modbus_analysis_data.start_addr;
|
||||
for (inx = 0; inx < modbus_analysis_data.reg_number; inx++)
|
||||
{
|
||||
TempData = modbus_analysis_data.write_data_addr[2 * inx];
|
||||
TempData = (TempData << 8) | modbus_analysis_data.write_data_addr[2 * inx + 1];
|
||||
error_code = proto_modbus_data_write(TempAddr, TempData);
|
||||
TempAddr++;
|
||||
if (error_code)
|
||||
{
|
||||
goto Error;
|
||||
}
|
||||
}
|
||||
send_struct.len = send_buff_index_offset + 6;
|
||||
send_struct.send_buffer[0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[1] = modbus_analysis_data.func;
|
||||
send_struct.send_buffer[2] = modbus_analysis_data.start_addr >> 8;
|
||||
send_struct.send_buffer[3] = modbus_analysis_data.start_addr & 0xff;
|
||||
send_struct.send_buffer[4] = modbus_analysis_data.reg_number >> 8;
|
||||
send_struct.send_buffer[5] = modbus_analysis_data.reg_number & 0xff;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
error_code = ModbusErrorCode_IllegalFunction;
|
||||
}
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Success:
|
||||
send_struct.send_buffer[4] = (send_struct.len - send_buff_index_offset) >> 8;
|
||||
send_struct.send_buffer[5] = (send_struct.len - send_buff_index_offset) & 0x00ff;
|
||||
proto_modbus_communication_data_send(send_struct.send_buffer, send_struct.len);
|
||||
return;
|
||||
|
||||
Error:
|
||||
send_struct.len = send_buff_index_offset + 3;
|
||||
send_struct.send_buffer[0] = modbus_analysis_data.id;
|
||||
send_struct.send_buffer[1] = modbus_analysis_data.func | 0x80;
|
||||
send_struct.send_buffer[2] = error_code;
|
||||
send_struct.send_buffer[4] = (send_struct.len - send_buff_index_offset) >> 8;
|
||||
send_struct.send_buffer[5] = (send_struct.len - send_buff_index_offset) & 0x00ff;
|
||||
proto_modbus_communication_data_send(send_struct.send_buffer, send_struct.len);
|
||||
}
|
||||
|
||||
/******************************************
|
||||
* <20><><EFBFBD><EFBFBD>: proto_modbus_data_write
|
||||
* <20><><EFBFBD><EFBFBD>: Modbusд<73>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: Addr: <20><>ַ
|
||||
Value:<3A><><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
******************************************/
|
||||
static modbus_error_code_e proto_modbus_data_write(u16 addr, u16 data)
|
||||
{
|
||||
modbus_error_code_e error_code;
|
||||
u8 temp_point,cali_point;
|
||||
|
||||
error_code = ModbusErrorCode_Success;
|
||||
|
||||
switch(addr)
|
||||
{
|
||||
// case 1 ... 4:
|
||||
// {
|
||||
// relay.set(addr-1,data);
|
||||
// }break;
|
||||
//
|
||||
// /*sn*/
|
||||
// case 20000 ... 20004:
|
||||
// {
|
||||
// Usr_Flash.FlashData.sn[addr - 20000] = data;
|
||||
// Usr_Flash.Write();
|
||||
// }break;
|
||||
// /*modbus_id*/
|
||||
// case 20005:
|
||||
// {
|
||||
// Usr_Flash.FlashData.modbus_id = data;
|
||||
// modbus_slave_ex.id = Usr_Flash.FlashData.modbus_id;
|
||||
// Usr_Flash.Write();
|
||||
// }break;
|
||||
}
|
||||
return error_code;
|
||||
}
|
||||
|
||||
/******************************************
|
||||
* <20><><EFBFBD><EFBFBD>: proto_modbus_data_read
|
||||
* <20><><EFBFBD><EFBFBD>: Modbus<75><73><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: Addr: <20><>ַ
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>ַ<EFBFBD><D6B7>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
******************************************/
|
||||
static u16 proto_modbus_data_read(u16 addr)
|
||||
{
|
||||
u16 data = 0;
|
||||
u16 *p_data;
|
||||
u16 num,offset;
|
||||
u16 sensor_index,sensor_ch,reg;
|
||||
u16 *p_string;
|
||||
|
||||
|
||||
|
||||
switch(addr)
|
||||
{
|
||||
case 0 ... 607:
|
||||
{
|
||||
sensor_index = addr / 19; /*<2A><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ*/
|
||||
reg = addr % 19; /*<2A><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
switch(reg)
|
||||
{
|
||||
case 0:/*<2A>˿<EFBFBD>&ID*/
|
||||
{
|
||||
data = (leakage.sub_device_data[sensor_index].flash_data.com + 1)<< 8 | leakage.sub_device_data[sensor_index].flash_data.modbus_id;
|
||||
}break;
|
||||
case 1 ... 5:/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
{
|
||||
p_string = (u16 *)leakage.sub_device_data[sensor_index].flash_data.region_name;
|
||||
data = p_string[reg - 1]>> 8 | p_string[reg - 1] << 8;
|
||||
}break;
|
||||
case 6 ... 10:/*<2A>豸<EFBFBD><E8B1B8>*/
|
||||
{
|
||||
p_string = (u16 *)leakage.sub_device_data[sensor_index].flash_data.device_name;
|
||||
data = p_string[reg - 6]>> 8 | p_string[reg - 6] << 8;
|
||||
}break;
|
||||
case 11 ... 18:/*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
{
|
||||
sensor_ch = (addr - 11) / 2;
|
||||
if( (addr - 11) & 0x0001) /*©Һλ<D2BA><CEBB>*/
|
||||
{
|
||||
data = leakage.sub_device_data[sensor_index].ch_data[sensor_ch].distance;
|
||||
}
|
||||
else /*<2A>豸״̬*/
|
||||
{
|
||||
data = leakage.sub_device_data[sensor_index].ch_data[sensor_ch].state;
|
||||
}
|
||||
}break;
|
||||
default:data = 0;
|
||||
}
|
||||
|
||||
}break;
|
||||
default:data = 0;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _PROTO_MODBUS_SLAVE_EX_H_
|
||||
#define _PROTO_MODBUS_SLAVE_EX_H_
|
||||
#ifndef _PROTO_MODBUS_TCP_SLAVE_EX_H_
|
||||
#define _PROTO_MODBUS_TCP_SLAVE_EX_H_
|
||||
#include "main.h"
|
||||
#include "gas_data.h"
|
||||
#include "proto_modbus_lib.h"
|
||||
Reference in New Issue
Block a user