实现电机,按键,虚拟串口,未验证
This commit is contained in:
58
source/dev/dev_flash.c
Normal file
58
source/dev/dev_flash.c
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
#include "rtthread.h"
|
||||
#include "stm32mp1xx.h"
|
||||
#include "board.h"
|
||||
#include "dev_flash.h"
|
||||
#include "debug.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
#ifndef RT_THREAD
|
||||
|
||||
#define rt_interrupt_enter()
|
||||
#define rt_interrupt_leave()
|
||||
#define rt_mutex_create(...) 0
|
||||
#define rt_mutex_delete(...)
|
||||
#define rt_mutex_take(...)
|
||||
#define rt_mutex_release(...)
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct{
|
||||
sys_param_def param;
|
||||
}self_def;
|
||||
|
||||
static self_def g_self;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 保存参数
|
||||
int flash_save_param(sys_param_def *par)
|
||||
{
|
||||
uint8_t *dst=(uint8_t *)&g_self.param;
|
||||
uint8_t *src=(uint8_t *)par;
|
||||
int size=sizeof(sys_param_def);
|
||||
memcpy(dst,src,size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const sys_param_def *sys_param(void)
|
||||
{
|
||||
return &g_self.param;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const scheme_def *check_scheme(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
76
source/dev/dev_flash.h
Normal file
76
source/dev/dev_flash.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef dev_flash_h__
|
||||
#define dev_flash_h__
|
||||
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 系统参数
|
||||
__packed
|
||||
typedef struct{
|
||||
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;// 本机识别号
|
||||
uint8_t host_log_ip[4];// 主机logip
|
||||
int uartbsp;// 串口4的波特率
|
||||
int coder_ret_mode;// 注码指令返回格式
|
||||
int slave_addr_start;// 小板起始地址
|
||||
int moter_max_count;// 电机最大步数
|
||||
}sys_param_def;
|
||||
|
||||
|
||||
|
||||
int flash_save_param(sys_param_def *par);
|
||||
const sys_param_def *sys_param(void);
|
||||
|
||||
|
||||
__packed
|
||||
typedef struct{
|
||||
uint32_t max;
|
||||
uint32_t min;
|
||||
uint32_t err;
|
||||
}scheme_range_def;
|
||||
|
||||
|
||||
|
||||
__packed
|
||||
typedef struct
|
||||
{
|
||||
uint32_t item_num;
|
||||
uint32_t err;
|
||||
scheme_range_def range[16];
|
||||
}scheme_task_def;
|
||||
|
||||
// 方案参数
|
||||
__packed
|
||||
typedef struct{
|
||||
uint8_t slave_data[2048];
|
||||
uint32_t plan_id;
|
||||
uint32_t timeout_m;
|
||||
uint32_t task_num;
|
||||
scheme_task_def task[0];
|
||||
}scheme_def;
|
||||
|
||||
|
||||
const scheme_def *check_scheme(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user