Files
1CAR/app/app_brake.h

59 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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 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; // 释放刹车定时器
} BrakeSystem;
// 声明外部变量
extern BrakeSystem brake_data;
void brakeAppInit(void);
#ifdef __cplusplus
}
#endif
#endif // APP_BRAKE_H