Files
linear-Slide/Application/app_motor.h

52 lines
1.3 KiB
C
Raw Permalink 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_MOTOR_H__
#define __APP_MOTOR_H__
#include <stdint.h>
#include <stdbool.h>
#include "CANopen.h"
#include "OD.h"
#include "Int_TMC2209.h"
#include "Com_debug.h"
#include "CiA402_defs.h"
#include "app_CiA402.h"
#include <stdlib.h>
#include "Int_Encoder.h"
// --- 全局变量引用 ---
extern Stepper_t stepper_1; // 引用在 app_main.c 中定义的电机对象
extern Encoder_t encoder_1; // 引用在 app_main.c 中定义的编码器对象
extern CO_t *CO; // 引用在 CO_app_STM32.c 中定义的 CANopen 对象
// 记录当前的绝对位置 (mm)
extern float current_absolute_pos_mm; // 当前绝对位置
extern float last_move_start_pos_mm; // 每次动作开始时的绝对位置
// 两个状态机分别对应位置模式和回零模式枚举类型的定义在CiA402_defs.h 中定义
extern Motor_State_t internal_state;
extern Homing_State_t homing_state;
// --- 函数声明 ---
/**
* @brief 电机应用层初始化
*/
void App_Motor_Init(void);
/**
* @brief 电机应用层周期性处理函数
*/
void App_Motor_Process(void);
/**
* @brief 在定时器终端中周期判断电机是否丢步
*
*/
void App_Motor_StepLossCheck(void);
/**
* @brief 获取“停止后延时窗口”评估出的误差mm读取成功返回 true
*/
bool App_Motor_TryGetStopError(float *err_mm);
#endif /* __APP_MOTOR_H__ */