9 changed files with 550 additions and 48 deletions
@ -0,0 +1,92 @@ |
|||||
|
/******************************************************************************
|
||||
|
|
||||
|
版权所有 (C), 2018-2099, Radkil |
||||
|
|
||||
|
****************************************************************************** |
||||
|
文 件 名 : BHBF_robot.c |
||||
|
版 本 号 : 初稿 |
||||
|
作 者 : radkil |
||||
|
生成日期 : 2026年6月8日 |
||||
|
最近修改 : |
||||
|
功能描述 : 机器人主程序 |
||||
|
|
||||
|
修改历史 : |
||||
|
1.日 期 : 2026年6月8日 |
||||
|
作 者 : radkil |
||||
|
修改内容 : 创建文件 |
||||
|
|
||||
|
******************************************************************************/ |
||||
|
#include "BHBF_robot.h" |
||||
|
#include "common.h" |
||||
|
|
||||
|
#include "cmsis_os.h" |
||||
|
#include "FreeRTOS.h" |
||||
|
#include "task.h" |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 外部变量说明 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 外部函数原型说明 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 内部函数原型说明 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 全局变量 * |
||||
|
*----------------------------------------------*/ |
||||
|
GV_struct_define GV = {0}; |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 模块级变量 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 常量定义 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 宏定义 * |
||||
|
*----------------------------------------------*/ |
||||
|
GV_struct_define *GetGV(void) |
||||
|
{ |
||||
|
static GV_struct_define tmpGV = {0}; |
||||
|
RD_MEMSET(&tmpGV, 0, sizeof(tmpGV)); |
||||
|
RD_MEMCPY(&tmpGV, &GV, sizeof(GV_struct_define)); |
||||
|
return &tmpGV; |
||||
|
} |
||||
|
|
||||
|
void SetGV(GV_struct_define *_pGV) |
||||
|
{ |
||||
|
RD_MEMCPY(&GV, _pGV, sizeof(GV_struct_define)); |
||||
|
} |
||||
|
|
||||
|
void GF_FsmStart(GF_CMD GFCmd) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void GF_Dispatch(void *argument) |
||||
|
{ |
||||
|
while(1) |
||||
|
{ |
||||
|
GF_CMD GFCmd = MK32_Task(GV.m_iWorkMode); |
||||
|
GF_FsmStart(GFCmd); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void GF_Init(void) |
||||
|
{ |
||||
|
Drv_InterfaceInit(); |
||||
|
|
||||
|
const osThreadAttr_t GF_Dispatch_attributes = { |
||||
|
.name = "GF_Task", |
||||
|
.stack_size = 1024, |
||||
|
.priority = (osPriority_t) osPriorityRealtime1, |
||||
|
}; |
||||
|
(void)osThreadNew(GF_Dispatch, NULL, &GF_Dispatch_attributes); |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,106 @@ |
|||||
|
/******************************************************************************
|
||||
|
|
||||
|
版权所有 (C), 2018-2099, Radkil |
||||
|
|
||||
|
****************************************************************************** |
||||
|
文 件 名 : BHBF_robot.h |
||||
|
版 本 号 : 初稿 |
||||
|
作 者 : radkil |
||||
|
生成日期 : 2026年6月8日 |
||||
|
最近修改 : |
||||
|
功能描述 : BHBF_robot.c 的头文件 |
||||
|
|
||||
|
修改历史 : |
||||
|
1.日 期 : 2026年6月8日 |
||||
|
作 者 : radkil |
||||
|
修改内容 : 创建文件 |
||||
|
|
||||
|
******************************************************************************/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 外部变量说明 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 外部函数原型说明 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 内部函数原型说明 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 全局变量 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 模块级变量 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 常量定义 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
/*----------------------------------------------*
|
||||
|
* 宏定义 * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
#ifndef __BHBF_ROBOT_H__ |
||||
|
#define __BHBF_ROBOT_H__ |
||||
|
|
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
#if __cplusplus |
||||
|
extern "C"{ |
||||
|
#endif |
||||
|
#endif /* __cplusplus */ |
||||
|
|
||||
|
|
||||
|
/*==============================================*
|
||||
|
* include header files * |
||||
|
*----------------------------------------------*/ |
||||
|
#include "drv_interface.h" |
||||
|
#include "rd_time.h" |
||||
|
|
||||
|
|
||||
|
/*==============================================*
|
||||
|
* constants or macros define * |
||||
|
*----------------------------------------------*/ |
||||
|
typedef enum { |
||||
|
GF_CMD_DEFAULT_NULL = 0, |
||||
|
GF_CMD_STOP_ALL, |
||||
|
GF_CMD_MANUAL_FORWARD, |
||||
|
GF_CMD_MANUAL_BACKWARD, |
||||
|
GF_CMD_AUTO_FORWARD |
||||
|
} GF_CMD; |
||||
|
|
||||
|
typedef struct _GV_struct_define |
||||
|
{ |
||||
|
int m_iWorkMode; |
||||
|
GF_CMD m_eGFCmd; |
||||
|
int32_t m_iMoveSpeed[2];//索引1对应左轮,索引2对应右轮
|
||||
|
} GV_struct_define; |
||||
|
|
||||
|
/*==============================================*
|
||||
|
* project-wide global variables * |
||||
|
*----------------------------------------------*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
/*==============================================*
|
||||
|
* routines' or functions' implementations * |
||||
|
*----------------------------------------------*/ |
||||
|
// 待实现接口
|
||||
|
void MK32_Init(void); |
||||
|
GF_CMD MK32_Task(int mode); |
||||
|
void MoveWheel_Init(void); |
||||
|
void MoveWheel_Task(int32_t Target_Velcity[]); |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
#if __cplusplus |
||||
|
} |
||||
|
#endif |
||||
|
#endif /* __cplusplus */ |
||||
|
|
||||
|
|
||||
|
#endif /* __BHBF_ROBOT_H__ */ |
||||
@ -0,0 +1,122 @@ |
|||||
|
/******************************************************************************
|
||||
|
|
||||
|
版权所有 (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