You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.3 KiB
77 lines
2.3 KiB
/*
|
|
* msp_LeiSai_ISV2_CAN.c
|
|
*
|
|
* Created on: Oct 22, 2024
|
|
* Author: akeguo
|
|
*/
|
|
|
|
#include "msp_LeiSai_ISV2_CAN.h"
|
|
|
|
ISV_MotorParameters* ISV_Motors[4];
|
|
|
|
|
|
FDCANHandler *LeiSaiISV_Motor_Controller;
|
|
HardWareController *LeiSaiISV_HardController;
|
|
DispacherController *LeiSaiISV_DispacherController;
|
|
void Decode_LeiSai_CAN(uint32_t canID, uint8_t *buffer, uint32_t length);
|
|
void LeiSai_ISV_Motor_Control();
|
|
void LeiSai_ISV_Motor_Control_intialize(FDCANHandler *Handler)
|
|
{
|
|
//初始化
|
|
|
|
LeiSaiISV_Motor_Controller = Handler;
|
|
LeiSaiISV_Motor_Controller->CAN_Decode = Decode_LeiSai_CAN;
|
|
|
|
|
|
|
|
HardWareErrorController->Add_PCOMHardWare(HardWareErrorController,
|
|
"LeiSai_ISV2CAN", 0,LeiSai_ISV2CAN);
|
|
|
|
|
|
LeiSaiISV_DispacherController = Handler->dispacherController;
|
|
LeiSaiISV_DispacherController->Add_Dispatcher_List(LeiSaiISV_DispacherController,
|
|
LeiSai_ISV_Motor_Control);
|
|
|
|
}
|
|
void Decode_LeiSai_CAN(uint32_t canID, uint8_t *buffer, uint32_t length)
|
|
{
|
|
//buffer[0] is CAN ID;
|
|
if (canID == 0x701 || canID == 0x601) //心跳包
|
|
{
|
|
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController,
|
|
"LeiSai_ISV2CAN", 1);
|
|
}
|
|
}
|
|
|
|
|
|
void LeiSai_CANSendMessageSDO(int MotorID, uint8_t Function, uint16_t ControlWord,
|
|
uint8_t subWord, int32_t ControlWordValue)
|
|
{
|
|
//copy the corresponsiding data to the send Array
|
|
LeiSaiISV_Motor_Controller->Tx_Buf[0] = Function;
|
|
memcpy(&LeiSaiISV_Motor_Controller->Tx_Buf[1], &ControlWord, 2);
|
|
LeiSaiISV_Motor_Controller->Tx_Buf[3] = subWord;
|
|
memcpy(&LeiSaiISV_Motor_Controller->Tx_Buf[4], &ControlWordValue, 4);
|
|
//send 8 bytes data
|
|
LeiSaiISV_Motor_Controller->CAN_Send(LeiSaiISV_Motor_Controller, 0x600 + MotorID, 8,
|
|
LeiSaiISV_Motor_Controller->Tx_Buf);
|
|
}
|
|
|
|
void LeiSai_CANSendMessageSDO_ADD_To_SendList(int MotorID, uint8_t Function,
|
|
uint16_t ControlWord, uint8_t subWord, int32_t ControlWordValue)
|
|
{
|
|
//copy the corresponsiding data to the send Array
|
|
LeiSaiISV_Motor_Controller->Tx_Buf[0] = Function;
|
|
memcpy(&LeiSaiISV_Motor_Controller->Tx_Buf[1], &ControlWord, 2);
|
|
LeiSaiISV_Motor_Controller->Tx_Buf[3] = subWord;
|
|
memcpy(&LeiSaiISV_Motor_Controller->Tx_Buf[4], &ControlWordValue, 4);
|
|
//send 8 bytes data
|
|
|
|
LeiSaiISV_Motor_Controller->AddCANSendList(LeiSaiISV_Motor_Controller, 0x600 + MotorID, 8,
|
|
LeiSaiISV_Motor_Controller->Tx_Buf, 4, NULL);
|
|
}
|
|
|
|
void LeiSai_ISV_Motor_Control()
|
|
{
|
|
|
|
}
|
|
|