feat:网络升级流程完善

1、局域网升级流程 - 初步测试OK
2、云端升级流程 - 初步测试OK
3、云端升级上报升级进度 - 初步测试OK
This commit is contained in:
caocong
2026-02-10 17:45:08 +08:00
parent f16825ea2b
commit 3041468aa7
23 changed files with 1184 additions and 336 deletions

View File

@@ -14,7 +14,7 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release" postbuildStep=" ${cross_prefix}${cross_objcopy}${cross_suffix} -O ihex &quot;${ProjName}.elf&quot; &quot;${ProjName}.hex&quot; &amp;&amp; ${cross_prefix}${cross_objcopy}${cross_suffix} -O binary &quot;${ProjName}.elf&quot; &quot;${ProjName}.bin&quot;">
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074." name="/" resourcePath="">
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.231146001" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
@@ -117,7 +117,7 @@
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1292785366" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other.406870191" name="Other flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other" useByScannerDiscovery="false" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.1719943455" name="Output file format (-O)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.ihex" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.1719943455" name="Output file format (-O)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.ihexAndbinary" valueType="enumerated"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1356766765" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source.2052761852" name="Display source (--source|-S)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source" useByScannerDiscovery="false" value="false" valueType="boolean"/>

View File

@@ -598,7 +598,7 @@ __attribute__((section(".non_0_wait"))) void Dev_TEMPCTRL_Ctrl(uint32_t CfgDevAd
if(0x01 == KeepFlag)
{
BLV_Device_Info_Write_To_SRAM(CfgDevAddIn,&BUS_PublicOut,(uint8_t *)&Rs485Tem,sizeof(RS485_TEMP_INFO));
BLV_Device_Info_Write_To_SRAM(CfgDevAddOut,&BUS_PublicOut,(uint8_t *)&Rs485Tem,sizeof(RS485_TEMP_INFO));
}
}

View File

