#ifndef APP_BRAKE_H #define APP_BRAKE_H #ifdef __cplusplus extern "C" { #endif #include "app_config.h" #include "app_frm_monitor.h" #include "app_frm_signal.h" #include "app_frm_timer.h" #define OIL_BRAKE 0 #define ELECTROMAGNETIC_BRAKE 1 // 定义刹车状态机状态 typedef enum { BRAKE_STATE_IDLE, BRAKE_STATE_APPLYING_BRAKE, BRAKE_STATE_RELEASING_BRAKE, BRAKE_STATE_BRAKE_ON, } BrakeState; typedef struct BrakeSystem { uint32_t start_time; Timer brake_timer; // 定时器结构体 uint8_t brake_command; // 刹车命令变量:1表示刹车,2表示释放 uint8_t brake_motor_state; // 刹车电机状态变量:0停止,1前进,2后退 uint8_t brake_command_in_progress; // 刹车命令执行状态:0表示空闲,1表示正在执行 uint8_t brake_direction; uint8_t emergency_stop_switch; // 急停开关 uint8_t remote_emergency_stop; // 遥控器急停开关 uint8_t remote_fault; // 遥控器故障 uint8_t can_bus_fault; // CAN总线故障 uint8_t ethernet_fault; // 以太网通信故障 uint8_t mode_signal; // 模式信号:0表示手动模式,1表示自动模式 BrakeState state; // 刹车状态机 uint8_t brake_position; // 刹车位置:0表示未刹车,1表示刹车 uint8_t old_brake_position; // 旧的刹车位置 Timer brake_apply_timer; // 刹车定时器 Timer brake_release_timer; // 释放刹车定时器 Timer brake_param_timer; //参数更新时间 } BrakeSystem; // 声明外部变量 extern BrakeSystem brake_data; void brakeAppInit(void); #ifdef __cplusplus } #endif #endif // APP_BRAKE_H