123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #ifndef __DEV_IAP_H
- #define __DEV_IAP_H
- #include "can_interface.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef __DEV_IAP_H_GLOBAL
- #define __DEV_IAP_H_EXTERN
- #else
- #define __DEV_IAP_H_EXTERN extern
- #endif
- /************************************************************************************************
- * Version *
- ************************************************************************************************/
- /************************************************************************************************
- * How to use *
- ************************************************************************************************/
- /************************************************************************************************
- * Enable config *
- ************************************************************************************************/
- /************************************************************************************************
- * Includes *
- ************************************************************************************************/
- #include "can_interface.h"
- #include <stdint.h>
- /************************************************************************************************
- * Defines *
- ************************************************************************************************/
- #define UPGRADE_FLAG_DATA_SIZE 4 // 升级参数数组元素个数
- #define UPGRADE_APP_DATA_SIZE 4 // 升级参数数组元素个数
- #define UPGRADE_BUFF_DATA_SIZE \
- (UPGRADE_FLAG_DATA_SIZE + UPGRADE_APP_DATA_SIZE) // 升级参数数组元素个数
- #define APP_START_ADDR ((uint32_t)0x08004000)
- #define APP_END_ADDR ((uint32_t)0x0801D000)
- #define UPGRADE_FLAG_START_ADDR ((uint32_t)0x0801D000)
- #define UPGRADE_FLAG_END_ADDR ((uint32_t)0x08027000)
- #define DOWNLOAD_START_ADDR ((uint32_t)0x08027000)
- #define DOWNLOAD_END_ADDR ((uint32_t)0x08040000)
- #define DOWNLOAD_MIDDLE_ADDR ((uint32_t)0x08033800)
- // 升级命令
- #define IAP_CMD_VERSION 0x71 // 查询版本号
- #define IAP_CMD_INFO 0x72 // 包信息
- #define IAP_CMD_ERASE 0x73 // 擦除命令
- #define IAP_CMD_DATA 0x80 // 数据帧 IAP_CMD_DATA |帧号
- #define IAP_CMD_CRC 0x74 // 传输结果校验
- #define IAP_CMD_JUMP 0x75 // 执行跳转
- #define IAP_CMD_JUMP_OVER 0x0175 // 执行跳转
- #define IAP_CMD_MODEL_TYPE 0x76 // 执行跳转
- #define UPGRADE_SIGN 0x5AA5
- #define DEVICE_ID 0x5AA5
- typedef union
- {
- uint16_t u8_buf[8];
- uint16_t u16_buf[4];
- } u16_u8;
- typedef union
- {
- uint16_t u8_save[200];
- uint16_t u16_save[100];
- } u16save_u8save;
- typedef struct
- {
- uint16_t total_packages;
- uint16_t current_packages;
- uint16_t count_packages;
- uint16_t recv_len;
- uint16_t crc16;
- uint16_t firmware_crc16;
- uint16_t firmware_ver;
- uint16_t total_bytes;
- uint16_t count_bytes;
- u16_u8 flash_data;
- u16_u8 recheck_data;
- u16save_u8save save_data;
- } iap_type;
- typedef union
- {
- struct
- {
- uint16_t sign; // 首地址 buf[0]
- uint16_t crc16; // 中地址 buf[1]
- uint32_t moving_size; // 高地址 buf[2] buf[3]
- } param;
- uint16_t infor_buf[UPGRADE_FLAG_DATA_SIZE];
- } upgrade_param; // 升级参数使用
- extern upgrade_param upgrade;
- void set_firmver(void);
- void iap_param_init(void);
- void iap_flag_release(void);
- uint8_t erase_app_flash(uint32_t start_address, uint32_t end_addr);
- void jump_boot_time_ctrl(void);
- void iap_rec_handler(pdu_tag rec_msg);
- /************************************************************************************************
- * Defines *
- ************************************************************************************************/
- #ifdef __cplusplus
- };
- #endif
- #endif // __DEV_IAP_H
|