123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- /**
- * @file giant_can.h
- * @author Ye Jin
- * @brief giant can protocol
- * @version 0.1
- * @date 2025-01-09
- *
- * @copyright Copyright (c) 2025
- *
- */
- /************************************************************************
- Beginning of File, do not put anything above here except notes
- Compiler Directives:
- *************************************************************************/
- #ifndef GIANT_CAN_H
- #define GIANT_CAN_H
- #include "typedefine.h"
- /****************************************
- *
- * Definitions & Macros
- *
- ****************************************/
- #define APPLICATIONSTATUS_ADDRESS (uint32_t)0x0803D000 /* Start user code status address: */
- #define MAXFRAME_SIZE 16
- //DriveChain Dir -for updata
- #define MC_FILEMAINDIR 0x0006
- #define MC_FILESUBDIR 0x0100
- //Data Frame- Function group
- #define FG_NETWORKMANAGER 0x0
- #define FG_EVENT 0x1
- #define FG_RESPONSEDATA 0x2
- #define FG_NORMALDATA 0x3
- //Node group
- #define NODE_ALL 0x0
- #define NODE_SERVICETOOL 0x1
- #define NODE_USERINTERFACE 0x2
- #define NODE_DRIVECHAIN 0x6
- #define NODE_MOTINOVA 0x7
- #define NODE_ENERGYPACK 0xC
- #define NODE_GIANTAPP 0xF
- //Data Frame-Data behavior
- #define DB_ACTIVEDATA 0x0
- #define DB_PASSIVEDATA 0x1
- //Remote Frame- motion group
- #define MG_HEARTBEAT 0x0
- #define MG_CONFIRMATION 0x1
- #define MG_ACTIVEDATA1 0x2
- #define MG_ACTIVEDATA2 0x3
- #define MG_PASSIVEDATA1 0x4
- #define MG_PASSIVEDATA2 0x5
- #define MG_PASSIVEDATA3 0x6
- #define MG_PASSIVEDATA4 0x7
- //mode
- #define AD_SERVICEMODE_S 0x6
- #define AD_SERVICEMODE_E 0xA
- #define AD_CHECKMODE 0xB
- #define AD_OFFMODE 0xC
- #define AD_ERRORMODE 0xD
- /***************************************
- *
- * Type Definations
- *
- ***************************************/
- /**
- * @brief Rx Standard Data ID
- *
- */
-
- typedef struct
- {
- UBYTE ucFrameSize; //缓冲区数组:缓冲区大小
- UBYTE ucFrameWrInde; //缓冲区数组:写索引
- UBYTE ucFrameRdInde; //缓冲区数组:读索引
- UBYTE ucFrameCnt; //缓冲区数组:数据计数
- } CANFrame_Info_Struct_t;
- typedef struct
- {
- ULONG id; /*!< standard format frame identifier */
- UBYTE rx_ff; /*!< format of frame, standard or extended format */
- UBYTE rx_ft; /*!< type of frame, data or remote */
- UBYTE rx_dlen; /*!< data length */
- UBYTE rx_data[8]; /*!< receive data */
- } CAN_ReceiveFrame_Struct_t;
- typedef struct
- {
- UBYTE FunctionGroup;//2 bits
- UBYTE NodeGroup;//4 bits
- UBYTE DataBehaviors;//1 bit
- UBYTE DataAddress;//4 bits
- } GiantStandardDataFrameID_Struct_t;
- typedef struct
- {
- UBYTE MotionGroup;//3 bits
- UBYTE RequireNodeGroup;//4 bits
- UBYTE ResponseNodeGroup;//4 bits
- } GiantStandardRemoteFrameID_Struct_t;
- typedef struct
- {
- UWORD RefreshFlag;
- UBYTE Error;
- UBYTE ManualSleepEn;
- UBYTE AutomaticSleepEn;//1-ignore,0-keep
- UBYTE InactivateErrorDetection;
- UBYTE ThrottleEn;
- UBYTE BrakeleEn;
- UBYTE WalkEn;
- UBYTE ThrottlePowerPercentage;
- UBYTE RidingModeEn;
- UBYTE AdjustingMode;
- UBYTE StartMode;
- UBYTE RearLight;//12V(2)
- UBYTE FrontLight;//12V(1)
- UWORD WheelCircumference;
- UBYTE MaximumTorque;
- UBYTE Acceleration;
- UBYTE AssistRatio;
- UBYTE MaximumPower;
- UWORD SpeedLimitation;
- UBYTE CommSleep;
- } GiantControlParams_Struct_t;
- /*****************************************
- *
- * Exported variable
- *
- ****************************************/
- //extern GiantStandardDataFrameID_Struct_t stGiantStandardDataFrameID_rx;
- //extern GiantStandardRemoteFrameID_Struct_t stGiantStandardRemoteFrameID_rx;
- extern GiantControlParams_Struct_t stGiantControlParams;
- //extern CANFrame_Info_Struct_t stCANFrame_InfoRx;
- //extern CAN_ReceiveFrame_Struct_t stCAN_ReceiveFrame_Buf_Rx[MAXFRAME_SIZE];
- /***************************************
- *
- * Function Definations
- *
- ***************************************/
- void giant_Init(void);
- void giant_10msTask(void);
- void CANFrame_Rx_ISR(void);
- void giant_CANRxData_Process(void);
- void giant_SendDriveChainPassiveData(UBYTE nodegroup, UBYTE dataaddr);
- void giant_SendDriveChainActiveData(UBYTE functiongroup, UBYTE dataaddr);
- void giant_SendRemote(UBYTE motiongroup);
- void giant_SendExtendData(UBYTE dataaddr, UBYTE datatype, UBYTE *data, UBYTE len);
- void giant_DataProcess(void);
- SLONG giant_slPolynomial(const SWORD *value);
- /************************************************************************/
- #endif
- /************************************************************************
- End of this File (EOF):
- Do not put anything after this part!
- *************************************************************************/
|