giant_can.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * @file giant_can.h
  3. * @author Ye Jin
  4. * @brief giant can protocol
  5. * @version 0.1
  6. * @date 2025-01-09
  7. *
  8. * @copyright Copyright (c) 2025
  9. *
  10. */
  11. /************************************************************************
  12. Beginning of File, do not put anything above here except notes
  13. Compiler Directives:
  14. *************************************************************************/
  15. #ifndef GIANT_CAN_H
  16. #define GIANT_CAN_H
  17. #include "typedefine.h"
  18. /****************************************
  19. *
  20. * Definitions & Macros
  21. *
  22. ****************************************/
  23. //Data Frame- Function group
  24. #define FG_NETWORKMANAGER 0x0
  25. #define FG_EVENT 0x1
  26. #define FG_RESPONSEDATA 0x2
  27. #define FG_NORMALDATA 0x3
  28. //Node group
  29. #define NODE_ALL 0x0
  30. #define NODE_SERVICETOOL 0x1
  31. #define NODE_USERINTERFACE 0x2
  32. #define NODE_DRIVECHAIN 0x6
  33. #define NODE_MOTINOVA 0x7
  34. #define NODE_ENERGYPACK 0xC
  35. #define NODE_GIANTAPP 0xF
  36. //Data Frame-Data behavior
  37. #define DB_ACTIVEDATA 0x0
  38. #define DB_PASSIVEDATA 0x1
  39. //Remote Frame- motion group
  40. #define MG_HEARTBEAT 0x0
  41. #define MG_CONFIRMATION 0x1
  42. #define MG_ACTIVEDATA1 0x2
  43. #define MG_ACTIVEDATA2 0x3
  44. #define MG_PASSIVEDATA1 0x4
  45. #define MG_PASSIVEDATA2 0x5
  46. #define MG_PASSIVEDATA3 0x6
  47. #define MG_PASSIVEDATA4 0x7
  48. //mode
  49. #define AD_SERVICEMODE_S 0x6
  50. #define AD_SERVICEMODE_E 0xA
  51. #define AD_CHECKMODE 0xB
  52. #define AD_OFFMODE 0xC
  53. #define AD_ERRORMODE 0xD
  54. /***************************************
  55. *
  56. * Type Definations
  57. *
  58. ***************************************/
  59. /**
  60. * @brief Rx Standard Data ID
  61. *
  62. */
  63. typedef struct
  64. {
  65. UBYTE FunctionGroup;//2 bits
  66. UBYTE NodeGroup;//4 bits
  67. UBYTE DataBehaviors;//1 bit
  68. UBYTE DataAddress;//4 bits
  69. } GiantStandardDataFrameID_Struct_t;
  70. typedef struct
  71. {
  72. UBYTE MotionGroup;//3 bits
  73. UBYTE RequireNodeGroup;//4 bits
  74. UBYTE ResponseNodeGroup;//4 bits
  75. } GiantStandardRemoteFrameID_Struct_t;
  76. typedef struct
  77. {
  78. UWORD RefreshFlag;
  79. UBYTE Error;
  80. UBYTE ManualSleepEn;
  81. UBYTE AutomaticSleepEn;//1-ignore,0-keep
  82. UBYTE InactivateErrorDetection;
  83. UBYTE ThrottleEn;
  84. UBYTE BrakeleEn;
  85. UBYTE WalkEn;
  86. UBYTE ThrottlePowerPercentage;
  87. UBYTE RidingModeEn;
  88. UBYTE AdjustingMode;
  89. UBYTE StartMode;
  90. UWORD WheelCircumference;
  91. UBYTE MaximumTorque;
  92. UBYTE Acceleration;
  93. UBYTE AssistRatio;
  94. UBYTE MaximumPower;
  95. UWORD SpeedLimitation;
  96. UBYTE CommSleep;
  97. } GiantControlParams_Struct_t;
  98. /*****************************************
  99. *
  100. * Exported variable
  101. *
  102. ****************************************/
  103. extern GiantStandardDataFrameID_Struct_t stGiantStandardDataFrameID_rx;
  104. extern GiantStandardRemoteFrameID_Struct_t stGiantStandardRemoteFrameID_rx;
  105. extern GiantControlParams_Struct_t stGiantControlParams;
  106. /***************************************
  107. *
  108. * Function Definations
  109. *
  110. ***************************************/
  111. void giant_Init(void);
  112. void giant_10msTask(void);
  113. void giant_DataProcess(void);
  114. void giant_SendDriveChainPassiveData(UBYTE remoteMG, UBYTE DataAddr);
  115. void giant_SendDriveChainActiveData(UBYTE functiongroup, UBYTE dataaddr);
  116. void giant_SendRemote(UBYTE motiongroup);
  117. void giant_CANRxData_Process(void);
  118. SLONG giant_slPolynomial(const SWORD *value);
  119. /************************************************************************/
  120. #endif
  121. /************************************************************************
  122. End of this File (EOF):
  123. Do not put anything after this part!
  124. *************************************************************************/