MotorControl.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @copyright (C) COPYRIGHT 2022 Fortiortech Shenzhen
  3. * @file MotorControl.h
  4. * @author Fortiortech Appliction Team
  5. * @since Create:2021-04-11
  6. * @date Last modify:2022-07-14
  7. * @note Last modify author is Marcel He
  8. * @brief
  9. */
  10. /* Define to prevent recursive inclusion -------------------------------------*/
  11. #ifndef __MOTORCONTROL_H_
  12. #define __MOTORCONTROL_H_
  13. /* Exported types -------------------------------------------------------------------------------*/
  14. typedef enum
  15. {
  16. mcReady = 0, ///< 准备状态,该状态电机空闲,等待控制命令
  17. mcInit = 1, ///< 初始化,该状态进行启动前的变量初始化
  18. mcCharge = 2, ///< 预充电,电机启动前给自举电容充电,一般用于高压驱动,低压驱动一般不需要
  19. mcTailWind = 3, ///< 顺逆风检测,该状态下电机进行顺逆风检测
  20. mcPosiCheck = 4, ///< 初始位置检测
  21. mcAlign = 5, ///< 预定位
  22. mcStart = 6, ///< 启动,用于配置启动代码
  23. mcRun = 7, ///< 运行,
  24. mcStop = 8, ///< 停止
  25. mcFault = 9, ///< 故障状态
  26. mcBrake = 10, ///< 刹车
  27. } MotStateType;
  28. typedef union
  29. {
  30. uint8 SetMode; ///< 整个配置模式使能位
  31. struct
  32. {
  33. uint8 CalibFlag :1; ///< 电流校准的标志位
  34. uint8 ChargeSetFlag :1; ///< 预充电配置标志位
  35. uint8 AlignSetFlag :1; ///< 预定位配置标志位
  36. uint8 TailWindSetFlag :1; ///< 顺逆风配置标志位
  37. uint8 StartSetFlag :1; ///< 启动配置标志位
  38. uint8 PosiCheckSetFlag :1; ///< 位置检测配置标志位
  39. uint8 Break :1; ////</ 刹车配置标志位
  40. } SetFlag;
  41. }MotStaM;
  42. /* Exported variables ---------------------------------------------------------------------------*/
  43. extern MotStateType data mcState;
  44. extern MotStaM McStaSet;
  45. /* Exported functions ---------------------------------------------------------------------------*/
  46. extern void MC_Control(void);
  47. extern void MotorcontrolInit(void);
  48. extern void McTailWindDealwith(void);
  49. extern void TailWindDealwith(void);
  50. #endif