giant_can.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 0x6
  50. #define AD_CHECKMODE 0xB
  51. #define AD_OFFMODE 0xC
  52. #define AD_ERRORMODE 0xD
  53. /***************************************
  54. *
  55. * Type Definations
  56. *
  57. ***************************************/
  58. /**
  59. * @brief Rx Standard Data ID
  60. *
  61. */
  62. typedef struct
  63. {
  64. UBYTE FunctionGroup;//2 bits
  65. UBYTE NodeGroup;//4 bits
  66. UBYTE DataBehaviors;//1 bit
  67. UBYTE DataAddress;//4 bits
  68. } GiantStandardDataFrameID_Struct_t;
  69. typedef struct
  70. {
  71. UBYTE MotionGroup;//3 bits
  72. UBYTE RequireNodeGroup;//4 bits
  73. UBYTE ResponseNodeGroup;//4 bits
  74. } GiantStandardRemoteFrameID_Struct_t;
  75. typedef struct
  76. {
  77. UWORD RefreshFlag;
  78. UBYTE Error;
  79. UBYTE ManualSleepEn;
  80. UBYTE AutomaticSleepEn;//1-ignore,0-keep
  81. UBYTE InactivateErrorDetection;
  82. UBYTE ThrottleEn;
  83. UBYTE BrakeleEn;
  84. UBYTE WalkEn;
  85. UBYTE ThrottlePowerPercentage;
  86. UBYTE RidingModeEn;
  87. UBYTE AdjustingMode;
  88. UWORD WheelCircumference;
  89. UBYTE MaximumTorque;
  90. UBYTE Acceleration;
  91. UBYTE AssistRatio;
  92. UBYTE MaximumPower;
  93. UWORD SpeedLimitation;
  94. } GiantControlParams_Struct_t;
  95. /*****************************************
  96. *
  97. * Exported variable
  98. *
  99. ****************************************/
  100. extern GiantStandardDataFrameID_Struct_t stGiantStandardDataFrameID_rx;
  101. extern GiantStandardRemoteFrameID_Struct_t stGiantStandardRemoteFrameID_rx;
  102. extern GiantControlParams_Struct_t stGiantControlParams;
  103. /***************************************
  104. *
  105. * Function Definations
  106. *
  107. ***************************************/
  108. void giant_Init(void);
  109. void giant_10msTask(void);
  110. void giant_DataProcess(void);
  111. void giant_SendDriveChainPassiveData(UBYTE remoteMG, UBYTE DataAddr);
  112. void giant_SendDriveChainActiveData(UBYTE functiongroup, UBYTE dataaddr);
  113. void giant_CANRxData_Process(void);
  114. /************************************************************************/
  115. #endif
  116. /************************************************************************
  117. End of this File (EOF):
  118. Do not put anything after this part!
  119. *************************************************************************/