2023-06-10 11:52:00 +08:00
|
|
|
|
#ifndef dev_flash_h__
|
|
|
|
|
#define dev_flash_h__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdint.h"
|
2025-02-13 23:22:16 +08:00
|
|
|
|
#include "cmsis_compiler.h"
|
2023-06-10 11:52:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-13 23:22:16 +08:00
|
|
|
|
typedef struct __packed{
|
2023-06-10 11:52:00 +08:00
|
|
|
|
uint32_t file_size;//文件长度,不包括文件名
|
|
|
|
|
char name[120];
|
|
|
|
|
int used; // 初始值为0xffffffff,每使用一次添加一个0
|
|
|
|
|
}flash_file;
|
|
|
|
|
|
|
|
|
|
#define FLASH_FILE_HEAD_SIZE 128
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int flash_erase_param(void);
|
|
|
|
|
int flash_erase_app1(void);
|
|
|
|
|
int flash_erase_app2(void);
|
|
|
|
|
int flash_erase_slave(void);
|
|
|
|
|
int flash_erase_scheme(void);
|
|
|
|
|
int flash_erase_lua(void);
|
|
|
|
|
uint32_t *flash_get_param(void);
|
|
|
|
|
//uint32_t *flash_get_app1(void);
|
|
|
|
|
uint32_t *flash_get_app2(void);
|
|
|
|
|
uint32_t *flash_get_slave(void);
|
|
|
|
|
uint32_t *flash_get_scheme(void);
|
|
|
|
|
uint32_t *flash_get_lua(void);
|
|
|
|
|
int flash_write(uint8_t *addr,const uint8_t *data,int len);
|
|
|
|
|
int flash_operate_end(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-13 23:22:16 +08:00
|
|
|
|
|
|
|
|
|
typedef struct __packed{
|
2023-06-10 11:52:00 +08:00
|
|
|
|
uint32_t size;
|
|
|
|
|
char pack_time[20];
|
|
|
|
|
uint32_t crc;
|
|
|
|
|
uint8_t local_ip[4];
|
|
|
|
|
uint8_t host_ip[4];
|
|
|
|
|
int host_port;
|
|
|
|
|
char host_if[8];
|
|
|
|
|
}rom_head;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ROM_HEAD_SIZE 128
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t *flash_get_rom(rom_head **head);
|
|
|
|
|
|
|
|
|
|
int flash_updata_app(uint8_t *rom,uint32_t size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 系统参数
|
2025-02-13 23:22:16 +08:00
|
|
|
|
|
|
|
|
|
typedef struct __packed{
|
2023-06-10 11:52:00 +08:00
|
|
|
|
char pack_time[20];// 打包时间
|
|
|
|
|
char host_if[8];// 主机接口
|
|
|
|
|
char device_type[12];// 设备类型 ,批检仪还是赋码仪
|
|
|
|
|
uint8_t mac[8];// mac地址
|
|
|
|
|
uint8_t local_ip[4];// 本机ip地址
|
|
|
|
|
uint8_t host_ip[4];// 主机ip地址
|
|
|
|
|
int host_port;// 主机端口
|
|
|
|
|
int local_cmd_port;// 本机命令端口
|
|
|
|
|
int host_log_port;// 主机log端口
|
|
|
|
|
int local_id;// 本机识别号
|
2023-06-15 18:11:28 +08:00
|
|
|
|
uint8_t host_log_ip[4];// 主机logip
|
2023-06-14 22:15:00 +08:00
|
|
|
|
int uartbsp;// 串口4的波特率
|
|
|
|
|
int coder_ret_mode;// 注码指令返回格式
|
|
|
|
|
int slave_addr_start;// 小板起始地址
|
2023-06-28 18:08:38 +08:00
|
|
|
|
int moter_max_count;// 电机最大步数
|
2023-06-10 11:52:00 +08:00
|
|
|
|
}sys_param_def;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int flash_save_param(sys_param_def *par);
|
|
|
|
|
const sys_param_def *sys_param(void);
|
|
|
|
|
|
|
|
|
|
|
2025-02-13 23:22:16 +08:00
|
|
|
|
|
|
|
|
|
typedef struct __packed{
|
2023-07-06 19:02:03 +08:00
|
|
|
|
uint32_t max;
|
|
|
|
|
uint32_t min;
|
|
|
|
|
uint32_t err;
|
2023-06-28 18:08:38 +08:00
|
|
|
|
}scheme_range_def;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-13 23:22:16 +08:00
|
|
|
|
|
|
|
|
|
typedef struct __packed
|
2023-06-28 18:08:38 +08:00
|
|
|
|
{
|
2023-07-06 19:02:03 +08:00
|
|
|
|
uint32_t taskid;
|
|
|
|
|
uint32_t taskindex;
|
|
|
|
|
uint32_t item_num;
|
|
|
|
|
uint32_t err;
|
|
|
|
|
scheme_range_def range[16];
|
2023-06-28 18:08:38 +08:00
|
|
|
|
}scheme_task_def;
|
2023-06-10 11:52:00 +08:00
|
|
|
|
|
|
|
|
|
// 方案参数
|
2025-02-13 23:22:16 +08:00
|
|
|
|
|
|
|
|
|
typedef struct __packed{
|
2023-06-10 11:52:00 +08:00
|
|
|
|
uint8_t slave_data[2048];
|
|
|
|
|
uint32_t plan_id;
|
|
|
|
|
uint32_t timeout_m;
|
2023-06-28 18:08:38 +08:00
|
|
|
|
uint32_t task_num;
|
2025-02-13 23:22:16 +08:00
|
|
|
|
scheme_task_def task[];
|
2023-06-10 11:52:00 +08:00
|
|
|
|
}scheme_def;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const scheme_def *check_scheme(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|