Myproject.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __MYPROJECT_H_
  2. #define __MYPROJECT_H_
  3. #include <FU68xx_5.h>
  4. #include <FU68xx_5_Type.h>
  5. #include <Customer.h>
  6. #include <Parameter.h>
  7. #include <AddFunction.h>
  8. #include <Protect.h>
  9. #include <ProtectSet.h>
  10. #include <VoltageCompensation.h>
  11. // math.h包含算术运算的数学函数
  12. #include <math.h>
  13. #include <Definition.h>
  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. }MotStaType;
  28. typedef union
  29. {
  30. uint8 SetMode; // 整个配置模式使能位
  31. struct
  32. {
  33. uint8 AlignSetFlag :1; // 预定位配置标志位
  34. } SetFlag;
  35. }MotStaM;
  36. extern MotStaType mcState;
  37. extern MotStaM McStaSet;
  38. void CMP0_Init(void);
  39. void CMP3_Init(void);
  40. void CMP3_Interrupt_Init(void);
  41. void CMP5_Init(void);
  42. void Timer2_Init(void);
  43. void Timer3_Init(void);
  44. void Timer4_Init(void);
  45. void SPI_Init(void);
  46. void WatchDogConfig(uint32 value, uint8 Status);
  47. unsigned short CRC_Check(unsigned char start_sector , unsigned char offset_sector);
  48. extern void FOC_Init(void);
  49. extern void Motor_Open(void);
  50. extern void Motor_Align(void);
  51. #if (FiledWeakenCompEnable)
  52. typedef struct
  53. {
  54. uint16 FieldWeakenActualUS_Q15;
  55. uint16 FieldWeakenActualDcbus_Q15;
  56. int16 FieldWeakenIsTheta;
  57. int16 mcIqref;
  58. int16 mcIdref;
  59. }FieldWeakeningTypeDef;
  60. FieldWeakeningTypeDef xdata mcFieldWeaken;
  61. void GetFieldWeakenUsAndUdc_Q15(int16 Ud, int16 Uq , uint16 Dcbus);
  62. void GetFieldWeakenIdRefAndIqRef_Q15(int16 Is);
  63. void GetFieldWeakenIsTheta_Q15(void);
  64. int16 mcFieldWeakenPI(int16 feedbackvalue, int16 referencevalue);
  65. void FiledWeakenControl(int16 Ud, int16 Uq , uint16 Dcbusk,int16 Is);
  66. #endif
  67. #define P_Power(POWER) _Q15(POWER*2/HW_BOARD_CURR_BASE/HW_BOARD_VOLTAGE_BASE/1.5)
  68. #define DAC_OvercurrentValue (_Q8(I_ValueX(OverHardcurrentValue ))+0x7F)
  69. #endif