hardware-notes 原文存档
指针函数和结构体的使用
22.03.12
//1,结构体定义了函数指针
typedef struct PID_TypeDef
{
float measure;
float target;
float (*f_cal_pid)(struct _PID_TypeDef *pid, float measure, float target);
}PID_TypeDef;
//2 定义结构体指针pid
PID_TypeDef * pid;
//3,使用函数指针
pid->f_cal_pid=pid_calculate;
//4,pid_calculate函数原型
float pid_calculate(PID_TypeDef* pid, float measure, float target)
{
pid->measure = measure;
pid->target=target;
...
}