giant_can.h 3.2 KB

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