Files
HBshuiwuConcentrator/APP/update.h
2025-12-15 16:07:49 +08:00

148 lines
3.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef _UPDATE_H_
#define _UPDATE_H_
#include "Basedefine.h"
#define FLASH_API_ADDRESS 0x08000000
#define FLASH_MAINTAINTIME_ADDRESS 0x08003000
#define FLASH_KEY_ADDRESS 0x08003800
#define FLASH_UPDATE_PARAMS_ADDRESS 0x08004000
#define FLASH_LOCAL_ADDR_ADDRESS 0x08004c00 // ÔÚAPPµÄÇ°ÃæÒ»¸ö1KλÖÃ
#define FLASH_APP_ADDRESS 0x08005000
#define FLASH_APP_BACK_ADDRESS 0x08022800
#define FLASH_SLAVE_NODE_COUNT_ADDRESS 0x0803F800
#define FLASH_API_PAGES 8
#define FLASH_PARAMS_PAGES 2
#define FLASH_APP_PAGES 59
#define FLASH_APPL_BACK_PAGES 59
#define UPDATE_DEFAULT_PACKET_SIZE 128
#define FLASH_PAGE_SIZE 2048
typedef enum
{
UPDATE_END = 0,
UPDATE_RUNNING,
UPDATE_FINISH,
UPDATE_SUCCESS,
UPDATE_FAILED,
UPDATE_SALVE,
}EM_UPDATE_STATUS;
enum
{
UPDATE_NONE,
UPDATE_PLC,
UPDATE_485,
UPDATE_MAX,
};
#pragma pack(push)
#pragma pack(1)
typedef struct
{
u32 totalBytes;
u16 version;
u16 total_packets;
u16 current_packets;
u16 received_packets;
u8 status;
u8 packetsState[127];
u16 crc;
}st_update_params;
typedef struct
{
u8 file_indication;
u8 file_property;
u8 file_instr;
u16 total_packets;
u32 current_packet_No;
u16 packet_length;
u8 * data;
}st_update_packet;
typedef struct
{
u8 start;
u16 len;
u8 ctrl;
u8 info_route:1;
u8 info_slave:1;
u8 info_com_module:1;
u8 info_conflict:1;
u8 info_relay:4;
u8 info[4];
u8 number;
}st_13762_head;
typedef struct
{
st_13762_head head;
u8 afn;
u8 dt1;
u8 dt2;
u32 current_packet_No;
u8 cs;
u8 end;
}st_AFN15_ack;
typedef struct
{
u8 start;
u8 lenL;
u8 lenH;
u8 ctrl;
u8 info_route:1;
u8 info_slave:1;
u8 info_com_module:1;
u8 info_conflict:1;
u8 info_relay:4;
u8 info[4];
u8 number;
u8 *source_addr;
u8 *relay_addr;
u8 *desc_addr;
u8 AFN;
u8 DT1;
u8 DT2;
u8 *data;
u8 cs;
u8 end;
}st_13762;
typedef struct
{
st_13762_head head;
u8 AFN;
u8 DT1;
u8 DT2;
u8 Manu_code[2];
u8 chip_code[2];
u8 day;
u8 month;
u8 year;
u8 version;
u8 cs;
u8 end;
}st_13762_03F1_ack;
#pragma pack(pop)
void transparent_Proc(void);
void write_update_contrlner(u8 ctrlner);
void apl_process_1372(u8 * ptr1372, u8 ctrlner);
bool check_13762_packet(u8 *buf);
void create_update_task(void);
#endif