#ifndef __BSP_DRIVER_SPEED_HALL_H_ #define __BSP_DRIVER_SPEED_HALL_H_ //#include "ptz_type_select.h" #include "gd32f4xx.h" // typedef struct _speed_t { // uint32_t hallNum; //霍尔编码器次数(运行方向的) // uint32_t startTime_60ms; //开始时间 // uint32_t startTime_us; // uint32_t endTime_60ms; //结束时间 // uint32_t endTime_us; // uint8_t flag; //标志位 // }speed_t; typedef struct _speed_t { uint32_t startTime_60ms; //开始时间 uint32_t startTime_us; uint32_t endTime_60ms; //结束时间 uint32_t endTime_us; float speed; //速度 float lastSpeed; //上一次速度 }speed_t; typedef struct _speed_pid_t { float kp; float ki; float kd; float sum_error; //积分误差 }speed_pid_t; typedef struct _speed_to_hall { speed_t hori_speed_t; speed_t vert_speed_t; speed_pid_t hori_speed_pid; speed_pid_t vert_speed_pid; uint32_t time_60ms; }speed_hall; typedef enum _calculation_speed_type { calculation_disable = 0, //未开始计算速度 calculation_enable = 1, //使能计算速度 calculation_ok = 2, //达到计算速度时间 calculation_start = 3, //开始计算速度 calculation_end = 4, //结束计算速度 }calculation_speed_type; extern speed_hall g_speed_to_hall; #define TIME_60MS_MAX 4000000000 #define SPEED_TIMER_PERIOD 60000 void init_hall_speed_module(void); extern void get_hori_speed(void); extern void get_vert_speed(void); #endif