@@ -226,7 +226,7 @@ __attribute__((section(".non_0_wait"))) uint8_t BLW_Rs485_Touch_Swi_Check(uint32
else //<2F><>ַû<D6B7><C3BB>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>
{
DevAdd = Find_AllDevice_List_Information2(Active_Port, 0x06, data[0]); //<2F><>ַ<EFBFBD><D6B7><EFBFBD>¸<EFBFBD>ֵ
if( (0x00000000 != DevAdd) || (0xFFFFFFFF != DevAdd) )
if( (0x00000000 != DevAdd) && (0xFFFFFFFF != DevAdd) )
{
BLV_Device_PublicInfo_Read_To_Struct(DevAdd,&BUS_Public);
}else{

View File

@@ -35,8 +35,9 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000 , LENGTH = 64K
*/
FLASH (rx) : ORIGIN = 0x00000000 , LENGTH = 80K
FLASH1 (rx) : ORIGIN = 0x00014000 , LENGTH = 368K
FLASH (rx) : ORIGIN = 0x00001000 , LENGTH = 76K
FLASH1 (rx) : ORIGIN = 0x00014000 , LENGTH = 336K
RAM (xrw) : ORIGIN = 0x20000000 , LENGTH = 64K
}
@@ -55,7 +56,7 @@ SECTIONS
.vector :
{
*(.vector);
KEEP(*(.vector));
_endof_Vector = .;
ASSERT(_endof_Vector < ORIGIN(FLASH1), "The vector must maintain in 0-wait zone");
. = ALIGN(4);

View File

@@ -17,7 +17,7 @@ BLV_DevAction_Manage_G DevActionGlobal; //
* Description : <20><><EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><E5A3AC><EFBFBD><EFBFBD>ⲿSRAM
* DevAction_Info <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
*******************************************************************************/
uint8_t DevAction_Info_Write_To_SRAM(uint32_t addr,DEV_ACTION_INFO *DevAction_Info)
__attribute__((section(".non_0_wait"))) uint8_t DevAction_Info_Write_To_SRAM(uint32_t addr,DEV_ACTION_INFO *DevAction_Info)
{
uint16_t temp_len = 0;
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
@@ -111,7 +111,7 @@ uint8_t DevAction_Info_Write_To_SRAM(uint32_t addr,DEV_ACTION_INFO *DevAction_In
* addr <20><>ȡ<EFBFBD><C8A1>ַ
* DevAction_Info <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
*******************************************************************************/
uint8_t DevAction_Info_Read_To_Struct(uint32_t addr,DEV_ACTION_INFO *DevAction_Info)
__attribute__((section(".non_0_wait"))) uint8_t DevAction_Info_Read_To_Struct(uint32_t addr,DEV_ACTION_INFO *DevAction_Info)
{
uint16_t temp_len = SRAM_Read_Word(addr);

View File

@@ -413,7 +413,7 @@ uint8_t Udp_Internal_BLVIAP_Logic(uint8_t* data,uint16_t DataLen, uint8_t *ip,ui
uint8_t UDP_IAP_Cmd_Processing(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port)
{
uint16_t frameno = UDP_Get_FrameNum(data);
UINT32 sendlen = 0x00;
uint32_t sendlen = 0x00;
uint8_t buff[6];
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
@@ -421,6 +421,8 @@ uint8_t UDP_IAP_Cmd_Processing(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s",__func__);
server_info.goal_port = port;
memcpy(server_info.goal_ip, ip, 4);
memcpy(buff, ip, 4);
@@ -430,6 +432,7 @@ uint8_t UDP_IAP_Cmd_Processing(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint
memset(&IAPVarTypeStruct_Ptr, 0, sizeof(IAPVarTypeStruct));
IAPVarTypeStruct_Ptr.BLVIapFlag = 0x01;
IAPVarTypeStruct_Ptr.IapFileType = TFTP_IAP_DataType_APP; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
//IAP <20><><EFBFBD><EFBFBD>APP<50><50>Ӧ<EFBFBD><D3A6>MD5 У<><D0A3>
@@ -467,11 +470,15 @@ uint8_t UDP_IAP_Cmd_Processing(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint
IAPVarTypeStruct_Ptr.Md5[12],IAPVarTypeStruct_Ptr.Md5[13],\
IAPVarTypeStruct_Ptr.Md5[14],IAPVarTypeStruct_Ptr.Md5[15]);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"BlockSize:%d",IAPVarTypeStruct_Ptr.BlockSize);
sendlen = BLV_UDP_HEAD_LEN;
if( (0 < IAPVarTypeStruct_Ptr.BlockSize) || (IAPVarTypeStruct_Ptr.BlockSize <= APP_BLOCK_MAX) )
{
Global_Large_Buff[sendlen++] = TFTP_IAP_Status_Ready;
IAPVarTypeStruct_Ptr.enable = 0x01;
IAPVarTypeStruct_Ptr.FunType = TFTP_FUNTYPE_LocalIAP;
IAPVarTypeStruct_Ptr.Write_Block = 0x00;
}else {
Global_Large_Buff[sendlen++] = TFTP_IAP_Status_Error_Block;
}
@@ -484,6 +491,544 @@ uint8_t UDP_IAP_Cmd_Processing(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint
return 0x00;
}
/*******************************************************************************
* Function Name : UDP_Cloud_IAP_Cmd_Processing
* Description : BLVͨѶЭ<D1B6><D0AD> - <20>ƶ<EFBFBD>IAP<41><50><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
uint8_t UDP_Cloud_IAP_Cmd_Processing(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port)
{
uint16_t frameno = UDP_Get_FrameNum(data);
uint32_t sendlen = 0x00;
uint8_t temp_buff[6];
uint16_t temp_len = 0;
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
temp_len = BLV_UDP_HEAD_LEN;
memcpy(server_info.goal_ip, &data[temp_len], 4);
temp_len += 4;
IAPVarTypeStruct_Ptr.TFTP_Port = data[temp_len + 1];
IAPVarTypeStruct_Ptr.TFTP_Port <<= 8;
IAPVarTypeStruct_Ptr.TFTP_Port |= data[temp_len];
memcpy(temp_buff, ip, 4);
temp_buff[4] = data[temp_len];
temp_buff[5] = data[temp_len + 1];
SRAM_DMA_Write_Buff(temp_buff, 6, SRAM_IAP_IP_ADDRESS); //<2F><><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><C3B9>ߵ<EFBFBD>ip<69><70>port<72><74><EFBFBD><EFBFBD>SRAM<41><4D><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<CAB1><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ڣ<CBBF><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD>
temp_len += 2;
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ƶ<EFBFBD>TFTP port:%X , IP:%d.%d.%d.%d",IAPVarTypeStruct_Ptr.TFTP_Port,temp_buff[0],temp_buff[1],temp_buff[2],temp_buff[3]);
IAPVarTypeStruct_Ptr.Md5[0] = data[temp_len + 3];
IAPVarTypeStruct_Ptr.Md5[1] = data[temp_len + 2];
IAPVarTypeStruct_Ptr.Md5[2] = data[temp_len + 1];
IAPVarTypeStruct_Ptr.Md5[3] = data[temp_len + 0];
IAPVarTypeStruct_Ptr.Md5[4] = data[temp_len + 7];
IAPVarTypeStruct_Ptr.Md5[5] = data[temp_len + 6];
IAPVarTypeStruct_Ptr.Md5[6] = data[temp_len + 5];
IAPVarTypeStruct_Ptr.Md5[7] = data[temp_len + 4];
IAPVarTypeStruct_Ptr.Md5[8] = data[temp_len + 11];
IAPVarTypeStruct_Ptr.Md5[9] = data[temp_len + 10];
IAPVarTypeStruct_Ptr.Md5[10] = data[temp_len + 9];
IAPVarTypeStruct_Ptr.Md5[11] = data[temp_len + 8];
IAPVarTypeStruct_Ptr.Md5[12] = data[temp_len + 15];
IAPVarTypeStruct_Ptr.Md5[13] = data[temp_len + 14];
IAPVarTypeStruct_Ptr.Md5[14] = data[temp_len + 13];
IAPVarTypeStruct_Ptr.Md5[15] = data[temp_len + 12];
temp_len += 16;
IAPVarTypeStruct_Ptr.BlockSize = data[temp_len + 1];
IAPVarTypeStruct_Ptr.BlockSize <<= 8;
IAPVarTypeStruct_Ptr.BlockSize |= data[temp_len];
temp_len += 2;
Dbg_Println(DBG_BIT_NET_STATUS_bit,"BlockSize:%d ",IAPVarTypeStruct_Ptr.BlockSize);
if(data[temp_len] == 0x00) //<2F>̼<EFBFBD> - UDPЭ<50><D0AD><EFBFBD><EFBFBD> 0x00<30><30>ʾ<EFBFBD>̼<EFBFBD><CCBC><EFBFBD>0x01<30><31>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
{
IAPVarTypeStruct_Ptr.IapFileType = TFTP_IAP_DataType_APP;
}else if(data[temp_len] == 0x01) //<2F><><EFBFBD><EFBFBD>
{
IAPVarTypeStruct_Ptr.IapFileType = TFTP_IAP_DataType_CONFIG;
}else{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"IapFileType Error:%d ",data[temp_len]);
return 0x02;
}
temp_len += 1;
IAPVarTypeStruct_Ptr.FtpFileNameLen = DataLen - 42;
if(IAPVarTypeStruct_Ptr.FtpFileNameLen > TFTP_File_Name_Size)
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"FtpFileNameLen Error:%d ",IAPVarTypeStruct_Ptr.FtpFileNameLen);
return 0x02;
}
memcpy(IAPVarTypeStruct_Ptr.FtpFileName,&data[temp_len],IAPVarTypeStruct_Ptr.FtpFileNameLen);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"ftp_name:%d - %s",IAPVarTypeStruct_Ptr.FtpFileNameLen,IAPVarTypeStruct_Ptr.FtpFileName);
if( (0 < IAPVarTypeStruct_Ptr.BlockSize) || (IAPVarTypeStruct_Ptr.BlockSize <= APP_BLOCK_MAX) )
{
IAPVarTypeStruct_Ptr.enable = 0x01;
IAPVarTypeStruct_Ptr.FunType = TFTP_FUNTYPE_CloudIAP;
IAPVarTypeStruct_Ptr.Write_Block = 0x00;
}else {
return 0x02;
}
//<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sendlen = BLV_UDP_HEAD_LEN;
Global_Large_Buff[sendlen++] = 0x00; //<2F><><EFBFBD><EFBFBD>״̬ - <20>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>(0x00)
sendlen += UDP_ADD_SoftwareVer(&Global_Large_Buff[sendlen]);
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
if( IAPVarTypeStruct_Ptr.IapFileType == TFTP_IAP_DataType_APP )
{
Global_Large_Buff[sendlen++] = 0x00;
}else if( IAPVarTypeStruct_Ptr.IapFileType == TFTP_IAP_DataType_CONFIG ){
Global_Large_Buff[sendlen++] = 0x01;
}else {
Global_Large_Buff[sendlen++] = 0x00;
}
sendlen += 2;
UDP_Add_Header(Global_Large_Buff, In_Cloud_IAP_Cmd, sendlen, frameno);
NetCRC16(Global_Large_Buff,sendlen);
WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver], Global_Large_Buff, &sendlen, ip, port);
return 0x00;
}
/*******************************************************************************
* Function Name : UDP__BLVIAPCheck_Cmd_Processing
* Description : BLVͨѶЭ<D1B6><D0AD> - IAP<41><50><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
uint8_t UDP_BLVIAPCheck_Cmd_Processing(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port)
{
uint8_t rev = 0;
uint16_t crcNumIndex = 0,temp_val = 0x00,deal_frame = 0;
uint32_t crc_data_len = 0,sendlen = 0;
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s - %d",__func__,DataLen);
if(DataLen <= BLV_UDP_HEAD_LEN) return 0x01;
/* У<><D0A3>֡<EFBFBD><D6A1> - ֡<>Ų<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>*/
deal_frame = UDP_Get_FrameNum(data);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s Frame:%d - %d",__func__,deal_frame,server_info.udp_frame);
if( server_info.udp_frame != deal_frame )
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"BLVIapFlag:%d - %d %d",IAPVarTypeStruct_Ptr.BLVIapFlag,IAPVarTypeStruct_Ptr.BlockSize,tftp_args.block);
server_info.udp_frame = deal_frame;
/*<2A><>ǰ<EFBFBD><C7B0>BLV_Cx<43><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD>ҵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>*/
if((IAPVarTypeStruct_Ptr.BLVIapFlag == 0x01) && (IAPVarTypeStruct_Ptr.BlockSize == IAPVarTypeStruct_Ptr.Write_Block))
{
uint8_t md5[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
IAPVarTypeStruct_Ptr.status = STA_END; //<2F>ͷ<EFBFBD>IAP<41>׽<EFBFBD><D7BD><EFBFBD>
switch(IAPVarTypeStruct_Ptr.IapFileType)
{
case TFTP_IAP_DataType_APP:
MD5Digest_SRAM(SRAM_IAP_APP_FILE_ADDRESS, IAPVarTypeStruct_Ptr.TotalCount,(char *)&md5[0]);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"falshд<EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><EFBFBD>ȣ<EFBFBD>%dByte", IAPVarTypeStruct_Ptr.TotalCount );
if( bytes_cmp(md5,IAPVarTypeStruct_Ptr.Md5,16) == 0x00 )
{
//<2F>ļ<EFBFBD>MD5У<35><D0A3><EFBFBD>ɹ<EFBFBD>
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>Md5<EFBFBD><EFBFBD>ȷ");
if( IAPVarTypeStruct_Ptr.FunType == TFTP_FUNTYPE_LocalIAP )
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
LOG_LogicInfo_DebugRecord("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
SRAM_Write_Byte(TFTP_FUNTYPE_LocalIAP, SRAM_IAP_NET_UPGRADE_Flag_ADDRESS);
}
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD>APPд<EFBFBD><EFBFBD>Flash<EFBFBD><EFBFBD>..");
SPI_FLASH_APP_Data_Erase();
for(uint32_t i = 0;i < IAPVarTypeStruct_Ptr.BlockSize; i++ )
{
WDT_Feed();
SRAM_DMA_Read_Buff(Global_Large_Buff,512,SRAM_IAP_APP_FILE_ADDRESS+i*512);
Flash_Write(Global_Large_Buff,512,SPIFLASH_APP_Data_Start_Addr+i*512);
}
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
/* <20><><EFBFBD><EFBFBD>APP<50><50>CRCУ<43><D0A3>ֵ <20><><EFBFBD><EFBFBD>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
g_app_feature.app_flag = App_Procedure_Ready;
g_app_feature.app_crc_size = MCU_APP_Flash_PageSize;
g_app_feature.app_start_addr = MCU_APP_Flash_Start_Addr;
g_app_feature.app_end_addr = MCU_APP_Flash_Start_Addr + IAPVarTypeStruct_Ptr.TotalCount;
if( ( IAPVarTypeStruct_Ptr.TotalCount % g_app_feature.app_crc_size ) != 0x00 ){
g_app_feature.app_crc_len = ( (IAPVarTypeStruct_Ptr.TotalCount / g_app_feature.app_crc_size) + 1) * 2;
}else {
g_app_feature.app_crc_len = (IAPVarTypeStruct_Ptr.TotalCount / g_app_feature.app_crc_size) * 2;
}
Dbg_Println(DBG_BIT_NET_STATUS_bit,"App CRC BLock:%d ",g_app_feature.app_crc_len);
crcNumIndex = 0x00;
for(uint32_t crc_addr = g_app_feature.app_start_addr; crc_addr < g_app_feature.app_end_addr;crc_addr += g_app_feature.app_crc_size)
{
if( g_app_feature.app_end_addr - crc_addr >= g_app_feature.app_crc_size ) {
crc_data_len = g_app_feature.app_crc_size;
}else {
crc_data_len = g_app_feature.app_end_addr - crc_addr;
}
memset(Temp_Flash_Buff,0,sizeof(Temp_Flash_Buff));
if(crc_data_len > 2048)
{
Flash_Read(Temp_Flash_Buff,2048,crc_addr);
Flash_Read(&Temp_Flash_Buff[2048],(crc_data_len - 2048),crc_addr+2048);
}else {
Flash_Read(Temp_Flash_Buff,crc_data_len,crc_addr);
}
temp_val = NetCRC16_2(Temp_Flash_Buff,crc_data_len);
g_app_feature.app_crc[crcNumIndex] = temp_val & 0xFF;
g_app_feature.app_crc[crcNumIndex + 1] = (temp_val >> 8) & 0xFF;
crcNumIndex += 2;
}
g_app_feature.crc_check = 0x00;
Write_APP_Feature_Info(0x02,&g_app_feature); //д<><D0B4>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
WDT_Feed(); //<2F><>ֹ<EFBFBD><D6B9><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>λ
Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"<EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ!");
//ֱ<>ӿ<EFBFBD><D3BF>Ź<EFBFBD><C5B9><EFBFBD>λ
IAPVarTypeStruct_Ptr.BLVIapResult = 0x01; //IAP<41><50><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
}else{
//MD5У<35><D0A3>ʧ<EFBFBD><CAA7>
// switch(IAPVarTypeStruct_Ptr->IapType)
// {
// case IAPTFTPWRITE://IAP_AckState(IAP_Error_MD5, (uint8_t *)ip, (uint16_t)port); break; //<2F>ظ<EFBFBD>Md5<64><35><EFBFBD><EFBFBD>
// IAP_AckState(IAP_Error_MD5, (uint8_t *)ip_addr, (uint16_t)sever_port); //<2F>ظ<EFBFBD>Md5<64><35><EFBFBD><EFBFBD>
// break;
// case IAPTFTPREAD:
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Error_MD5, (uint8_t *)ip, (uint16_t)port, DATATYPE_IAP);
// break;
// }
IAPVarTypeStruct_Ptr.BLVIapResult = 0x02; //IAP<41><50><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Md5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X", \
md5[0],md5[1],md5[2],md5[3],md5[4],md5[5],md5[6],md5[7],md5[8],md5[9],md5[10],md5[11],md5[12],md5[13],md5[14],md5[15]);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"UDP Md5:%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X", \
IAPVarTypeStruct_Ptr.Md5[0],IAPVarTypeStruct_Ptr.Md5[1], \
IAPVarTypeStruct_Ptr.Md5[2],IAPVarTypeStruct_Ptr.Md5[3], \
IAPVarTypeStruct_Ptr.Md5[4],IAPVarTypeStruct_Ptr.Md5[5], \
IAPVarTypeStruct_Ptr.Md5[6],IAPVarTypeStruct_Ptr.Md5[7], \
IAPVarTypeStruct_Ptr.Md5[8],IAPVarTypeStruct_Ptr.Md5[9], \
IAPVarTypeStruct_Ptr.Md5[10],IAPVarTypeStruct_Ptr.Md5[11],\
IAPVarTypeStruct_Ptr.Md5[12],IAPVarTypeStruct_Ptr.Md5[13],\
IAPVarTypeStruct_Ptr.Md5[14],IAPVarTypeStruct_Ptr.Md5[15]);
}
break;
case TFTP_IAP_DataType_CONFIG:
MD5Digest_SRAM(SRAM_IAP_LOGIC_DataStart_ADDRESS, IAPVarTypeStruct_Ptr.TotalCount, (char *)&md5[0]);
if( bytes_cmp(md5,IAPVarTypeStruct_Ptr.Md5,16) == 0x00 )
{
// switch(IAPVarTypeStruct_Ptr->IapType)
// {
// case IAPTFTPWRITE: //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"<22><>¼<EFBFBD>߼<EFBFBD><DFBC>ļ<EFBFBD>д<EFBFBD><D0B4><EFBFBD>ɹ<EFBFBD>״̬..");
// LOGIC_Config_AckState(IAP_Finish, (uint8_t *)ip, (uint16_t)sever_port);
// break;
// case IAPTFTPREAD:
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"<22><>¼<EFBFBD>߼<EFBFBD><DFBC>ļ<EFBFBD><C4BC><EFBFBD>ȡ<EFBFBD>ɹ<EFBFBD>״̬..");
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Finish, (uint8_t *)ip, (uint16_t)sever_port, DATATYPE_CONFIG);
// break;
// }
SPI_FLASH_Logic_File_Erase(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(uint32_t i = 0; i < IAPVarTypeStruct_Ptr.BlockSize; i++)
{
WDT_Feed();
temp_val = SRAM_IAP_LOGIC_DataStart_ADDRESS+i*512;
SRAM_DMA_Read_Buff(Global_Large_Buff,512,SRAM_IAP_LOGIC_DataStart_ADDRESS+i*512);
Flash_Write(Global_Large_Buff,512,SPIFLASH_LOGIC_DataStart_ADDRESS+i*512);
}
Global_Large_Buff[0] = 0x01;
Global_Large_Buff[1] = 0x00;
Global_Large_Buff[2] = 0x06;
Global_Large_Buff[3] = 0xCC;
Global_Large_Buff[4] = IAPVarTypeStruct_Ptr.TotalCount & 0xFF;
Global_Large_Buff[5] = (IAPVarTypeStruct_Ptr.TotalCount >> 8) & 0xFF;
Global_Large_Buff[6] = (IAPVarTypeStruct_Ptr.TotalCount >> 16) & 0xFF;
Global_Large_Buff[7] = (IAPVarTypeStruct_Ptr.TotalCount >> 24) & 0xFF;
memcpy(&Global_Large_Buff[8],IAPVarTypeStruct_Ptr.Md5,16);
Flash_Write(Global_Large_Buff,24,SPIFLASH_LOGIC_DataFlag_ADDRESS);
Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
LOG_LogicInfo_DebugRecord("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ");
IAPVarTypeStruct_Ptr.BLVIapResult = 0x01; //IAP<41><50><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
}else{
// switch(IAPVarTypeStruct_Ptr->IapType)
// {
// case IAPTFTPWRITE: //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// LOGIC_Config_AckState(IAP_Error_MD5, (uint8_t *)ip_addr, (uint16_t)sever_port);
// break;
// case IAPTFTPREAD:
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Error_MD5, (uint8_t *)ip, (uint16_t)sever_port, DATATYPE_CONFIG);
// break;
// }
IAPVarTypeStruct_Ptr.BLVIapResult = 0x02; //IAP<41><50><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Md5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X",\
md5[0],md5[1],md5[2],md5[3],md5[4],md5[5],md5[6],md5[7],md5[8],md5[9],md5[10],md5[11],md5[12],md5[13],md5[14],md5[15]);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"UDP Md5:%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X,%X",\
IAPVarTypeStruct_Ptr.Md5[0],IAPVarTypeStruct_Ptr.Md5[1],\
IAPVarTypeStruct_Ptr.Md5[2],IAPVarTypeStruct_Ptr.Md5[3],\
IAPVarTypeStruct_Ptr.Md5[4],IAPVarTypeStruct_Ptr.Md5[5],\
IAPVarTypeStruct_Ptr.Md5[6],IAPVarTypeStruct_Ptr.Md5[7],\
IAPVarTypeStruct_Ptr.Md5[8],IAPVarTypeStruct_Ptr.Md5[9],\
IAPVarTypeStruct_Ptr.Md5[10],IAPVarTypeStruct_Ptr.Md5[11],\
IAPVarTypeStruct_Ptr.Md5[12],IAPVarTypeStruct_Ptr.Md5[13],\
IAPVarTypeStruct_Ptr.Md5[14],IAPVarTypeStruct_Ptr.Md5[15]);
}
break;
default:
IAPVarTypeStruct_Ptr.BLVIapResult = 0x10; //IAP<41><50><EFBFBD><EFBFBD> - δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD>");
break;
}
}else if( (IAPVarTypeStruct_Ptr.BLVIapFlag == 0x01) && (IAPVarTypeStruct_Ptr.BlockSize != IAPVarTypeStruct_Ptr.Write_Block) )
{
IAPVarTypeStruct_Ptr.BLVIapResult = 0x03; //IAP<41><50><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
}else {
IAPVarTypeStruct_Ptr.BLVIapResult = 0x10; //IAP<41><50><EFBFBD><EFBFBD> - δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
}
}else{
/*֡<><D6A1><EFBFBD><EFBFBD>ͬ - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ظ<EFBFBD>(<28>ظ<EFBFBD><D8B8>еĽ<D0B5><C4BD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʹ<EFBFBD>õĽ<C3B5><C4BD><EFBFBD>)*/
}
//<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
sendlen = BLV_UDP_HEAD_LEN;
Global_Large_Buff[BLV_UDP_HEAD_LEN] = IAPVarTypeStruct_Ptr.BLVIapResult; //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sendlen += 3;
UDP_Add_Header(Global_Large_Buff,In_BLVIAPCheck_Cmd,sendlen,deal_frame);
NetCRC16(Global_Large_Buff,sendlen);
rev = WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver],Global_Large_Buff,&sendlen,ip,port);
return rev;
}
/*******************************************************************************
* Function Name : UDP_BLVIAPPlan_Cmd_Processing
* Description : BLVͨѶЭ<D1B6><D0AD> - IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD>
*******************************************************************************/
uint8_t UDP_BLVIAPPlan_Cmd_SendPack(uint8_t iap_state)
{
uint8_t rev = 0;
uint32_t sendlen = 0;
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s -------",__func__);
if((server_info.frame_no < 0xfffe) && (server_info.frame_no >= 0x8000))
{
server_info.frame_no++;
} else {
server_info.frame_no = 0x8000;
}
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
sendlen = BLV_UDP_HEAD_LEN;
Global_Large_Buff[sendlen++] = iap_state; //<2F><><EFBFBD><EFBFBD>״̬
Global_Large_Buff[sendlen++] = IAPVarTypeStruct_Ptr.IapFileType; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
Global_Large_Buff[sendlen++] = (IAPVarTypeStruct_Ptr.BlockSize & 0xFF); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ܿ<EFBFBD><DCBF><EFBFBD>
Global_Large_Buff[sendlen++] = ((IAPVarTypeStruct_Ptr.BlockSize >> 8) & 0xFF); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ܿ<EFBFBD><DCBF><EFBFBD>
Global_Large_Buff[sendlen++] = (IAPVarTypeStruct_Ptr.Write_Block & 0xFF); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ĵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
Global_Large_Buff[sendlen++] = ((IAPVarTypeStruct_Ptr.Write_Block >> 8) & 0xFF); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ĵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
Global_Large_Buff[sendlen++] = IAPVarTypeStruct_Ptr.FtpFileNameLen;
memcpy(&Global_Large_Buff[sendlen],IAPVarTypeStruct_Ptr.FtpFileName,IAPVarTypeStruct_Ptr.FtpFileNameLen);
sendlen += IAPVarTypeStruct_Ptr.FtpFileNameLen;
UDP_Add_Header(Global_Large_Buff,In_BLVIAPPlan_Cmd,sendlen,server_info.frame_no);
NetCRC16(Global_Large_Buff,sendlen);
rev = WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver], Global_Large_Buff, &sendlen, server_info.dis_ip, server_info.dis_port);
return rev;
}
/*******************************************************************************
* Function Name : UDP_BLVIAPJump_Cmd_Processing
* Description : BLVͨѶЭ<D1B6><D0AD> - <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
uint8_t UDP_BLVIAPJump_Cmd_Processing(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port)
{
uint8_t rev = 0x00,result = 0x02;
uint16_t deal_frame = 0;
uint32_t sendlen = 0;
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s - %d",__func__,DataLen);
if(DataLen <= BLV_UDP_HEAD_LEN) return 0x01;
/* У<><D0A3>֡<EFBFBD><D6A1> - ֡<>Ų<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>*/
deal_frame = UDP_Get_FrameNum(data);
if( server_info.udp_frame != deal_frame )
{
switch(data[BLV_UDP_HEAD_LEN])
{
case 0x01:
result = 0x01;
break;
case 0x02:
result = 0x01;
break;
}
}
//<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
sendlen = BLV_UDP_HEAD_LEN;
Global_Large_Buff[BLV_UDP_HEAD_LEN] = IAPVarTypeStruct_Ptr.BLVIapResult; //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sendlen += 3;
UDP_Add_Header(Global_Large_Buff,In_BLVIAPJump_Cmd,sendlen,deal_frame);
NetCRC16(Global_Large_Buff,sendlen);
rev = WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver],Global_Large_Buff,&sendlen,ip,port);
/* - <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>λ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>־λ,
* - <20><>Ҫ<EFBFBD><D2AA>Ԥ<EFBFBD><D4A4>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ󣬻<C9BA>û<EFBFBD>и<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
if( (SRAM_Read_Byte(SRAM_IAP_NET_UPGRADE_Flag_ADDRESS) == TFTP_FUNTYPE_LocalIAP) )
{
SRAM_Write_Byte(0x01, SRAM_IAP_IAP_Reset_Flag_ADDRESS);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s <20><><EFBFBD>þ<EFBFBD><C3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>־ %d",__func__,SRAM_Read_Byte(SRAM_IAP_IAP_Reset_Flag_ADDRESS));
}
if(result == 0x01)
{
Delay_Ms(100);
WDT_Feed();
switch(data[BLV_UDP_HEAD_LEN])
{
case 0x01: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ",__func__,DataLen);
RCC_SET_GLOB_RST_KEEP(0x03);
Delay_Ms(100);
NVIC_SystemReset();
while(1);
break;
case 0x02: //<2F><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>λ
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>λ",__func__,DataLen);
RCC_SET_GLOB_RST_KEEP(0x04); //0x04<30><34>APP <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>λ
Delay_Ms(100);
while(1);
break;
}
}
return rev;
}
/*******************************************************************************
* Function Name : UDP_ReplyIAP_SendPack
* Description : BLVͨѶЭ<D1B6><D0AD> - IAP<41><50><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD> <20><><EFBFBD>ݷ<EFBFBD><DDB7>ͺ<EFBFBD><CDBA><EFBFBD>
*******************************************************************************/
uint8_t UDP_ReplyIAP_SendPack(void)
{
uint16_t frameno = 0x8001;
uint8_t R_IP[4] = {0};
uint16_t R_Port = 0;
uint32_t sendlen = 0x00;
uint8_t rev = 0;
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s",__func__);
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
SRAM_DMA_Read_Buff(R_IP,4,SRAM_IAP_IP_ADDRESS);
R_Port = SRAM_Read_Byte(SRAM_IAP_PORT_ADDRESS);
R_Port |= SRAM_Read_Byte(SRAM_IAP_PORT_ADDRESS+1) << 8;
sendlen = BLV_UDP_HEAD_LEN;
Global_Large_Buff[sendlen++] = 0x01; //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -
sendlen += UDP_ADD_SoftwareVer(&Global_Large_Buff[sendlen]); //<2F><><EFBFBD>ӹ̼<D3B9><CCBC>
sendlen += 2;
UDP_Add_Header(Global_Large_Buff,In_IAP_Cmd,sendlen,frameno);
NetCRC16(Global_Large_Buff,sendlen);
rev = WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver],Global_Large_Buff,&sendlen,R_IP,R_Port);
return rev;
}
/*******************************************************************************
* Function Name : UDP_ReplyCloudIAP_SendPack
* Description : BLVͨѶЭ<D1B6><D0AD> - <20>ƶ<EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD> <20><><EFBFBD>ݷ<EFBFBD><DDB7>ͺ<EFBFBD><CDBA><EFBFBD>
*******************************************************************************/
uint8_t UDP_ReplyCloudIAP_SendPack(void)
{
uint16_t frameno = 0x8001;
uint8_t R_IP[4] = {0};
uint16_t R_Port = 0;
uint32_t sendlen = 0x00;
uint8_t rev = 0;
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s",__func__);
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
SRAM_DMA_Read_Buff(R_IP,4,SRAM_IAP_IP_ADDRESS);
R_Port = SRAM_Read_Byte(SRAM_IAP_PORT_ADDRESS);
R_Port |= SRAM_Read_Byte(SRAM_IAP_PORT_ADDRESS+1) << 8;
sendlen = BLV_UDP_HEAD_LEN;
Global_Large_Buff[sendlen++] = 0x01; //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -
sendlen += UDP_ADD_SoftwareVer(&Global_Large_Buff[sendlen]); //<2F><><EFBFBD>ӹ̼<D3B9><CCBC>
Global_Large_Buff[sendlen++] = 0x00;
sendlen += 2;
UDP_Add_Header(Global_Large_Buff,In_Cloud_IAP_Cmd,sendlen,frameno);
NetCRC16(Global_Large_Buff,sendlen);
rev = WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver],Global_Large_Buff,&sendlen,server_info.dis_ip,server_info.dis_port);
return rev;
}
/*******************************************************************************
* Function Name : UDP_Search_Cmd_Processing
* Description : BLVͨѶЭ<D1B6><D0AD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -760,6 +1305,108 @@ uint8_t Udp_QueryTime_Cmd_Process(uint8_t *data, uint16_t DataLen, uint8_t *ip,u
return 0;
}
/*******************************************************************************
* Function Name : Udp_WriteRegister_Cmd_Processing
* Description : UDPͨѶЭ<D1B6><D0AD> - д<><D0B4><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
uint8_t Udp_WriteRegister_Cmd_Processing(uint8_t *data, uint16_t DataLen, uint8_t *ip,uint16_t port)
{
uint8_t i = 0,temp = 0,temp_num = 0;
uint32_t read_register = 0,temp_offset = 0,temp_data = 0;
uint16_t pack_frame = 0;
uint32_t sendlen = BLV_UDP_HEAD_LEN; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
memset(Global_Large_Buff,0,sizeof(Global_Large_Buff));
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s",__func__);
pack_frame = UDP_Get_FrameNum(data); //֡<><D6A1>
if( server_info.udp_frame != pack_frame )
{
//֡<>Ų<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/*<2A><><EFBFBD>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
temp = 0x01;
if(data[BLV_UDP_HEAD_LEN] > 35) temp_num = 35; //<2F><><EFBFBD>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>35<33><35>
else temp_num = data[BLV_UDP_HEAD_LEN];
for(i = 0;i<temp_num;i++)
{
temp_offset = data[BLV_UDP_HEAD_LEN+i*8+4];
temp_offset <<= 8;
temp_offset |= data[BLV_UDP_HEAD_LEN+i*8+3];
temp_offset <<= 8;
temp_offset |= data[BLV_UDP_HEAD_LEN+i*8+2];
temp_offset <<= 8;
temp_offset |= data[BLV_UDP_HEAD_LEN+i*8+1];
temp_data = data[BLV_UDP_HEAD_LEN+i*8+8];
temp_data <<= 8;
temp_data |= data[BLV_UDP_HEAD_LEN+i*8+7];
temp_data <<= 8;
temp_data |= data[BLV_UDP_HEAD_LEN+i*8+6];
temp_data <<= 8;
temp_data |= data[BLV_UDP_HEAD_LEN+i*8+5];
read_register = SRAM_Register_Start_ADDRESS + temp_offset;
Dbg_Println(DBG_BIT_NET_STATUS_bit,"temp_offset:%X data:%X",read_register,temp_data);
if(read_register > SRAM_Register_End_ADDRESS)
{
temp = 0x02; //д<><D0B4>ʧ<EFBFBD><CAA7>
Dbg_Println(DBG_BIT_NET_STATUS_bit,"Not In The Right Range");
continue;
}
/*<2A><>Ȩʱ<C8A8><CAB1>д<EFBFBD><D0B4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>±<EFBFBD><C2B1><EFBFBD>ʱ<EFBFBD><CAB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>RTCʱ<43><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>ʹ<EFBFBD><CAB9>UTCʱ<43><EFBFBD><E4B1A3><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>*/
if(read_register == (SRAM_Register_Start_ADDRESS + Register_MandateUTC_OFFSET))
{
S_RTC write_rtc;
memset(&write_rtc,0,sizeof(write_rtc));
Unix_Conversion_To_RTC(&write_rtc,temp_data);
RTC_WriteDate(write_rtc);
}
/*<2A><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ˢ<EFBFBD><CBA2>*/
if(read_register == (SRAM_Register_Start_ADDRESS + Register_MandateExpiresTime_OFFSET))
{
BLV_Set_Authorize_Status(temp_data,0);
}
/*<2A><><EFBFBD><EFBFBD>MCU<43><55><EFBFBD><EFBFBD>״̬*/
if(read_register == (SRAM_Register_Start_ADDRESS + Register_MandateLock_OFFSET))
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"Set_Authorize_Lock_Status:%X",temp_data);
if(temp_data == 0x00000001)
{
Set_Authorize_Lock_Status(0x01);
}else if(temp_data == 0x00000000)
{
Set_Authorize_Lock_Status(0x00);
}
}
SRAM_Write_DW(temp_data,read_register);
if(temp_data != SRAM_Read_DW(read_register)) temp = 0x02; //д<><D0B4>ʧ<EFBFBD><CAA7>
}
Retain_Flash_Register_Data(); //<2F><><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1>浽Flash<73><68>
}else{
//֡<><D6A1><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
sendlen = BLV_UDP_HEAD_LEN;
Global_Large_Buff[sendlen++] = temp; //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UDP_Add_Header(Global_Large_Buff,In_WriteRegister_Cmd,sendlen,pack_frame); //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>
//<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
NetCRC16(&Global_Large_Buff[0],sendlen);
WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver], &Global_Large_Buff[0], &sendlen, server_info.dis_ip, server_info.dis_port);
return 0x00;
}
/*******************************************************************************
* Function Name : Udp_Internal_GetRoomRent_CMD
* Description : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>̬
@@ -1068,12 +1715,16 @@ __attribute__((section(".non_0_wait"))) uint8_t Udp_Internal_Read_MCU_System_Sen
}else {
/*<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Launcher_ ǰ׺<C7B0><D7BA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>Ĭ<EFBFBD><C4AC>ΪLauncher_C1F_V02*/
memset(temp_data,0,sizeof(temp_data));
snprintf((char *)temp_data,sizeof(temp_data),"Launcher_C1F_V02 ");
snprintf((char *)temp_data,sizeof(temp_data),"Launcher_C1F_V04 ");
memcpy(&Global_Large_Buff[BLV_UDP_HEAD_LEN+67],temp_data,20);
}
UDP_Add_Mac(&Global_Large_Buff[BLV_UDP_HEAD_LEN+87]); //MAC<41><43>ַ
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+93],4,SRAM_Register_Start_ADDRESS + Register_ProjectCode_OFFSET); //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
Global_Large_Buff[BLV_UDP_HEAD_LEN+93] = 0x3D;
Global_Large_Buff[BLV_UDP_HEAD_LEN+94] = 0x04;
Global_Large_Buff[BLV_UDP_HEAD_LEN+95] = 0x00;
Global_Large_Buff[BLV_UDP_HEAD_LEN+96] = 0x00;
//SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+93],4,SRAM_Register_Start_ADDRESS + Register_ProjectCode_OFFSET); //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+97],4,SRAM_Register_Start_ADDRESS + Register_RoomNumber_OFFSET);
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+101],4,SRAM_Register_Start_ADDRESS + Register_HouseType_OFFSET);
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+105],4,SRAM_Register_Start_ADDRESS + Register_ConfigVersion_OFFSET); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -1087,11 +1738,12 @@ __attribute__((section(".non_0_wait"))) uint8_t Udp_Internal_Read_MCU_System_Sen
//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
memset(temp_data,0,sizeof(temp_data));
snprintf((char *)temp_data,sizeof(temp_data),"BLV-C1");
snprintf((char *)temp_data,sizeof(temp_data),"BLV-C1F");
memcpy(&Global_Large_Buff[BLV_UDP_HEAD_LEN+257],temp_data,32);
memset(temp_data,0,sizeof(temp_data));
snprintf((char *)temp_data,sizeof(temp_data),"BLV-V9");
memcpy(&Global_Large_Buff[BLV_UDP_HEAD_LEN+321],temp_data,32);
//<2F><>ȡFlash<73>е<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
//Flash_Read(&Global_Large_Buff[BLV_UDP_HEAD_LEN+257],64,SPIFLASH_MCU_Model_Revision_ADDRESS);
//Flash_Read(&Global_Large_Buff[BLV_UDP_HEAD_LEN+321],64,SPIFLASH_MCU_Control_Revision_ADDRESS);
@@ -2222,6 +2874,7 @@ void Udp_Internal_Analysis(uint8_t *data, uint32_t len, uint8_t* ip, uint16_t po
temp_val = data[len-1];
temp_val <<= 0x08;
temp_val |= data[len-2];
if(NetCRC16_2(data,len-2) != temp_val) return ; //CRCУ<43><D0A3>ʧ<EFBFBD><CAA7><><D6B1><EFBFBD>˳<EFBFBD>
switch(data[CMD_OFFSET])
@@ -2232,25 +2885,43 @@ void Udp_Internal_Analysis(uint8_t *data, uint32_t len, uint8_t* ip, uint16_t po
// case In_IAP_Cmd: //IAP APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// UDP_IAP_Cmd_Processing(data, len, ip, port);
// break;
// case In_Subgroup_Cmd: //IAP <20>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -- ȡ<><C8A1>û<EFBFBD><C3BB>ʹ<EFBFBD><CAB9>
// UDP_Subgroup_Cmd_Processing(data, len, ip, port);
// break;
case In_Cloud_IAP_Cmd: //<2F>ƶ<EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6>
UDP_Cloud_IAP_Cmd_Processing(data, len, ip, port);
break;
case In_Read_MCUSystem_Cmd: //<2F><>ȡMCU<43><55><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - Ҳ<><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UDP_Read_MCUSystem_Cmd_Processing(data, len, ip, port);
break;
case In_QueryTime_Cmd: //<2F><>ȡʱ<C8A1><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Udp_QueryTime_Cmd_Process(data, len, ip, port);
break;
case In_ReadRegister_Cmd:
break;
case In_WriteRegister_Cmd:
Udp_WriteRegister_Cmd_Processing(data, len, ip, port);
break;
case In_DevState_Cmd: //<2F>ϱ<EFBFBD><CFB1>豸״̬<D7B4><CCAC><EFBFBD><EFBFBD>
Udp_Internal_RoomState_Process(data, len, ip, port);
break;
case In_PeriodicReport_Cmd: //<2F><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>
Udp_Internal_Periodic_Report_Process(data, len, ip, port);
break;
case In_BLVIAPLogic_Cmd:
case In_BLVIAP_Cmd: //PC <20>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UDP_IAP_Cmd_Processing(data, len, ip, port);
break;
case In_BLVIAPCheck_Cmd: //PC У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UDP_BLVIAPCheck_Cmd_Processing(data, len, ip, port);
break;
case In_BLVIAPJump_Cmd: //PC <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
UDP_BLVIAPJump_Cmd_Processing(data, len, ip, port);
break;
case In_BLVIAPLogic_Cmd: //PC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Udp_Internal_BLVIAP_Logic(data, len, ip, port);
break;
case In_BLVPCTestDevice_Cmd:
case In_BLVPCTestDevice_Cmd: //PC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Udp_Internal_BLVPCTestDevice_Process(data, len, ip, port);
break;
default:
@@ -2274,7 +2945,7 @@ void Udp_Internal_Analysis(uint8_t *data, uint32_t len, uint8_t* ip, uint16_t po
__attribute__((section(".non_0_wait"))) void BLV_UDP_Comm_Task(void)
{
static uint32_t udp_state_tick = 0;
uint32_t temp_val = 0;
uint32_t temp_val = 0,temp_rev = 0;
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
if( SysTick_1ms - udp_state_tick >= 100 )
@@ -2283,16 +2954,6 @@ __attribute__((section(".non_0_wait"))) void BLV_UDP_Comm_Task(void)
if( (WCHNET_Get_PHY_Linked_Status() == 0x01) || (server_info.init_flag == 0x00) ) return ; //DNS<4E><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>ֱ<EFBFBD><D6B1><EFBFBD>˳<EFBFBD>
/*<2A><><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
// if(IAPVarTypeStruct_Ptr != NULL)
// {
// if(IAPSTART == IAPVarTypeStruct_Ptr->IapState)
// {
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"RoomState_Cmd<6D><64>ͣ,IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..");
// return;
// }
// }
server_info.udp_scan_cnt++;
if(server_info.udp_scan_cnt >= 9)
{
@@ -2322,6 +2983,8 @@ __attribute__((section(".non_0_wait"))) void BLV_UDP_Comm_Task(void)
//UDP_ActSend_PowerChange_Scan_State(); //ɨ<><C9A8>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>
//Udp_Scan_Roomstate(); //ɨ<>跿<EFBFBD><E8B7BF><EFBFBD>豸״̬
}
switch(server_info.udp_sta)
@@ -2340,6 +3003,47 @@ __attribute__((section(".non_0_wait"))) void BLV_UDP_Comm_Task(void)
}
return ;
}else{
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
if( (SRAM_Read_Byte(SRAM_IAP_NET_UPGRADE_Flag_ADDRESS) == TFTP_FUNTYPE_LocalIAP)
&& (SRAM_Read_Byte(SRAM_IAP_IAP_Reset_Flag_ADDRESS) == 0x01) )
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ظ<EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD> ..");
temp_rev = UDP_ReplyIAP_SendPack();
if(temp_rev == WCHNET_ERR_SUCCESS)
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ظ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>");
SRAM_Write_Byte(0xFF,SRAM_IAP_NET_UPGRADE_Flag_ADDRESS); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
SRAM_Write_Byte(0xFF,SRAM_IAP_IAP_Reset_Flag_ADDRESS);
}else {
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ظ<EFBFBD>ʧ<EFBFBD><EFBFBD> %x<><78>",temp_rev);
temp_rev = SRAM_Read_Byte(SRAM_IAP_UPGRADE_Reply_NUM_ADDRESS);
if(temp_rev > 5) SRAM_Write_Byte(0xFF,SRAM_IAP_NET_UPGRADE_Flag_ADDRESS); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
temp_rev++;
SRAM_Write_Byte(0xFF,SRAM_IAP_UPGRADE_Reply_NUM_ADDRESS);
}
return ;
}else if( SRAM_Read_Byte(SRAM_IAP_NET_UPGRADE_Flag_ADDRESS) == TFTP_FUNTYPE_CloudIAP )
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ظ<EFBFBD>-<2D>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD> -..");
temp_rev = UDP_ReplyCloudIAP_SendPack();
if(temp_rev == WCHNET_ERR_SUCCESS)
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ظ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>");
SRAM_Write_Byte(0xFF,SRAM_IAP_NET_UPGRADE_Flag_ADDRESS); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
}else {
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ظ<EFBFBD>ʧ<EFBFBD><EFBFBD> %x<><78>",temp_rev);
temp_rev = SRAM_Read_Byte(SRAM_IAP_UPGRADE_Reply_NUM_ADDRESS);
if(temp_rev > 5) SRAM_Write_Byte(0xFF,SRAM_IAP_NET_UPGRADE_Flag_ADDRESS); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
temp_rev++;
SRAM_Write_Byte(0xFF,SRAM_IAP_UPGRADE_Reply_NUM_ADDRESS);
}
return ;
}
}
Dbg_Println(DBG_BIT_NET_STATUS_bit,"UDPע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><EFBFBD><EFBFBD>");

View File

@@ -40,6 +40,8 @@
#define In_Power_Change_Cmd 0x35 //ȡ<><C8A1>״̬<D7B4>ϱ<EFBFBD> 2025-09-25 <20><><EFBFBD><EFBFBD>
#define In_DevState_Cmd 0x36 //<2F>豸״̬<D7B4>ϱ<EFBFBD> 2025-09-25 <20><><EFBFBD><EFBFBD>
#define In_Cloud_IAP_Cmd 0x68 //<2F>ƶ<EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define In_SeriaNet_Cmd 0x70 //͸<><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>
#define In_SeriaNetReported_Cmd 0x71 //͸<><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
@@ -75,6 +77,12 @@
#define UDP_ActSend_TimeSync_Flag 0x20 //UDP<44><50><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> - ʱ<><CAB1>ͬ<EFBFBD><CDAC> <20><>־λ
#define UDP_ActSend_Heart_Flag 0x40 //UDP<44><50><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>־λ
#define IAPPlan_State_Starting 0x01 //<2F><><EFBFBD><EFBFBD>״̬ - <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define IAPPlan_State_Underway 0x02 //<2F><><EFBFBD><EFBFBD>״̬ - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define IAPPlan_State_Checking 0x03 //<2F><><EFBFBD><EFBFBD>״̬ - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>
#define IAPPlan_State_CheckSucc 0x04 //<2F><><EFBFBD><EFBFBD>״̬ - У<><D0A3><EFBFBD>ɹ<EFBFBD>,RCU<43><55><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define IAPPlan_State_IAPTimeout 0x05 //<2F><><EFBFBD><EFBFBD>״̬ - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
#define USER_NET_Register_Timeout 30 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>ʱ,<2C><>λ<EFBFBD><CEBB>S
#define USER_NET_Send_Timeout 20 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵȴ<DDB5><C8B4>ظ<EFBFBD>ʱ<EFBFBD><CAB1>,<2C><>λ<EFBFBD><CEBB>S
#define USER_NET_Register_Times 10 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
@@ -96,8 +104,15 @@ uint8_t Udp_Internal_SeriaNet_Uploading(uint8_t port,uint32_t baud,uint32_t data
uint8_t Udp_Internal_SeriaNet_Uploading2(uint8_t port,uint32_t baud,uint8_t* data, uint16_t DataLen);
uint8_t Udp_Internal_SeriaNet_Response_Timeout(void);
uint8_t UDP_BLVIAPPlan_Cmd_SendPack(uint8_t iap_state);
uint8_t UDP_ReplyIAP_SendPack(void);
uint8_t UDP_ReplyCloudIAP_SendPack(void);
void Udp_Internal_Analysis(uint8_t *data, uint32_t len, uint8_t* ip, uint16_t port);
void BLV_UDP_Comm_Task(void);
#endif /* MCU_DRIVER_INC_BLV_NETCOMM_FUNCTION_H_ */

View File

@@ -20,9 +20,11 @@
#define SPIFLASH_APP_FEATURE_Addr 0x00000000 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - 512Byte
#define SPIFLASH_UPDATE_RECORD_Addr 0x00000200 //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>ַ - 512Byte
#define SPIFLASH_UPDATE_FLAG_Addr 0x00000200 //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>ַ - 512Byte
#define SPIFLASH_UPDATE_RECORD_Addr 0x00000400 //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>ַ
#define SPIFLASH_APP_Data_Start_Addr 0x00004000
#define SPIFLASH_APP_Data_Start_Addr 0x00001000
#define SPIFLASH_APP_Data_End_Addr 0x0006FFFF
#define SPIFLASH_APP_End_Addr 0x0006FFFF

View File

@@ -19,13 +19,13 @@
#define App_Procedure_Not_Ready 0x44 //Appδ׼<CEB4><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
//MCU Flash Address range(0x0 -- 0x6FFFF) Size(448K)
#define MCU_APP_Flash_Start_Addr 0x00007000 //MCU Flash<73><68>APP<50><50><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define MCU_APP_Data_Start_Addr 0x00007000 //MCU Flash APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define MCU_APP_Data_End_Addr 0x00027DFF //MCU Flash APP<50><50><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD>ַ
#define MCU_APP_Feature_Addr 0x00027E00 //MCU Flash <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD>ַ
#define MCU_APP_Flash_End_Addr 0x00027FFF //MCU Flash<73><68>APP<50>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>ַ
#define MCU_APP_Flash_Start_Addr 0x00001000 //MCU Flash<73><68>APP<50><50><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define MCU_APP_Data_Start_Addr 0x00001000 //MCU Flash APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define MCU_APP_Data_End_Addr 0x00067DFF //MCU Flash APP<50><50><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD>ַ
#define MCU_APP_Feature_Addr 0x00067E00 //MCU Flash <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD>ַ
#define MCU_APP_Flash_End_Addr 0x00067FFF //MCU Flash<73><68>APP<50>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>ַ
#define MCU_APP_Feature_PageAddr 0x00027000 //MCU APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ҳ<EFBFBD>ĵ<EFBFBD>ַ
#define MCU_APP_Feature_PageAddr 0x00067000 //MCU APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ҳ<EFBFBD>ĵ<EFBFBD>ַ
#define MCU_APP_Feature_PageOffset 0x00000E00 //MCU APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
#define APP_FEATURE_SIZE 0x0200 //512Byte

View File

@@ -116,7 +116,8 @@
/*<2A><>¼Launcher<65><EFBFBD><E6B1BE>Ϣ <20><>С<EFBFBD><D0A1>0x20 2025-07-07*/
#define SRAM_Launcher_SoftwareVer_Addr 0x0000E800
/*Launcherʹ<72><CAB9> <20><><EFBFBD>ڼ<EFBFBD>¼APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3> <20><>С:0x10 2026-01-14*/
#define SRAM_APP_Write_Count_Addr 0x0000E900
/**********SRAM Uart<72><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><>ʼ**********/
#define SRAM_Uart_Buffer_Size 0x0400 //<2F><><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С
@@ -170,19 +171,9 @@
#define SRAM_VCard_Property_Start_Addr 0x0004D000 //<2F>޿<EFBFBD>ȡ<EFBFBD><C8A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ʼ<EFBFBD><CABC>ַ <20><><EFBFBD><EFBFBD> һ<><D2BB>1K
#define SRAM_VCard_Property_End_Addr 0x0004D3FF //<2F>޿<EFBFBD>ȡ<EFBFBD><C8A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ <20><><EFBFBD><EFBFBD>
/**********SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2>ַ <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><>ʼ**********/
#define SRAM_IAP_APP_FILE_ADDRESS 0x00050000 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>APP<50>ļ<EFBFBD><C4BC>ĵ<EFBFBD>ַ - 218K
#define SRAM_IAP_IP_ADDRESS 0x0008E600 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>IP - 4Byte <20><>ʱ<EFBFBD><CAB1>UDP<44><50>ַ<EFBFBD><D6B7><EFBFBD>ſռ<D5BC><E4A3AC><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>UDP<44><50>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>
#define SRAM_IAP_PORT_ADDRESS 0x0008E604 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>port - 2Byte <20><>ʱ<EFBFBD><CAB1>UDP<44><50>ַ<EFBFBD><D6B7><EFBFBD>ſռ<D5BC><E4A3AC><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>UDP<44><50>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>
#define SRAM_IAP_NET_UPGRADE_Flag_ADDRESS 0x0008E606 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ - 1Byte
#define SRAM_IAP_UPGRADE_Reply_NUM_ADDRESS 0x0008E607 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>APP<50><50>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD> - 1Byte
/**********SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2>ַ <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><><EFBFBD><EFBFBD>**********/
/**********<2A><>Ŀӳ<C4BF><D3B3><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><>ʼ**********/
#define SRAM_Register_Start_ADDRESS 0x0008E900
#define SRAM_Register_End_ADDRESS 0x0008EFFF
#define SRAM_Register_Start_ADDRESS 0x0004E000
#define SRAM_Register_End_ADDRESS 0x0004EFFF
#define Register_OFFSET_LEN 0x0400 //<2F><>ǰ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ռ<D5BC><E4B3A4> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><E2B3A4>ҲӦ<D2B2>ñ仯
//<2F><>Ŀ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ƫ<EFBFBD>Ƶ<EFBFBD>ַ
@@ -222,29 +213,39 @@
#define Register_TFTPDmName_OFFSET 0x0185 //TFTP<54><50>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - 64Byte
/**********<2A><>Ŀӳ<C4BF><D3B3><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><><EFBFBD><EFBFBD>**********/
/**********SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2>ַ <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><>ʼ**********/
#define SRAM_IAP_APP_FILE_ADDRESS 0x00100000 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>APP<50>ļ<EFBFBD> <20><>ʼ<EFBFBD><CABC>ַ - 412K
#define SRAM_IAP_APP_FILE_End_ADDRESS 0x00167FFF //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>APP<50>ļ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
#define SRAM_IAP_IP_ADDRESS 0x00168000 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>IP - 4Byte <20><>ʱ<EFBFBD><CAB1>UDP<44><50>ַ<EFBFBD><D6B7><EFBFBD>ſռ<D5BC><E4A3AC><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>UDP<44><50>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>
#define SRAM_IAP_PORT_ADDRESS 0x00168004 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>port - 2Byte <20><>ʱ<EFBFBD><CAB1>UDP<44><50>ַ<EFBFBD><D6B7><EFBFBD>ſռ<D5BC><E4A3AC><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>UDP<44><50>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>
#define SRAM_IAP_NET_UPGRADE_Flag_ADDRESS 0x00168006 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ - 1Byte
#define SRAM_IAP_UPGRADE_Reply_NUM_ADDRESS 0x00168007 //SRAM<41>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8>ķ<EFBFBD><C4B7>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>APP<50><50>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD> - 1Byte
#define SRAM_IAP_IAP_Reset_Flag_ADDRESS 0x00168008 //SRAM<41>д<EFBFBD><D0B4>ž<EFBFBD><C5BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ󣬸<C9BA>λ<EFBFBD><CEBB>־λ
/**********SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2>ַ <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><><EFBFBD><EFBFBD>**********/
/**********SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>·<EFBFBD> <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><>ʼ**********/
#define SRAM_IAP_LOGIC_FILE_ADDRESS 0x00090000 //SRAM<41><4D><EFBFBD>߼<EFBFBD><DFBC>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
#define SRAM_IAP_LOGIC_FILE_ADDRESS 0x00190000 //SRAM<41><4D><EFBFBD>߼<EFBFBD><DFBC>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
#define SRAM_IAP_LOGIC_DataFlag_ADDRESS 0x00090000 //<2F>ļ<EFBFBD><C4BC><EFBFBD>־λ - 4Byte
#define SRAM_IAP_LOGIC_DataSize_ADDRESS 0x00090004 //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> - 4Byte
#define SRAM_IAP_LOGIC_DataMD5_ADDRESS 0x00090008 //<2F>ļ<EFBFBD>MD5У<35><D0A3>ֵ - 16Byte
#define SRAM_IAP_LOGIC_DataFlag_ADDRESS 0x00190000 //<2F>ļ<EFBFBD><C4BC><EFBFBD>־λ - 4Byte
#define SRAM_IAP_LOGIC_DataSize_ADDRESS 0x00190004 //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> - 4Byte
#define SRAM_IAP_LOGIC_DataMD5_ADDRESS 0x00190008 //<2F>ļ<EFBFBD>MD5У<35><D0A3>ֵ - 16Byte
#define SRAM_IAP_LOGIC_DataStart_ADDRESS 0x00090200
#define SRAM_IAP_LOGIC_DataEnd_ADDRESS 0x000FFFFF
#define SRAM_IAP_LOGIC_DataStart_ADDRESS 0x00190200
#define SRAM_IAP_LOGIC_DataEnd_ADDRESS 0x001FFFFF
/**********SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>·<EFBFBD> <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> - <20><><EFBFBD><EFBFBD>**********/
#define SRAM_DevAction_List_Size 0x0400 //ÿ<><C3BF><EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>С - <20><>ǰ<EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
#define SRAM_DevAction_List_Num 950
#define SRAM_DevAction_List_Start_Addr 0x00100000 //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ <20><><EFBFBD><EFBFBD> һ<><D2BB>960K
#define SRAM_DevAction_List_End_Addr 0x001EFFFF //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SRAM_BlwMap_List_Start_Addr 0x001F0000 //ӳ<><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ <20><><EFBFBD><EFBFBD> һ<><D2BB>32K
#define SRAM_BlwMap_List_End_Addr 0x001F7FFF //ӳ<><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SRAM_DevDly_List_Start_Addr 0x001F8000 //<2F><>ʱ<EFBFBD><EFBFBD><E8B1B8>ʼ<EFBFBD><CABC>ַ һ<><D2BB>32K
#define SRAM_DevDly_List_End_Addr 0x001FFFFF //<2F><>ʱ<EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
#define SRAM_DevAction_List_Start_Addr 0x00200000 //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ <20><><EFBFBD><EFBFBD> һ<><D2BB>960K
#define SRAM_DevAction_List_End_Addr 0x002EFFFF //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SRAM_BlwMap_List_Start_Addr 0x002F0000 //ӳ<><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ <20><><EFBFBD><EFBFBD> һ<><D2BB>32K
#define SRAM_BlwMap_List_End_Addr 0x002F7FFF //ӳ<><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SRAM_DevDly_List_Start_Addr 0x002F8000 //<2F><>ʱ<EFBFBD><EFBFBD><E8B1B8>ʼ<EFBFBD><CABC>ַ һ<><D2BB>32K
#define SRAM_DevDly_List_End_Addr 0x002FFFFF //<2F><>ʱ<EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ

View File

@@ -8,6 +8,9 @@
#ifndef MCU_DRIVER_INC_WATCHDOG_H_
#define MCU_DRIVER_INC_WATCHDOG_H_
#include <stdint.h>
#include "ch564.h"
void WDT_Init(void);
void WDT_Feed(void);
void WDT_Reinit(void);

View File

@@ -7,6 +7,7 @@
#include "spi_flash.h"
#include "debug.h"
#include "watchdog.h"
uint8_t Temp_Flash_Buff[4100]; //FLash д<><EFBFBD><EBBBBA>BUFF
@@ -493,12 +494,22 @@ __attribute__((section(".non_0_wait"))) void Flash_Write(uint8_t* pBuffer,uint16
/*******************************************************************************
* Function Name : SPI_FLASH_APP_Data_Erase
* Description : <20>ⲿFlash APP<50>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>
* APP<50>ռ<EFBFBD><D5BC><EFBFBD>С Size: 0x00070000 <20><>ַ<EFBFBD><D6B7>Χ<EFBFBD><CEA7>0x00000000 ~ 0x0006FFFF
* APP<50>ռ<EFBFBD><D5BC><EFBFBD>С Size: 0x00070000 <20><>ַ<EFBFBD><D6B7>Χ<EFBFBD><CEA7>0x00001000 ~ 0x0006FFFF
*******************************************************************************/
__attribute__((section(".non_0_wait"))) void SPI_FLASH_APP_Data_Erase(void)
{
for(uint8_t i = 0;i < 7;i++)
Flash_Erase_Page(0); //<2F><><EFBFBD><EFBFBD>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(uint8_t i = 1;i < 16;i++)
{
WDT_Feed();
Flash_Erase_Sector(i);
}
for(uint8_t i = 1;i < 7;i++)
{
WDT_Feed();
Flash_Erase_Block(i);
}
}

View File

@@ -22,7 +22,8 @@ void TIMER0_Init(void)
volatile uint32_t Time0_100us = 0;
volatile uint32_t Time0_1ms = 0;
void __attribute__((interrupt("WCH-Interrupt-fast"))) TIM0_IRQHandler()
void TIM0_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM0_IRQHandler(void)
{
static uint8_t NUM_1 = 0;

View File

@@ -455,7 +455,7 @@ __attribute__((section(".non_0_wait"))) uint8_t UART1_ChangeBaud(uint32_t baudra
while(1)
{
if( UART0_GetLinSTA() & RB_LSR_TX_ALL_EMP )
if( UART1_GetLinSTA() & RB_LSR_TX_ALL_EMP )
{
/*<2A><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>*/
__disable_irq();
@@ -503,7 +503,7 @@ __attribute__((section(".non_0_wait"))) uint8_t UART2_ChangeBaud(uint32_t baudra
while(1)
{
if( UART0_GetLinSTA() & RB_LSR_TX_ALL_EMP )
if( UART2_GetLinSTA() & RB_LSR_TX_ALL_EMP )
{
/*<2A><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>*/
__disable_irq();
@@ -551,7 +551,7 @@ __attribute__((section(".non_0_wait"))) uint8_t UART3_ChangeBaud(uint32_t baudra
while(1)
{
if( UART0_GetLinSTA() & RB_LSR_TX_ALL_EMP )
if( UART3_GetLinSTA() & RB_LSR_TX_ALL_EMP )
{
/*<2A><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>*/
__disable_irq();

View File

@@ -8,14 +8,14 @@
/*******************************************************************************
* Function Name : WDT_Init
* Description : <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʼ<EFBFBD><CABC> <20><><EFBFBD>Ź<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ4ms<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* Description : <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʼ<EFBFBD><CABC> <20><><EFBFBD><EFBFBD>100MHz <20><>ƵԼΪ84ms
* Input : None
* Return : None
*******************************************************************************/
__attribute__((section(".non_0_wait"))) void WDT_Init(void)
{
// WWDG_ResetCfg(ENABLE);
// WWDG_SetCounter(WDT_NUM);
FEED_DOG();
WDOG_ENABLE();
}
/*******************************************************************************
@@ -26,17 +26,14 @@ __attribute__((section(".non_0_wait"))) void WDT_Init(void)
*******************************************************************************/
__attribute__((section(".non_0_wait"))) void WDT_Feed(void)
{
//WWDG_ClearFlag();
// WWDG_SetCounter(WDT_NUM);
FEED_DOG();
}
/*******************************************************************************
* Function Name : WDT_Reinit
* Description : <20><><EFBFBD>Ź<EFBFBD>ȥ<EFBFBD><C8A5>ʼ<EFBFBD><CABC> <20><><EFBFBD>Ź<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ϊ4ms<6D><73><EFBFBD><EFBFBD>
* Input : None
* Return : None
* Description : <20><><EFBFBD>Ź<EFBFBD>ȥ<EFBFBD><C8A5>ʼ<EFBFBD><CABC>
*******************************************************************************/
__attribute__((section(".non_0_wait"))) void WDT_Reinit(void)
{
WDOG_DISABLE();
}

View File

@@ -601,12 +601,12 @@ __attribute__((section(".non_0_wait"))) void NetWork_Parameter_Get(void)
//MCU<43><55>ʼ<EFBFBD><CABC>IP
g_netinfo.device_ip[0] = 192;
g_netinfo.device_ip[1] = 168;
g_netinfo.device_ip[2] = MACAddr[4];
g_netinfo.device_ip[3] = MACAddr[5];
g_netinfo.device_ip[2] = g_netinfo.mac_addr[4];
g_netinfo.device_ip[3] = g_netinfo.mac_addr[5];
//MCU<43><55>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
g_netinfo.gateway[0] = 192;
g_netinfo.gateway[1] = 168;
g_netinfo.gateway[2] = MACAddr[4];
g_netinfo.gateway[2] = g_netinfo.mac_addr[4];
g_netinfo.gateway[3] = 1;
//MCU<43><55>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_netinfo.subnet[0] = 255;
@@ -775,9 +775,16 @@ __attribute__((section(".non_0_wait"))) uint8_t WCHNET_LIB_Init(void)
Dbg_Println(DBG_BIT_NET_STATUS_bit,"version error.\n");
}
/*<2A><>ȡMAC <20><>ַ*/
g_netinfo.mac_addr[2] = SRAM_Read_Byte(SRAM_Register_Start_ADDRESS + Register_NETMACKADDR_OFFSET );
g_netinfo.mac_addr[3] = SRAM_Read_Byte(SRAM_Register_Start_ADDRESS + Register_NETMACKADDR_OFFSET + 1);
g_netinfo.mac_addr[4] = SRAM_Read_Byte(SRAM_Register_Start_ADDRESS + Register_NETMACKADDR_OFFSET + 2);
g_netinfo.mac_addr[5] = SRAM_Read_Byte(SRAM_Register_Start_ADDRESS + Register_NETMACKADDR_OFFSET + 3);
//<2F><>ȡоƬ<D0BE>Դ<EFBFBD><D4B4><EFBFBD>MAC <20><>ַ
// GetMACAddress(MACAddr);
// Dbg_Print_Buff(DBG_BIT_NET_STATUS_bit, "NET MAC:", MACAddr, 6);
Dbg_Print_Buff(DBG_BIT_NET_STATUS_bit, "NET MAC:", g_netinfo.mac_addr, 6);
NetWork_Parameter_Get();
@@ -814,6 +821,8 @@ __attribute__((section(".non_0_wait"))) uint8_t WCHNET_LIB_Init(void)
server_info.net_sta = NET_PHY_WAIT;
SRAM_Write_Byte(0x00,SRAM_IAP_UPGRADE_Reply_NUM_ADDRESS);
return 0;
}

View File

@@ -6,6 +6,7 @@
*/
#include "tftp_function.h"
#include "net_function.h"
#include "blv_netcomm_function.h"
#include "sram_mem_addr.h"
#include "flash_mem_addr.h"
#include "spi_flash.h"
@@ -125,9 +126,9 @@ __attribute__((section(".non_0_wait"))) uint8_t IAP_tftp_process_write(uint8_t s
memcpy(&tftp_args.to_ip[0],to_ip,4);
tftp_args.to_port = to_port;
tftp_args.block = 0;
tftp_args.tot_bytes = 0;
IAPVarTypeStruct_Ptr.Write_Block = 0;
IAPVarTypeStruct_Ptr.TotalCount = 0;
IAPVarTypeStruct_Ptr.IapErrFlag = 0;
Dbg_Println(DBG_BIT_NET_STATUS_bit,"ip:%d.%d.%d.%d, port:%d",to_ip[0], to_ip[1], to_ip[2], to_ip[3], to_port);
@@ -147,7 +148,55 @@ __attribute__((section(".non_0_wait"))) uint8_t IAP_tftp_process_write(uint8_t s
return 0x01;
}
TFTP_send_ack_packet(g_netinfo.SocketId[SocketIdnex_TFTPDATA], to_ip, to_port, tftp_args.block); //ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD>
TFTP_send_ack_packet(g_netinfo.SocketId[SocketIdnex_TFTPDATA], to_ip, to_port, IAPVarTypeStruct_Ptr.Write_Block); //ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD>
return 0x00;
}
/*******************************************************************************
* Function Name : IAP_tftp_process_read
* Description : TFTP<54><50><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD> - <20><><EFBFBD>Ͷ<EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>
*******************************************************************************/
uint8_t IAP_tftp_process_read(uint8_t s, uint8_t* to_ip, int to_port)
{
uint8_t data_buffer[150];
uint32_t sendlen = 0;
memset(data_buffer,0,sizeof(data_buffer));
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s",__func__);
IAPVarTypeStruct_Ptr.TotalCount = 0x00;
IAPVarTypeStruct_Ptr.IapErrFlag = 0x00;
if(IAPVarTypeStruct_Ptr.IapFileType == TFTP_IAP_DataType_APP)
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ");
IAPVarTypeStruct_Ptr.FlashWriteAddress = SRAM_IAP_APP_FILE_ADDRESS; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ַ - <20><><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD>SRAM<41><4D>
}else if(IAPVarTypeStruct_Ptr.IapFileType == TFTP_IAP_DataType_CONFIG)
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ");
IAPVarTypeStruct_Ptr.FlashWriteAddress = SRAM_IAP_LOGIC_DataStart_ADDRESS; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ַ - <20><><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD>SRAM<41><4D>
}else{
return 1;
}
data_buffer[0] = 0x00;
data_buffer[1] = 0x01;
memcpy(&data_buffer[2], IAPVarTypeStruct_Ptr.FtpFileName, IAPVarTypeStruct_Ptr.FtpFileNameLen); //<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ȥ<EFBFBD><C8A5>ȡ<EFBFBD>ļ<EFBFBD> <20>ܳ<EFBFBD><DCB3><EFBFBD>
sendlen += IAPVarTypeStruct_Ptr.FtpFileNameLen+2;
data_buffer[sendlen++] = 0;
data_buffer[sendlen++] = 'o'; //octet <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׼ʹ<D7BC>ð<EFBFBD>λ<EFBFBD><CEBB>
data_buffer[sendlen++] = 'c';
data_buffer[sendlen++] = 't';
data_buffer[sendlen++] = 'e';
data_buffer[sendlen++] = 't';
data_buffer[sendlen++] = 0;
Dbg_Println(DBG_BIT_NET_STATUS_bit,"FtpFileNameLen:%d , name:%s",IAPVarTypeStruct_Ptr.FtpFileNameLen,IAPVarTypeStruct_Ptr.FtpFileName);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"SocketId:%d , port:%d , len:%d , IP:%d.%d.%d.%d",s,to_port,sendlen,to_ip[0],to_ip[1],to_ip[2],to_ip[3]);
WCHNET_SocketUdpSendTo(s, data_buffer, &sendlen, to_ip, to_port);
return 0x00;
}
@@ -171,6 +220,11 @@ __attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s,
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s block:%d - %d",__func__,IAPVarTypeStruct_Ptr.Write_Block,TFTP_Pack_Get_Block(pkt_buf));
if( pkt_buf_len > TFTP_DATA_LEN_MAX ) {
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s Data_len:%d Error",__func__,pkt_buf_len);
return ;
}
if( (pkt_buf_len > TFTP_DATA_PKT_HDR_LEN) && ( TFTP_Pack_Get_Block(pkt_buf) == (IAPVarTypeStruct_Ptr.Write_Block + 1) ) )
{
pkt_buf_len = pkt_buf_len - TFTP_DATA_PKT_HDR_LEN;
@@ -189,7 +243,7 @@ __attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s,
if( IAPVarTypeStruct_Ptr.Write_Block == 0x00 )
{
temp_val = data_buffer[0] + (data_buffer[1]<<8) + (data_buffer[2]<<16) + (data_buffer[3]<<24);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"temp_var : %08X ,block :%d",temp_val,IAPVarTypeStruct_Ptr.Write_Block);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"temp_var : %X ,block :%d",temp_val,IAPVarTypeStruct_Ptr.Write_Block);
if( (temp_val & 0x2FFE0000) != 0x20000000 )
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>");
@@ -208,7 +262,7 @@ __attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s,
// break;
// }
IAPVarTypeStruct_Ptr.IapErrFlag = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE>һ
//IAPVarTypeStruct_Ptr.IapErrFlag = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE>һ
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> data_buffer[0] & 0x2FFE0000 = %X; data_buffer[1]=%X\n", (data_buffer[0] & 0x2FFE0000), data_buffer[1]);
}else if( IAPVarTypeStruct_Ptr.Write_Block > APP_BLOCK_MAX ){
@@ -253,7 +307,7 @@ __attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s,
{
IAPVarTypeStruct_Ptr.Write_Block++;
SRAM_DMA_Write_Buff(data_buffer,pkt_buf_len,IAPVarTypeStruct_Ptr.FlashWriteAddress); //д<><D0B4>SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Dbg_Println(DBG_BIT_NET_STATUS_bit,"д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>%08X,д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: byte<74><65>%d", IAPVarTypeStruct_Ptr.FlashWriteAddress, pkt_buf_len);
Dbg_Println(DBG_BIT_NET_STATUS_bit,"д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>%X,д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: byte<74><65>%d", IAPVarTypeStruct_Ptr.FlashWriteAddress, pkt_buf_len);
/*<2A>Գ<EFBFBD><D4B3>Ƚ<EFBFBD><C8BD><EFBFBD>4Byte<74><65><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ַƫ<D6B7><C6AB>ʹ<EFBFBD><CAB9> <20><><EFBFBD><EFBFBD><E8B2BB>Ҫ<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB>Ҫ*/
// pkt_buf_len = (pkt_buf_len + 3) / 4;
@@ -268,7 +322,16 @@ __attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s,
TFTP_send_ack_packet(s, ip_addr, Port, IAPVarTypeStruct_Ptr.Write_Block); //<2F><>ÿ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0>Ļظ<C4BB><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD> <20><>ַ <20>˿ںͿ<DABA><CDBF><EFBFBD>
if( IAPVarTypeStruct_Ptr.Write_Block == IAPVarTypeStruct_Ptr.BlockSize )
if( (IAPVarTypeStruct_Ptr.BLVIapFlag != 0x01)
&& (IAPVarTypeStruct_Ptr.Write_Block != 0x00)
&& (IAPVarTypeStruct_Ptr.Write_Block % 50 == 0x00)
&& (IAPVarTypeStruct_Ptr.BlockSize != IAPVarTypeStruct_Ptr.Write_Block) )
{
/* <20><><EFBFBD>ƶ˷<C6B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
UDP_BLVIAPPlan_Cmd_SendPack(IAPPlan_State_Underway); //<2F><><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>
}
if( (IAPVarTypeStruct_Ptr.BLVIapFlag != 0x01) && (IAPVarTypeStruct_Ptr.Write_Block == IAPVarTypeStruct_Ptr.BlockSize) )
{
uint8_t md5[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
uint16_t crc_data_len = 0;
@@ -283,23 +346,17 @@ __attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s,
{
//<2F>ļ<EFBFBD>MD5У<35><D0A3><EFBFBD>ɹ<EFBFBD>
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>Md5<EFBFBD><EFBFBD>ȷ");
//Ϊɶ<CEAA><C9B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ˻ظ<CBBB><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>һ<EFBFBD><D2BB>
// switch(IAPVarTypeStruct_Ptr->IapType)
// {
// case IAPTFTPWRITE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"<22><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
// SRAM_Write_Byte(IAP_STATE_COMPLETE, SRAM_IAP_NET_UPGRADE_Flag_ADDRESS);
// LOG_LogicInfo_DebugRecord("<22><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
// break;
// case IAPTFTPREAD: //<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"<22><>¼<EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
// LOG_LogicInfo_DebugRecord("<22><>¼<EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
// SRAM_Write_Byte(CLOUD_IAP_TFTP_STATE_COMPLETE, SRAM_IAP_NET_UPGRADE_Flag_ADDRESS);
// break;
// }
if( IAPVarTypeStruct_Ptr.FunType == TFTP_FUNTYPE_CloudIAP )
{
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD>¼<EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
LOG_LogicInfo_DebugRecord("<EFBFBD><EFBFBD>¼<EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
SRAM_Write_Byte(TFTP_FUNTYPE_CloudIAP, SRAM_IAP_NET_UPGRADE_Flag_ADDRESS);
}
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD>APPд<EFBFBD><EFBFBD>Flash<EFBFBD><EFBFBD>..");
//Cloud_IAP_Plan_SendPack(args,IAPVarTypeStruct_Ptr,IAPPlan_State_CheckSucc); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UDP_BLVIAPPlan_Cmd_SendPack(IAPPlan_State_CheckSucc); //<2F><><EFBFBD><EFBFBD>IAP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - У<EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SPI_FLASH_APP_Data_Erase();
for(uint32_t i = 0;i < IAPVarTypeStruct_Ptr.BlockSize; i++ )
@@ -358,6 +415,8 @@ __attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s,
Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"<EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ!");
//ֱ<>ӿ<EFBFBD><D3BF>Ź<EFBFBD><C5B9><EFBFBD>λ
NVIC_SystemReset();
while(1);
}else{
//MD5У<35><D0A3>ʧ<EFBFBD><CAA7>
@@ -401,7 +460,7 @@ __attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s,
// break;
// }
//Cloud_IAP_Plan_SendPack(args,IAPVarTypeStruct_Ptr,IAPPlan_State_CheckSucc); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UDP_BLVIAPPlan_Cmd_SendPack(IAPPlan_State_CheckSucc); //<2F><><EFBFBD><EFBFBD>IAP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - У<EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SPI_FLASH_Logic_File_Erase(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -495,6 +554,11 @@ void UDPSocket_TFTP_CMD_AppCallBack(struct _SOCK_INF * SocketInf,uint32_t ipaddr
/*TFTP<54><50><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
}else if( TFTP_Pack_Get_Opcode(buff) == TFTP_DATA )
{
/*TFTP<54><50><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
}else {
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>*/
@@ -527,6 +591,8 @@ void UDPSocket_TFTP_DATA_AppCallBack(struct _SOCK_INF * SocketInf,uint32_t ipadd
// }
}
/*******************************************************************************
* Function Name : Internal_TFTP_Task
* Description : TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -563,14 +629,25 @@ __attribute__((section(".non_0_wait"))) void Internal_TFTP_Task(void)
{
IAPVarTypeStruct_Ptr.processing_tick = SysTick_1ms;
IAPVarTypeStruct_Ptr.status = STA_INIT_IDLE;
if(IAPVarTypeStruct_Ptr.FunType == TFTP_FUNTYPE_CloudIAP)
{
//<2F><><EFBFBD>ƶ˷<C6B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
//TFTP_CMD_ACK(server_info.goal_ip, server_info.goal_port); //<2F>ظ<EFBFBD>TFTP<54><50><EFBFBD><EFBFBD>
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD>ƶ˷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>...");
IAP_tftp_process_read(g_netinfo.SocketId[SocketIdnex_TFTPDATA], server_info.goal_ip, IAPVarTypeStruct_Ptr.TFTP_Port);
}
}
break;
case STA_INIT_IDLE:
//<2F><><EFBFBD>ƶ˷<C6B6><CBB7>Ͷ<EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
if( SysTick_1ms - IAPVarTypeStruct_Ptr.processing_tick > 30000) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ͷ<EFBFBD><CDB7>׽<EFBFBD><D7BD><EFBFBD>
if( SysTick_1ms - IAPVarTypeStruct_Ptr.processing_tick > 60000 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ͷ<EFBFBD><CDB7>׽<EFBFBD><D7BD><EFBFBD>
{
//Cloud_IAP_Plan_SendPack(tftp_args,IAPVarTypeStruct_Ptr,IAPPlan_State_IAPTimeout); //<2F><><EFBFBD><EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
UDP_BLVIAPPlan_Cmd_SendPack(IAPPlan_State_IAPTimeout); //<2F><><EFBFBD><EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
Dbg_Println(DBG_BIT_NET_STATUS_bit,"TFTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ");
IAPVarTypeStruct_Ptr.status = STA_END;
@@ -626,6 +703,7 @@ __attribute__((section(".non_0_wait"))) void Internal_TFTP_Task(void)
}
break;
case STA_INIT_CONNECT: //
break;
}
}

View File

@@ -61,7 +61,8 @@ typedef struct
uint8_t enable; //TFTP <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>״̬ 0X01:ʹ<>ܣ<EFBFBD>0x00:ûʹ<C3BB><CAB9>
uint8_t FunType; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x01:<3A><><EFBFBD><EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x02:<3A>ƶ<EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x03:LOG<4F><47>־<EFBFBD>ϴ<EFBFBD>
uint8_t NewIapFlag; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̱<EFBFBD>־λ - 2022-01-05
uint8_t BLVIapFlag; //BLV<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̱<EFBFBD>־λ
uint8_t BLVIapResult; //BLV<4C><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uint8_t IapErrFlag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
@@ -105,7 +106,9 @@ typedef struct
}tftp_connection_args;
extern IAPVarTypeStruct IAPVarTypeStruct_Ptr;
extern tftp_connection_args tftp_args;
uint8_t bytes_cmp(uint8_t *src,uint8_t *dat,uint32_t len);
void Internal_TFTP_Task(void);
#endif /* NETLIB_TFTP_FUNCTION_H_ */

View File

@@ -100,7 +100,7 @@ extern "C"
}
#define RCC_GET_GLOB_RST_KEEP() (R8_GLOB_RESET_KEEP)
#define RCC_SET_GLOB_RST_KEEP(val) (R8_GLOB_RESET_KEEP = (val);)
#define RCC_SET_GLOB_RST_KEEP(val) {R8_GLOB_RESET_KEEP = (val);}
#define RCC_SET_PLL_SYS_OUT_DIV(val) \
({ \
RCC_UNLOCK_SAFE_ACCESS(); \

132
Readme.md
View File

@@ -1,86 +1,94 @@
```C
1Launcher
2RS485主动端口增加避障功能RS485轮询端口与BUS端口是轮询机制
3BLV-C1P
4Launcher流程修改MCU Flash只在升级后写入MCU Flash
5
6APP固件中串口升级 -
7TFTP日志上传机制修改
1 -
2 -
3 -
4 -
遇到问题:
1、网络搜索主机 - 回复项目编码、房型、房号、房号ID、房型ID 、房态、不正确
2、网络搜索主机中服务器通讯端口在C1F中这个端口是固定为3341网络配置工具上使用的是这个字段进行的网络通讯下发字段。
问题点RCU主机 UDP套接字固定端口为3341而服务器端口为3339
```
#### 2026-01-08
### 2026-02-10
```C
1 - OK
2 - OK
3 - OK
```
### 2026-01-08
```C
1 - OK
2 - OK
3 - OK
```
### 2026-01-06
```C
1OK
```
### 2026-01-05
```C
1CSIO BUS设备列表中 -
2BUS总线通讯 - OK
3 - OK
4C5继电器设备
```
### 2025-12-25
```C
1TFTP升级 -
2
3TFTP升级 - 使
```
### 2025-12-10
```C
1TFTP IAP升级功能移植完毕
2
```
### 2025-12-06
```C
1 -
2TFTP功能
-> TFTP升级
-> TFTP日志文件传输
```
#### 2026-01-06
1、场景动作执行初步测试OK
#### 2026-01-05
1、CSIO 继电器单独一个设备存放在BUS设备列表中应该将这个设备存放到虚拟设备上 - 不合理的地方,待修改
2、调试BUS总线通讯 - OK
3、动作执行 - 网络控制继电器 OK
4、增加C5继电器设备
#### 2025-12-25
1、TFTP升级 - 配置文件初步测试没问题
2、配置文件内容解析移植完毕调试中
3、TFTP升级 - 是否一个套接字搞定,不需要使用两个套接字
#### 2025-12-10
1、TFTP IAP升级功能移植完毕待测试
2、优化代码编译的空间问题目前零等待区的空间已满需将除了库函数以外的代码及相关变量全部放置非零等待区中否则项目编译不成功
#### 2025-12-06
1. 动作执行函数初步实现完毕 - 待测试
2. 开始移植TFTP功能
1. TFTP升级
2. TFTP日志文件传输

View File

@@ -65,7 +65,8 @@
#define MCU_TYPE "BLV-C1F" //<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>
#define APP_NAME "App_L4_C1F_42" //APP<50><50><EFBFBD><EFBFBD> 16Byte
#define SoftwareVer "C1P_A_L4_01_251107" //<2F><><EFBFBD><EFBFBD><EFBFBD>汾 20Byte
#define SoftwareVer "C1P_A_L4_01_251109" //<2F><><EFBFBD><EFBFBD><EFBFBD>汾 20Byte

View File

@@ -14,6 +14,8 @@
#include <stdio.h>
#include <string.h>
uint32_t test_tick = 0;
uint8_t test_buff[10] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A};
@@ -30,6 +32,7 @@ int main(void)
SystemCoreClockUpdate();
Systick_Init();
WDT_Reinit();
UARTx_Init(UART_0,9600); //RS485<38><35>ѯ<EFBFBD>˿<EFBFBD>
UARTx_Init(UART_1,512000); //<2F><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
UARTx_Init(UART_2,9600); //RS485<38><35><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
@@ -41,6 +44,8 @@ int main(void)
SPI_FLASH_Init();
Read_Flash_Register_Data();
WCHNET_LIB_Init();
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU Start!! \r\n");
@@ -48,8 +53,8 @@ int main(void)
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"DEV_ACTION_INFO Size:%d \r\n",sizeof(DEV_ACTION_INFO));
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Dev_Action_U64Cond Size:%d \r\n",sizeof(Dev_Action_U64Cond));
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Struct_Dev_Dly Size:%d \r\n",sizeof(Struct_Dev_Dly));
// Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Dev_Action_U64Cond Size:%d \r\n",sizeof(Dev_Action_U64Cond));
// Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Struct_Dev_Dly Size:%d \r\n",sizeof(Struct_Dev_Dly));
BLV_DevAction_AllData_Init();

View File

@@ -12,7 +12,6 @@
#include "ch564.h"
#include "debug.h"
/*
* Uncomment the line corresponding to the desired System clock (SYSCLK)
* frequency (after reset the HSI is used as SYSCLK source).
@@ -88,23 +87,8 @@ static void SetSysClockTo25_HSE(void);
*/
void SystemInit(void)
{
if ( SystemCoreClock >= 60000000 )
{
RCC_UNLOCK_SAFE_ACCESS();
BITS_CFG( R32_EXTEN_CTLR0 , RB_FLASH_PRE_EN , ENABLE );
BITS_CFG( R32_EXTEN_CTLR0 , RB_SW_CFG , DISABLE );
RCC_LOCK_SAFE_ACCESS();
}
else
{
RCC_UNLOCK_SAFE_ACCESS();
BITS_CFG( R32_EXTEN_CTLR0 , RB_FLASH_PRE_EN , DISABLE );
BITS_CFG( R32_EXTEN_CTLR0 , RB_SW_CFG , DISABLE );
RCC_LOCK_SAFE_ACCESS();
}
SystemCoreClockUpdate();
//Delay_Init();
HSI_ON();
/* Close ETH PHY */
@@ -192,6 +176,7 @@ void SystemCoreClockUpdate(void)
static void SetSysClock(void)
{
SystemCoreClockUpdate();
//Delay_Init();
GPIO_IPD_Unused();
#ifdef SYSCLK_FREQ_120MHz_HSI
@@ -233,6 +218,10 @@ static void SetSysClockTo120_HSI(void)
USB_PLL_SOURCE_SELECT( USB_PLL_SOURCE_HSI );
USB_PLL_ON();
Delay_Us( PLL_STARTUP_TIME );
RCC_UNLOCK_SAFE_ACCESS();
BITS_CFG( R32_EXTEN_CTLR0 , RB_FLASH_PRE_EN , ENABLE );
BITS_CFG( R32_EXTEN_CTLR0 , RB_SW_CFG , DISABLE ); //<2F>ر<EFBFBD>SW<53><57><EFBFBD>Կ<EFBFBD>
RCC_LOCK_SAFE_ACCESS();
SYSCLK_SOURCE_SELECT( SYSCLK_SOURCE_USBPLL );
}
@@ -252,6 +241,10 @@ static void SetSysClockTo80_HSI(void)
USB_PLL_SOURCE_SELECT(USB_PLL_SOURCE_HSI);
USB_PLL_ON();
Delay_Us(PLL_STARTUP_TIME);
RCC_UNLOCK_SAFE_ACCESS();
BITS_CFG( R32_EXTEN_CTLR0 , RB_FLASH_PRE_EN , ENABLE );
BITS_CFG( R32_EXTEN_CTLR0 , RB_SW_CFG , DISABLE ); //<2F>ر<EFBFBD>SW<53><57><EFBFBD>Կ<EFBFBD>
RCC_LOCK_SAFE_ACCESS();
SYSCLK_SOURCE_SELECT(SYSCLK_SOURCE_USBPLL);
}
@@ -271,6 +264,10 @@ static void SetSysClockTo60_HSI(void)
USB_PLL_SOURCE_SELECT(USB_PLL_SOURCE_HSI);
USB_PLL_ON();
Delay_Us(PLL_STARTUP_TIME);
RCC_UNLOCK_SAFE_ACCESS();
BITS_CFG( R32_EXTEN_CTLR0 , RB_FLASH_PRE_EN , ENABLE );
BITS_CFG( R32_EXTEN_CTLR0 , RB_SW_CFG , DISABLE ); //<2F>ر<EFBFBD>SW<53><57><EFBFBD>Կ<EFBFBD>
RCC_LOCK_SAFE_ACCESS();
SYSCLK_SOURCE_SELECT(SYSCLK_SOURCE_USBPLL);
}
@@ -327,6 +324,10 @@ static void SetSysClockTo120_HSE(void)
USB_PLL_MUL_SELECT(USB_PLL_MUL_24);
USB_PLL_ON();
Delay_Us(PLL_STARTUP_TIME);
RCC_UNLOCK_SAFE_ACCESS();
BITS_CFG( R32_EXTEN_CTLR0 , RB_FLASH_PRE_EN , ENABLE );
BITS_CFG( R32_EXTEN_CTLR0 , RB_SW_CFG , DISABLE ); //<2F>ر<EFBFBD>SW<53><57><EFBFBD>Կ<EFBFBD>
RCC_LOCK_SAFE_ACCESS();
SYSCLK_SOURCE_SELECT(SYSCLK_SOURCE_USBPLL);
}
@@ -349,6 +350,10 @@ static void SetSysClockTo80_HSE(void)
USB_PLL_MUL_SELECT(USB_PLL_MUL_24);
USB_PLL_ON();
Delay_Us(PLL_STARTUP_TIME);
RCC_UNLOCK_SAFE_ACCESS();
BITS_CFG( R32_EXTEN_CTLR0 , RB_FLASH_PRE_EN , ENABLE );
BITS_CFG( R32_EXTEN_CTLR0 , RB_SW_CFG , DISABLE ); //<2F>ر<EFBFBD>SW<53><57><EFBFBD>Կ<EFBFBD>
RCC_LOCK_SAFE_ACCESS();
SYSCLK_SOURCE_SELECT(SYSCLK_SOURCE_USBPLL);
}
@@ -371,6 +376,10 @@ static void SetSysClockTo60_HSE(void)
USB_PLL_MUL_SELECT(USB_PLL_MUL_24);
USB_PLL_ON();
Delay_Us(PLL_STARTUP_TIME);
RCC_UNLOCK_SAFE_ACCESS();
BITS_CFG( R32_EXTEN_CTLR0 , RB_FLASH_PRE_EN , ENABLE );
BITS_CFG( R32_EXTEN_CTLR0 , RB_SW_CFG , DISABLE ); //<2F>ر<EFBFBD>SW<53><57><EFBFBD>Կ<EFBFBD>
RCC_LOCK_SAFE_ACCESS();
SYSCLK_SOURCE_SELECT(SYSCLK_SOURCE_USBPLL);
}