10 changed files with 51 additions and 673 deletions
@ -1,15 +0,0 @@ |
|||||
cmake_minimum_required(VERSION 3.10) |
|
||||
|
|
||||
set(COMMON_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../library/CMakeLists.txt") |
|
||||
|
|
||||
if(EXISTS ${COMMON_CMAKE_PATH}) |
|
||||
include(${COMMON_CMAKE_PATH}) |
|
||||
else() |
|
||||
message(FATAL_ERROR "Cannot find common build logic at ${COMMON_CMAKE_PATH}") |
|
||||
endif() |
|
||||
|
|
||||
if(TARGET RBcore) |
|
||||
target_link_libraries(optional PUBLIC RBcore) |
|
||||
else() |
|
||||
message(WARNING "[optional] Dependency 'RBcore' not found.") |
|
||||
endif() |
|
||||
@ -1,170 +0,0 @@ |
|||||
/******************************************************************************
|
|
||||
|
|
||||
版权所有 (C), 2018-2099, Radkil |
|
||||
|
|
||||
****************************************************************************** |
|
||||
文 件 名 : msp_MK32.c |
|
||||
版 本 号 : 初稿 |
|
||||
作 者 : radkil |
|
||||
生成日期 : 2026年6月8日 |
|
||||
最近修改 : |
|
||||
功能描述 : MK32遥控器 |
|
||||
|
|
||||
修改历史 : |
|
||||
1.日 期 : 2026年6月8日 |
|
||||
作 者 : radkil |
|
||||
修改内容 : 创建文件 |
|
||||
|
|
||||
******************************************************************************/ |
|
||||
#include "msp_MK32.h" |
|
||||
#include "BHBF.h" |
|
||||
#include <math.h> |
|
||||
|
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 外部变量说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 外部函数原型说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 内部函数原型说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 全局变量 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 模块级变量 * |
|
||||
*----------------------------------------------*/ |
|
||||
static SP_MSP_MK32_Button RB_MK32; |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 常量定义 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 宏定义 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
static int check_MK32Data(char *_pBuffer, uint32_t _iSize) |
|
||||
{ |
|
||||
if (_pBuffer[0] != 0x0f) |
|
||||
{ |
|
||||
return -1; |
|
||||
} |
|
||||
if (_pBuffer[24] != 0x0f) |
|
||||
{ |
|
||||
return -1; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
return 25; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
static void decode_MK32Data(const char *buf, uint32_t _iSize) |
|
||||
{ |
|
||||
int16_t CH[16]; |
|
||||
int Start_byte = -1; |
|
||||
|
|
||||
CH[0] = ((buf[Start_byte + 1] | buf[Start_byte + 2] << 8) & 0x07FF); |
|
||||
CH[1] = ((buf[Start_byte + 2] >> 3 | buf[Start_byte + 3] << 5) & 0x07FF); |
|
||||
CH[2] = ((buf[Start_byte + 3] >> 6 | buf[Start_byte + 4] << 2 |
|
||||
| buf[Start_byte + 5] << 10) & 0x07FF); |
|
||||
CH[3] = ((buf[Start_byte + 5] >> 1 | buf[Start_byte + 6] << 7) & 0x07FF); |
|
||||
CH[4] = ((buf[Start_byte + 6] >> 4 | buf[Start_byte + 7] << 4) & 0x07FF); |
|
||||
CH[5] = ((buf[Start_byte + 7] >> 7 | buf[Start_byte + 8] << 1 |
|
||||
| buf[Start_byte + 9] << 9) & 0x07FF); |
|
||||
CH[6] = ((buf[Start_byte + 9] >> 2 | buf[Start_byte + 10] << 6) & 0x07FF); |
|
||||
CH[7] = ((buf[Start_byte + 10] >> 5 | buf[Start_byte + 11] << 3) & 0x07FF); |
|
||||
CH[8] = ((buf[Start_byte + 12] | buf[Start_byte + 13] << 8) & 0x07FF); |
|
||||
CH[9] = ((buf[Start_byte + 13] >> 3 | buf[Start_byte + 14] << 5) & 0x07FF); |
|
||||
CH[10] = ((buf[Start_byte + 14] >> 6 | buf[Start_byte + 15] << 2 |
|
||||
| buf[Start_byte + 16] << 10) & 0x07FF); |
|
||||
CH[11] = ((buf[Start_byte + 16] >> 1 | buf[Start_byte + 17] << 7) & 0x07FF); |
|
||||
CH[12] = ((buf[Start_byte + 17] >> 4 | buf[Start_byte + 18] << 4) & 0x07FF); |
|
||||
CH[13] = ((buf[Start_byte + 18] >> 7 | buf[Start_byte + 19] << 1 |
|
||||
| buf[Start_byte + 20] << 9) & 0x07FF); |
|
||||
CH[14] = ((buf[Start_byte + 20] >> 2 | buf[Start_byte + 21] << 6) & 0x07FF); |
|
||||
CH[15] = ((buf[Start_byte + 21] >> 5 | buf[Start_byte + 22] << 3) & 0x07FF); |
|
||||
|
|
||||
int32_t* channel_ptrs[16] = |
|
||||
{ |
|
||||
&RB_MK32.CH0_RY_H, &RB_MK32.CH1_RY_V, &RB_MK32.CH2_LY_V, &RB_MK32.CH3_LY_H, |
|
||||
&RB_MK32.CH4_SA, &RB_MK32.CH5_SB, &RB_MK32.CH6_SC, &RB_MK32.CH7_SD, |
|
||||
&RB_MK32.CH8_SE, &RB_MK32.CH9_SF, &RB_MK32.CH10_LD1, &RB_MK32.CH11_RD1, |
|
||||
&RB_MK32.CH12_S1, &RB_MK32.CH13_S2, &RB_MK32.CH14_LT, &RB_MK32.CH15_RT |
|
||||
}; |
|
||||
|
|
||||
// 按键数值转换:1050为中间值,272-1712
|
|
||||
for (int i = 0; i < 16; i++) |
|
||||
{ |
|
||||
// 通过指针解引用赋值,完美替代原来的 RB_MK32[i + 1]
|
|
||||
*channel_ptrs[i] = (int32_t)((CH[i] - 992) * 1.388889); |
|
||||
} |
|
||||
|
|
||||
// 【核心修改】:通过具体的成员名访问 IsOnline,替代原来的 RB_MK32[17]
|
|
||||
if (buf[22] == 0) |
|
||||
{ |
|
||||
RB_MK32.IsOnline = 1; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
RB_MK32.IsOnline = 0; |
|
||||
} |
|
||||
RB_MK32.RxIndex++; |
|
||||
} |
|
||||
|
|
||||
void MK32_Init(void) |
|
||||
{ |
|
||||
TUartUserData *ptUartUserData = UART_userdata_init(5, 115200, 512); |
|
||||
g_ptE28_SBUS = rd_ComCreate(check_MK32Data, decode_MK32Data, E28_SBUS_Send, ptUartUserData->m_buf_size, ptUartUserData); |
|
||||
UART_IT_init(g_ptE28_SBUS); |
|
||||
} |
|
||||
|
|
||||
GF_CMD MK32_Task(int mode) |
|
||||
{ |
|
||||
int angle; |
|
||||
angle = atan2(RB_MK32.CH1_RY_V, RB_MK32.CH0_RY_H) * 180 / M_PI; |
|
||||
|
|
||||
if(RB_MK32.CH5_SB == 0) |
|
||||
{ |
|
||||
// 前进
|
|
||||
if((angle >= 45) && (angle <= 135)) |
|
||||
{ |
|
||||
if (0 == mode) return GF_CMD_MANUAL_FORWARD; |
|
||||
else return GF_CMD_AUTO_FORWARD; |
|
||||
} |
|
||||
// 后退
|
|
||||
else if((angle >= -135) && (angle < -45)) |
|
||||
{ |
|
||||
return GF_CMD_MANUAL_BACKWARD; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
return GF_CMD_STOP_ALL; |
|
||||
} |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
// 前进
|
|
||||
if((angle >= 45) && (angle <= 135)) |
|
||||
{ |
|
||||
if (0 == mode) return GF_CMD_MANUAL_FORWARD; |
|
||||
else return GF_CMD_AUTO_FORWARD; |
|
||||
} |
|
||||
// 后退
|
|
||||
else if((angle >= -135) && (angle < -45)) |
|
||||
{ |
|
||||
return GF_CMD_MANUAL_BACKWARD; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
return GF_CMD_STOP_ALL; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,109 +0,0 @@ |
|||||
/******************************************************************************
|
|
||||
|
|
||||
版权所有 (C), 2018-2099, Radkil |
|
||||
|
|
||||
****************************************************************************** |
|
||||
文 件 名 : msp_MK32.h |
|
||||
版 本 号 : 初稿 |
|
||||
作 者 : radkil |
|
||||
生成日期 : 2026年6月8日 |
|
||||
最近修改 : |
|
||||
功能描述 : msp_MK32.c 的头文件 |
|
||||
|
|
||||
修改历史 : |
|
||||
1.日 期 : 2026年6月8日 |
|
||||
作 者 : radkil |
|
||||
修改内容 : 创建文件 |
|
||||
|
|
||||
******************************************************************************/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 外部变量说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 外部函数原型说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 内部函数原型说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 全局变量 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 模块级变量 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 常量定义 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 宏定义 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
#ifndef __MSP_MK32_H__ |
|
||||
#define __MSP_MK32_H__ |
|
||||
|
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
#if __cplusplus |
|
||||
extern "C"{ |
|
||||
#endif |
|
||||
#endif /* __cplusplus */ |
|
||||
|
|
||||
|
|
||||
/*==============================================*
|
|
||||
* include header files * |
|
||||
*----------------------------------------------*/ |
|
||||
#include <stdint.h> |
|
||||
|
|
||||
|
|
||||
|
|
||||
/*==============================================*
|
|
||||
* constants or macros define * |
|
||||
*----------------------------------------------*/ |
|
||||
typedef struct _SP_MSP_MK32_Button |
|
||||
{ |
|
||||
int32_t RxIndex; |
|
||||
int32_t CH0_RY_H; |
|
||||
int32_t CH1_RY_V; |
|
||||
int32_t CH2_LY_V; |
|
||||
int32_t CH3_LY_H; |
|
||||
int32_t CH4_SA; |
|
||||
int32_t CH5_SB; |
|
||||
int32_t CH6_SC; |
|
||||
int32_t CH7_SD; |
|
||||
int32_t CH8_SE; |
|
||||
int32_t CH9_SF; |
|
||||
int32_t CH10_LD1; |
|
||||
int32_t CH11_RD1; |
|
||||
int32_t CH12_S1; |
|
||||
int32_t CH13_S2; |
|
||||
int32_t CH14_LT; |
|
||||
int32_t CH15_RT; |
|
||||
int32_t IsOnline; |
|
||||
} SP_MSP_MK32_Button; |
|
||||
|
|
||||
|
|
||||
/*==============================================*
|
|
||||
* project-wide global variables * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
|
|
||||
|
|
||||
/*==============================================*
|
|
||||
* routines' or functions' implementations * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
#if __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
#endif /* __cplusplus */ |
|
||||
|
|
||||
|
|
||||
#endif /* __MSP_MK32_H__ */ |
|
||||
@ -1,211 +0,0 @@ |
|||||
/******************************************************************************
|
|
||||
|
|
||||
版权所有 (C), 2018-2099, Radkil |
|
||||
|
|
||||
****************************************************************************** |
|
||||
文 件 名 : msp_TI5MOTOR.c |
|
||||
版 本 号 : 初稿 |
|
||||
作 者 : radkil |
|
||||
生成日期 : 2026年6月8日 |
|
||||
最近修改 : |
|
||||
功能描述 : TI5电机 |
|
||||
|
|
||||
修改历史 : |
|
||||
1.日 期 : 2026年6月8日 |
|
||||
作 者 : radkil |
|
||||
修改内容 : 创建文件 |
|
||||
|
|
||||
******************************************************************************/ |
|
||||
#include "msp_TI5MOTOR.h" |
|
||||
#include "BHBF.h" |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 外部变量说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 外部函数原型说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 内部函数原型说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 全局变量 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 模块级变量 * |
|
||||
*----------------------------------------------*/ |
|
||||
static MotorParameters Motor[4]; |
|
||||
static int32_t Motor_ID_Errors[7] = { 0 }; |
|
||||
static CSP tempCSP; |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 常量定义 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 宏定义 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
#define DF_MSP_Ti5Motor_StartID 0 |
|
||||
|
|
||||
static int CANSendCommand(uint8_t id, uint8_t command, int32_t *content) |
|
||||
{ |
|
||||
int len = (content != NULL) ? 5 : 1; |
|
||||
char buf[10] = {0}; |
|
||||
buf[0] = id; |
|
||||
buf[1] = command; |
|
||||
if (content != NULL) |
|
||||
{ |
|
||||
RD_MEMCPY(&buf[2], content, 4); |
|
||||
} |
|
||||
return rd_ComWrite(g_ptFDCAN1, (char *)buf, len); |
|
||||
} |
|
||||
|
|
||||
static void Motor_ClearFault(uint8_t id) |
|
||||
{ |
|
||||
CANSendCommand(id, 0x0B, NULL); |
|
||||
} |
|
||||
|
|
||||
static void Motor_GetFaultState(uint8_t id) |
|
||||
{ |
|
||||
CANSendCommand(id, 0x0A, NULL); // set motor stop mode
|
|
||||
|
|
||||
} |
|
||||
|
|
||||
static void GetCSPByCommand(uint8_t id) |
|
||||
{ |
|
||||
CANSendCommand(id, 0x41, NULL); |
|
||||
} |
|
||||
|
|
||||
static void Motor_SetVelocityModeAndTargetVelocity(uint8_t id, int32_t targetSpeed) |
|
||||
{ |
|
||||
CANSendCommand(id, 0x1d, &targetSpeed); //Motor_SetVelocityModeAndTargetVelocity
|
|
||||
} |
|
||||
|
|
||||
static int check_TI5MOTOR(char *buffer, uint32_t length) |
|
||||
{ |
|
||||
TCANUserData *ptCANUserData = (TCANUserData *)g_ptFDCAN1->m_pUserData; |
|
||||
uint8_t ID_A_T = (uint8_t)ptCANUserData->m_canrx->Identifier; |
|
||||
int32_t Function_code = 0; |
|
||||
|
|
||||
if (ID_A_T >= DF_MSP_Ti5Motor_StartID |
|
||||
&& ID_A_T < DF_MSP_Ti5Motor_StartID + 7) |
|
||||
{ |
|
||||
(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).RxIndex++; |
|
||||
} |
|
||||
|
|
||||
switch (Function_code) |
|
||||
{ |
|
||||
case 3: |
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Run_Mode, |
|
||||
&buffer[1], length - 1); |
|
||||
break; |
|
||||
case 4: //ma
|
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Current, |
|
||||
&buffer[1], length - 1); |
|
||||
|
|
||||
break; |
|
||||
case 5: |
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Target_Current, |
|
||||
&buffer[1], length - 1); |
|
||||
|
|
||||
break; |
|
||||
case 6: |
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Velcity, |
|
||||
&buffer[1], length - 1); |
|
||||
|
|
||||
break; |
|
||||
case 7: |
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Target_Velcity, |
|
||||
&buffer[1], length - 1); |
|
||||
|
|
||||
break; |
|
||||
case 8: |
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Position, |
|
||||
&buffer[1], length - 1); |
|
||||
|
|
||||
break; |
|
||||
case 9: |
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Target_Position, |
|
||||
&buffer[1], length - 1); |
|
||||
break; |
|
||||
case 10: |
|
||||
|
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).ERROR_Flag, |
|
||||
&buffer[1], length - 1); |
|
||||
|
|
||||
memcpy(&(Motor_ID_Errors[ID_A_T - DF_MSP_Ti5Motor_StartID]), |
|
||||
&buffer[1], length - 1); |
|
||||
break; |
|
||||
case 49: |
|
||||
memcpy( |
|
||||
&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Temperature_Motor, |
|
||||
&buffer[1], length - 1); |
|
||||
break; |
|
||||
case 50: |
|
||||
memcpy(&(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Temperature_PCB, |
|
||||
&buffer[1], length - 1); |
|
||||
break; |
|
||||
|
|
||||
case 65: |
|
||||
case 66: |
|
||||
case 67: |
|
||||
case 68: |
|
||||
//电流 MA
|
|
||||
// case 65-68 均返回CSP
|
|
||||
//tempCSP=&buffer[0];
|
|
||||
memcpy(&tempCSP, buffer, 8); |
|
||||
(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Current = |
|
||||
tempCSP.Current;//单位为mA
|
|
||||
(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Velcity = |
|
||||
tempCSP.Velocity;//转化为度每秒公式:(返回值/100/减速比)*360
|
|
||||
(Motor[ID_A_T - DF_MSP_Ti5Motor_StartID]).Position = |
|
||||
tempCSP.Position;//转化为减速机角度公式:(返回值/65536/减速比)*360
|
|
||||
return 8; |
|
||||
default: |
|
||||
return -1; |
|
||||
} |
|
||||
return 1; |
|
||||
} |
|
||||
|
|
||||
static void decode_TI5MOTOR(const char *_pBuffer, uint32_t _iSize) |
|
||||
{ |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
void MoveWheel_Init(void) |
|
||||
{ |
|
||||
TCANUserData *ptCANUserData = CAN_userdata_init(&hfdcan1, 8, 0); |
|
||||
g_ptFDCAN1 = rd_ComCreate(check_TI5MOTOR, decode_TI5MOTOR, FDCAN1_Send, CONFIG_UART_BUFFER_SIZE, ptCANUserData); |
|
||||
CAN_IT_init(g_ptFDCAN1); |
|
||||
|
|
||||
for (int i = 1; i < 5; i++) |
|
||||
{ |
|
||||
GetCSPByCommand(i); |
|
||||
Rd_Delay(4); |
|
||||
Motor_ClearFault(i); |
|
||||
Rd_Delay(4); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
void MoveWheel_Task(int32_t Target_Velcity[]) |
|
||||
{ |
|
||||
for (int i = 1; i < 5; i++) |
|
||||
{ |
|
||||
Motor_ClearFault(i); |
|
||||
Rd_Delay(4); |
|
||||
Motor_GetFaultState(i); |
|
||||
Rd_Delay(4); |
|
||||
GetCSPByCommand(i); |
|
||||
Rd_Delay(4); |
|
||||
} |
|
||||
for (int i = 1; i < 5; i++) |
|
||||
{ |
|
||||
Motor_SetVelocityModeAndTargetVelocity(i, Target_Velcity[i]); |
|
||||
Rd_Delay(4); |
|
||||
} |
|
||||
} |
|
||||
@ -1,122 +0,0 @@ |
|||||
/******************************************************************************
|
|
||||
|
|
||||
版权所有 (C), 2018-2099, Radkil |
|
||||
|
|
||||
****************************************************************************** |
|
||||
文 件 名 : msp_TI5MOTOR.h |
|
||||
版 本 号 : 初稿 |
|
||||
作 者 : radkil |
|
||||
生成日期 : 2026年6月8日 |
|
||||
最近修改 : |
|
||||
功能描述 : msp_TI5MOTOR.c 的头文件 |
|
||||
|
|
||||
修改历史 : |
|
||||
1.日 期 : 2026年6月8日 |
|
||||
作 者 : radkil |
|
||||
修改内容 : 创建文件 |
|
||||
|
|
||||
******************************************************************************/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 外部变量说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 外部函数原型说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 内部函数原型说明 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 全局变量 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 模块级变量 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 常量定义 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
/*----------------------------------------------*
|
|
||||
* 宏定义 * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
#ifndef __MSP_TI5MOTOR_H__ |
|
||||
#define __MSP_TI5MOTOR_H__ |
|
||||
|
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
#if __cplusplus |
|
||||
extern "C"{ |
|
||||
#endif |
|
||||
#endif /* __cplusplus */ |
|
||||
|
|
||||
|
|
||||
/*==============================================*
|
|
||||
* include header files * |
|
||||
*----------------------------------------------*/ |
|
||||
#include <stdint.h> |
|
||||
|
|
||||
|
|
||||
|
|
||||
/*==============================================*
|
|
||||
* constants or macros define * |
|
||||
*----------------------------------------------*/ |
|
||||
typedef struct _MotorParameters { |
|
||||
int32_t MotorID; |
|
||||
int32_t RxIndex; |
|
||||
int32_t Run_Mode; |
|
||||
int32_t Current; |
|
||||
int32_t Target_Current; |
|
||||
int32_t Velcity; |
|
||||
int32_t Target_Velcity; |
|
||||
int32_t Position; |
|
||||
int32_t Target_Position; |
|
||||
int32_t ERROR_Flag; |
|
||||
int32_t Temperature_Motor; |
|
||||
int32_t Temperature_PCB; |
|
||||
int32_t AccTime; |
|
||||
int32_t DecTime; |
|
||||
int32_t EncoderOffset; /* 53 83 设置位置偏移 int32_t "设置偏移值和目标位置
|
|
||||
(目标位置=编码器位置 - 偏移值)" */ |
|
||||
} MotorParameters; |
|
||||
|
|
||||
#pragma pack (2) /*指定按2字节对齐*/ |
|
||||
typedef struct _CSP |
|
||||
{ |
|
||||
int16_t Current; |
|
||||
int16_t Velocity; |
|
||||
int32_t Position; |
|
||||
} CSP; |
|
||||
|
|
||||
typedef struct _TSP |
|
||||
{ |
|
||||
int32_t Torque; |
|
||||
int32_t Velocity; |
|
||||
int32_t Position; |
|
||||
} TSP; |
|
||||
|
|
||||
#pragma pack () /*取消指定对齐,恢复缺省对齐*/ |
|
||||
|
|
||||
/*==============================================*
|
|
||||
* project-wide global variables * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
|
|
||||
|
|
||||
/*==============================================*
|
|
||||
* routines' or functions' implementations * |
|
||||
*----------------------------------------------*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
#if __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
#endif /* __cplusplus */ |
|
||||
|
|
||||
|
|
||||
#endif /* __MSP_TI5MOTOR_H__ */ |
|
||||
Loading…
Reference in new issue