Browse Source

paint_robot_new【编译通过】增加RBcore模块初版

master
Lizongdi 2 weeks ago
parent
commit
71530dd0f5
  1. 70
      RBcore/BHBF.c
  2. 1
      RBcore/drv_interface.c
  3. 24
      RBcore/include/BHBF.h
  4. 2
      motor/motor_example.c

70
RBcore/BHBF.c

@ -18,8 +18,7 @@
******************************************************************************/ ******************************************************************************/
#include "BHBF.h" #include "BHBF.h"
#include "common.h" #include "common.h"
#include "msg_center.h"
#include "task.h"
/*----------------------------------------------* /*----------------------------------------------*
* * * *
@ -36,7 +35,7 @@
/*----------------------------------------------* /*----------------------------------------------*
* * * *
*----------------------------------------------*/ *----------------------------------------------*/
GV_define GV = {0}; static uint32_t g_uiRBcoreModuleID = 0;
/*----------------------------------------------* /*----------------------------------------------*
* * * *
@ -49,40 +48,59 @@ GV_define GV = {0};
/*----------------------------------------------* /*----------------------------------------------*
* * * *
*----------------------------------------------*/ *----------------------------------------------*/
GV_define *GetGV(void) static void RBcore_ModuleHandler(const Msg_t *pstMsg)
{ {
static GV_define tmpGV = {0}; if (NULL == pstMsg)
RD_MEMSET(&tmpGV, 0, sizeof(tmpGV)); {
RD_MEMCPY(&tmpGV, &GV, sizeof(GV_define)); return;
return &tmpGV; }
}
void SetGV(GV_define *_pGV) switch (pstMsg->m_uiMsgID)
{ {
RD_MEMCPY(&GV, _pGV, sizeof(GV_define)); case MOTOR_CMD_SET_SPEED:
{
break;
}
case MOTOR_CMD_STOP:
{
break;
}
case MOTOR_CMD_SET_HOME:
{
break;
}
case MOTOR_CMD_GET_STATUS:
{
break;
}
default:
break;
}
} }
void GF_FsmStart(GF_CMD GFCmd)
{
}
void GF_Dispatch(void *argument) void RBcore_Task(void *argument)
{ {
while(1) while(1)
{ {
//GF_CMD GFCmd = MK32_Task(GV.m_iWorkMode); // 处理消息
GF_FsmStart(0); MsgCenter_ProcessWait(g_uiRBcoreModuleID, 2);
} }
} }
void GF_Init(void) void RBcore_Init(void)
{ {
// const osThreadAttr_t GF_Dispatch_attributes = { g_uiRBcoreModuleID = MsgCenter_Register(MODULE_NAME_RBCORE, RBcore_ModuleHandler);
// .name = "GF_Task",
// .stack_size = 1024, const osThreadAttr_t GF_Dispatch_attributes = {
// .priority = (osPriority_t) osPriorityRealtime1, .name = MODULE_NAME_RBCORE,
// }; .stack_size = 1024,
// (void)osThreadNew(GF_Dispatch, NULL, &GF_Dispatch_attributes); .priority = (osPriority_t) osPriorityRealtime1,
};
(void)osThreadNew(RBcore_Task, NULL, &GF_Dispatch_attributes);
} }

1
RBcore/drv_interface.c

@ -255,6 +255,7 @@ void SendAll_Task(void *argument)
} }
} }
extern void RBcore_Init(void);
extern void MotorInit(void); extern void MotorInit(void);
extern void MotorMgr_ParseResponse(uint8_t ucMotorID, const uint8_t *pucData, uint32_t uiLen); extern void MotorMgr_ParseResponse(uint8_t ucMotorID, const uint8_t *pucData, uint32_t uiLen);

24
RBcore/include/BHBF.h

@ -68,16 +68,21 @@ extern "C"{
/*==============================================* /*==============================================*
* constants or macros define * * constants or macros define *
*----------------------------------------------*/ *----------------------------------------------*/
#define MODULE_NAME_RBCORE "RBcore"
#define MODULE_NAME_MOTOR "motor" #define MODULE_NAME_MOTOR "motor"
typedef enum { typedef enum {
MOTOR_CMD_SET_SPEED = 0x01, // 设置速度 MOTOR_CMD_SET_SPEED = 0x0001, // 设置速度
MOTOR_CMD_SET_POSITION = 0x02, // 设置位置 MOTOR_CMD_SET_POSITION, // 设置位置
MOTOR_CMD_STOP = 0x03, // 停止 MOTOR_CMD_STOP, // 停止
MOTOR_CMD_GET_STATUS = 0x04, // 获取状态 MOTOR_CMD_GET_STATUS, // 获取状态
MOTOR_CMD_SET_HOME = 0x05, // 设置零点 MOTOR_CMD_SET_HOME, // 设置零点
MOTOR_CMD_SPEED_MODE = 0x06, // 速度模式 MOTOR_CMD_SPEED_MODE, // 速度模式
MOTOR_CMD_POSITION_MODE = 0x07, // 位置模式 MOTOR_CMD_POSITION_MODE, // 位置模式
MOTOR_CMD_END = 0x0100,
RBCORE_CMD_MANUAL_FORWARD,
RBCORE_CMD_MANUAL_BACKWARD,
} Motor_Cmd_e; } Motor_Cmd_e;
// 电机命令数据结构 // 电机命令数据结构
@ -94,8 +99,6 @@ typedef struct {
uint32_t m_uiFaultCode; uint32_t m_uiFaultCode;
} Motor_StatusData_t; } Motor_StatusData_t;
#define MODULE_NAME_RBCORE "RBcore"
typedef enum { typedef enum {
GF_CMD_DEFAULT_NULL = 0, GF_CMD_DEFAULT_NULL = 0,
GF_CMD_STOP_ALL, GF_CMD_STOP_ALL,
@ -120,9 +123,6 @@ typedef struct _GV_struct_define
/*==============================================* /*==============================================*
* routines' or functions' implementations * * routines' or functions' implementations *
*----------------------------------------------*/ *----------------------------------------------*/
GV_define *GetGV(void);
void SetGV(GV_define *_pGV);
// 待实现接口
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

2
motor/motor_example.c

@ -325,7 +325,7 @@ void MotorInit(void)
// 创建电机任务 // 创建电机任务
const osThreadAttr_t motor_task_attributes = { const osThreadAttr_t motor_task_attributes = {
.name = "motor_task", .name = MODULE_NAME_MOTOR,
.stack_size = 1024, .stack_size = 1024,
.priority = (osPriority_t) osPriorityHigh5, .priority = (osPriority_t) osPriorityHigh5,
}; };

Loading…
Cancel
Save