diff --git a/RBcore/BHBF.c b/RBcore/BHBF.c index a5ad215..76e082d 100644 --- a/RBcore/BHBF.c +++ b/RBcore/BHBF.c @@ -18,8 +18,7 @@ ******************************************************************************/ #include "BHBF.h" #include "common.h" - -#include "task.h" +#include "msg_center.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}; - RD_MEMSET(&tmpGV, 0, sizeof(tmpGV)); - RD_MEMCPY(&tmpGV, &GV, sizeof(GV_define)); - return &tmpGV; -} + if (NULL == pstMsg) + { + return; + } -void SetGV(GV_define *_pGV) -{ - RD_MEMCPY(&GV, _pGV, sizeof(GV_define)); + switch (pstMsg->m_uiMsgID) + { + 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) { - //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 = { -// .name = "GF_Task", -// .stack_size = 1024, -// .priority = (osPriority_t) osPriorityRealtime1, -// }; -// (void)osThreadNew(GF_Dispatch, NULL, &GF_Dispatch_attributes); + g_uiRBcoreModuleID = MsgCenter_Register(MODULE_NAME_RBCORE, RBcore_ModuleHandler); + + const osThreadAttr_t GF_Dispatch_attributes = { + .name = MODULE_NAME_RBCORE, + .stack_size = 1024, + .priority = (osPriority_t) osPriorityRealtime1, + }; + (void)osThreadNew(RBcore_Task, NULL, &GF_Dispatch_attributes); } diff --git a/RBcore/drv_interface.c b/RBcore/drv_interface.c index 21596e7..ed11d8e 100644 --- a/RBcore/drv_interface.c +++ b/RBcore/drv_interface.c @@ -255,6 +255,7 @@ void SendAll_Task(void *argument) } } +extern void RBcore_Init(void); extern void MotorInit(void); extern void MotorMgr_ParseResponse(uint8_t ucMotorID, const uint8_t *pucData, uint32_t uiLen); diff --git a/RBcore/include/BHBF.h b/RBcore/include/BHBF.h index 3d8aba7..2f295db 100644 --- a/RBcore/include/BHBF.h +++ b/RBcore/include/BHBF.h @@ -68,16 +68,21 @@ extern "C"{ /*==============================================* * constants or macros define * *----------------------------------------------*/ +#define MODULE_NAME_RBCORE "RBcore" #define MODULE_NAME_MOTOR "motor" typedef enum { - MOTOR_CMD_SET_SPEED = 0x01, // 设置速度 - MOTOR_CMD_SET_POSITION = 0x02, // 设置位置 - MOTOR_CMD_STOP = 0x03, // 停止 - MOTOR_CMD_GET_STATUS = 0x04, // 获取状态 - MOTOR_CMD_SET_HOME = 0x05, // 设置零点 - MOTOR_CMD_SPEED_MODE = 0x06, // 速度模式 - MOTOR_CMD_POSITION_MODE = 0x07, // 位置模式 + MOTOR_CMD_SET_SPEED = 0x0001, // 设置速度 + MOTOR_CMD_SET_POSITION, // 设置位置 + MOTOR_CMD_STOP, // 停止 + MOTOR_CMD_GET_STATUS, // 获取状态 + MOTOR_CMD_SET_HOME, // 设置零点 + MOTOR_CMD_SPEED_MODE, // 速度模式 + MOTOR_CMD_POSITION_MODE, // 位置模式 + + MOTOR_CMD_END = 0x0100, + RBCORE_CMD_MANUAL_FORWARD, + RBCORE_CMD_MANUAL_BACKWARD, } Motor_Cmd_e; // 电机命令数据结构 @@ -94,8 +99,6 @@ typedef struct { uint32_t m_uiFaultCode; } Motor_StatusData_t; -#define MODULE_NAME_RBCORE "RBcore" - typedef enum { GF_CMD_DEFAULT_NULL = 0, GF_CMD_STOP_ALL, @@ -120,9 +123,6 @@ typedef struct _GV_struct_define /*==============================================* * routines' or functions' implementations * *----------------------------------------------*/ -GV_define *GetGV(void); -void SetGV(GV_define *_pGV); -// 待实现接口 #ifdef __cplusplus #if __cplusplus diff --git a/motor/motor_example.c b/motor/motor_example.c index 0a07c64..01046cd 100644 --- a/motor/motor_example.c +++ b/motor/motor_example.c @@ -325,7 +325,7 @@ void MotorInit(void) // 创建电机任务 const osThreadAttr_t motor_task_attributes = { - .name = "motor_task", + .name = MODULE_NAME_MOTOR, .stack_size = 1024, .priority = (osPriority_t) osPriorityHigh5, };