This commit is contained in:
Robofish 2026-02-04 16:16:53 +08:00
parent 05dae2219e
commit 62fdf6e4ea
18 changed files with 49 additions and 40 deletions

View File

@ -21,19 +21,19 @@
#define FDCAN1_FILTER_CONFIG_TABLE(X) \ #define FDCAN1_FILTER_CONFIG_TABLE(X) \
X(0, FDCAN_STANDARD_ID, FDCAN_FILTER_MASK, 0x000 , 0x000 , 0) \ X(0, FDCAN_STANDARD_ID, FDCAN_FILTER_MASK, 0x000 , 0x000 , 0) \
X(1, FDCAN_EXTENDED_ID, FDCAN_FILTER_MASK, 0x00000000, 0x00000000, 0) X(1, FDCAN_EXTENDED_ID, FDCAN_FILTER_MASK, 0x00000000, 0x00000000, 0)
#define FDCAN1_GLOBAL_FILTER FDCAN_REJECT, FDCAN_REJECT, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE/* 全局过滤器参数(用于 HAL_FDCAN_ConfigGlobalFilter */ #define FDCAN1_GLOBAL_FILTER FDCAN_ACCEPT_IN_RX_FIFO0, FDCAN_ACCEPT_IN_RX_FIFO0, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE
#endif #endif
#ifdef FDCAN2_EN #ifdef FDCAN2_EN
#define FDCAN2_FILTER_CONFIG_TABLE(X) \ #define FDCAN2_FILTER_CONFIG_TABLE(X) \
X(0, FDCAN_STANDARD_ID, FDCAN_FILTER_MASK, 0x000 , 0x000 , 0) \ X(0, FDCAN_STANDARD_ID, FDCAN_FILTER_MASK, 0x000 , 0x000 , 0) \
X(1, FDCAN_EXTENDED_ID, FDCAN_FILTER_MASK, 0x00000000, 0x00000000, 0) X(1, FDCAN_EXTENDED_ID, FDCAN_FILTER_MASK, 0x00000000, 0x00000000, 0)
#define FDCAN2_GLOBAL_FILTER FDCAN_ACCEPT_IN_RX_FIFO1, FDCAN_ACCEPT_IN_RX_FIFO1, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE/* 全局过滤器参数(用于 HAL_FDCAN_ConfigGlobalFilter */ #define FDCAN2_GLOBAL_FILTER FDCAN_ACCEPT_IN_RX_FIFO1, FDCAN_ACCEPT_IN_RX_FIFO1, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE
#endif #endif
#ifdef FDCAN3_EN #ifdef FDCAN3_EN
#define FDCAN3_FILTER_CONFIG_TABLE(X) \ #define FDCAN3_FILTER_CONFIG_TABLE(X) \
X(0, FDCAN_STANDARD_ID, FDCAN_FILTER_MASK, 0x000 , 0x000 , 0) \ X(0, FDCAN_STANDARD_ID, FDCAN_FILTER_MASK, 0x000 , 0x000 , 0) \
X(1, FDCAN_EXTENDED_ID, FDCAN_FILTER_MASK, 0x00000000, 0x00000000, 0) X(1, FDCAN_EXTENDED_ID, FDCAN_FILTER_MASK, 0x00000000, 0x00000000, 0)
#define FDCAN3_GLOBAL_FILTER FDCAN_REJECT, FDCAN_ACCEPT_IN_RX_FIFO1, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE/* 全局过滤器参数(用于 HAL_FDCAN_ConfigGlobalFilter */ #define FDCAN3_GLOBAL_FILTER FDCAN_ACCEPT_IN_RX_FIFO1, FDCAN_ACCEPT_IN_RX_FIFO1, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE
#endif #endif
/* ====宏展开实现==== */ /* ====宏展开实现==== */

View File

@ -90,6 +90,7 @@ int8_t BSP_GPIO_EnableIRQ(BSP_GPIO_t gpio) {
default: default:
return BSP_ERR; return BSP_ERR;
} }
return BSP_OK;
} }
int8_t BSP_GPIO_DisableIRQ(BSP_GPIO_t gpio) { int8_t BSP_GPIO_DisableIRQ(BSP_GPIO_t gpio) {
@ -107,6 +108,7 @@ int8_t BSP_GPIO_DisableIRQ(BSP_GPIO_t gpio) {
default: default:
return BSP_ERR; return BSP_ERR;
} }
return BSP_OK;
} }
int8_t BSP_GPIO_WritePin(BSP_GPIO_t gpio, bool value){ int8_t BSP_GPIO_WritePin(BSP_GPIO_t gpio, bool value){
if (gpio >= BSP_GPIO_NUM) return BSP_ERR; if (gpio >= BSP_GPIO_NUM) return BSP_ERR;

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <sys/_intsup.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -31,7 +30,6 @@ typedef struct {
} gyro_offset; /* 陀螺仪偏置 */ } gyro_offset; /* 陀螺仪偏置 */
} BMI088_Cali_t; /* BMI088校准数据 */ } BMI088_Cali_t; /* BMI088校准数据 */
typedef struct { typedef struct {
DEVICE_Header_t header; DEVICE_Header_t header;
AHRS_Accl_t accl; AHRS_Accl_t accl;

View File

@ -29,6 +29,10 @@ motor_lz:
motor_rm: motor_rm:
bsp_config: {} bsp_config: {}
enabled: true enabled: true
mrobot:
bsp_config:
BSP_UART_MROBOT: BSP_UART_VOFA
enabled: true
vofa: vofa:
bsp_config: bsp_config:
BSP_UART_VOFA: BSP_UART_VOFA BSP_UART_VOFA: BSP_UART_VOFA

View File

@ -120,7 +120,7 @@ static void send_string(const char *str) {
if (str == NULL || *str == '\0') return; if (str == NULL || *str == '\0') return;
ctx.tx_complete = false; ctx.tx_complete = false;
BSP_UART_Transmit(MROBOT_UART_PORT, (uint8_t *)str, strlen(str), true); BSP_UART_Transmit(BSP_UART_VOFA, (uint8_t *)str, strlen(str), true);
while (!ctx.tx_complete) { osDelay(1); } while (!ctx.tx_complete) { osDelay(1); }
} }
@ -151,7 +151,7 @@ static void uart_rx_callback(void) {
if (ch == 'q' || ch == 'Q' || ch == 27) { if (ch == 'q' || ch == 'Q' || ch == 27) {
ctx.htop_exit = true; ctx.htop_exit = true;
} }
BSP_UART_Receive(MROBOT_UART_PORT, &ctx.uart_rx_char, 1, false); BSP_UART_Receive(BSP_UART_VOFA, &ctx.uart_rx_char, 1, false);
return; return;
} }
@ -160,19 +160,19 @@ static void uart_rx_callback(void) {
if (ctx.cmd_index > 0) { if (ctx.cmd_index > 0) {
ctx.cmd_buffer[ctx.cmd_index] = '\0'; ctx.cmd_buffer[ctx.cmd_index] = '\0';
ctx.cmd_ready = true; ctx.cmd_ready = true;
BSP_UART_Transmit(MROBOT_UART_PORT, (uint8_t *)"\r\n", 2, false); BSP_UART_Transmit(BSP_UART_VOFA, (uint8_t *)"\r\n", 2, false);
} }
} else if (ch == 127 || ch == 8) { /* 退格键 */ } else if (ch == 127 || ch == 8) { /* 退格键 */
if (ctx.cmd_index > 0) { if (ctx.cmd_index > 0) {
ctx.cmd_index--; ctx.cmd_index--;
BSP_UART_Transmit(MROBOT_UART_PORT, (uint8_t *)ANSI_BACKSPACE, 3, false); BSP_UART_Transmit(BSP_UART_VOFA, (uint8_t *)ANSI_BACKSPACE, 3, false);
} }
} else if (ch >= 32 && ch < 127 && ctx.cmd_index < sizeof(ctx.cmd_buffer) - 1) { } else if (ch >= 32 && ch < 127 && ctx.cmd_index < sizeof(ctx.cmd_buffer) - 1) {
ctx.cmd_buffer[ctx.cmd_index++] = ch; ctx.cmd_buffer[ctx.cmd_index++] = ch;
BSP_UART_Transmit(MROBOT_UART_PORT, &ch, 1, false); BSP_UART_Transmit(BSP_UART_VOFA, &ch, 1, false);
} }
BSP_UART_Receive(MROBOT_UART_PORT, &ctx.uart_rx_char, 1, false); BSP_UART_Receive(BSP_UART_VOFA, &ctx.uart_rx_char, 1, false);
} }
/* ========================================================================== */ /* ========================================================================== */
@ -500,11 +500,11 @@ void MRobot_Init(void) {
} }
/* 注册 UART 回调 */ /* 注册 UART 回调 */
BSP_UART_RegisterCallback(MROBOT_UART_PORT, BSP_UART_RX_CPLT_CB, uart_rx_callback); BSP_UART_RegisterCallback(BSP_UART_VOFA, BSP_UART_RX_CPLT_CB, uart_rx_callback);
BSP_UART_RegisterCallback(MROBOT_UART_PORT, BSP_UART_TX_CPLT_CB, uart_tx_callback); BSP_UART_RegisterCallback(BSP_UART_VOFA, BSP_UART_TX_CPLT_CB, uart_tx_callback);
/* 启动 UART 接收 */ /* 启动 UART 接收 */
BSP_UART_Receive(MROBOT_UART_PORT, &ctx.uart_rx_char, 1, false); BSP_UART_Receive(BSP_UART_VOFA, &ctx.uart_rx_char, 1, false);
/* 等待用户按下回车 */ /* 等待用户按下回车 */
while (ctx.uart_rx_char != '\r' && ctx.uart_rx_char != '\n') { while (ctx.uart_rx_char != '\r' && ctx.uart_rx_char != '\n') {

View File

@ -143,10 +143,6 @@ extern "C" {
#define MROBOT_HTOP_REFRESH_MS 200 /* htop 刷新间隔 (ms) */ #define MROBOT_HTOP_REFRESH_MS 200 /* htop 刷新间隔 (ms) */
#endif #endif
#ifndef MROBOT_UART_PORT
#define MROBOT_UART_PORT BSP_UART_VOFA /* 默认 UART 端口 */
#endif
#ifndef MROBOT_USER_NAME #ifndef MROBOT_USER_NAME
#define MROBOT_USER_NAME "root" /* CLI 用户名 */ #define MROBOT_USER_NAME "root" /* CLI 用户名 */
#endif #endif

View File

@ -23,6 +23,9 @@ Gimbal_AI_t ai_for_gimbal;
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_ai(void *argument) { void Task_ai(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */

View File

@ -51,27 +51,9 @@ static const KPID_Params_t imu_temp_ctrl_pid_param = {
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/** /* USER PRIVATE CODE END */
* @brief IMU
*/
static int print_imu_callback(const void *data, char *buffer, size_t size) {
const BMI088_t *imu = (const BMI088_t *)data;
#define RAD2DEG 57.2957795131f
return MRobot_Snprintf(buffer, size,
" Status : %s\r\n"
" Accel : X=%.3f Y=%.3f Z=%.3f (m/s^2)\r\n"
" Gyro : X=%.3f Y=%.3f Z=%.3f (rad/s)\r\n"
" Euler : R=%.2f P=%.2f Y=%.2f (deg)\r\n"
" Temp : %.1f C\r\n",
imu->header.online ? "Online" : "Offline",
imu->accl.x, imu->accl.y, imu->accl.z,
imu->gyro.x, imu->gyro.y, imu->gyro.z,
eulr_to_send.rol * RAD2DEG, eulr_to_send.pit * RAD2DEG, eulr_to_send.yaw * RAD2DEG,
imu->temp);
}
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_atti_esit(void *argument) { void Task_atti_esit(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */

View File

@ -20,6 +20,9 @@ static uint16_t count;
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_blink(void *argument) { void Task_blink(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */

View File

@ -18,6 +18,7 @@
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/** /**
* @brief hello * @brief hello
* @note 0 (pdFALSE) 0 * @note 0 (pdFALSE) 0
@ -27,6 +28,7 @@ static long Cli_Hello(char *buffer, size_t size, const char *cmd) {
MRobot_Snprintf(buffer, size, "Ciallo(∠・ω< )⌒★\r\n"); MRobot_Snprintf(buffer, size, "Ciallo(∠・ω< )⌒★\r\n");
return 0; /* 返回0表示命令执行完成 */ return 0; /* 返回0表示命令执行完成 */
} }
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_cli(void *argument) { void Task_cli(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */

View File

@ -32,6 +32,9 @@ Chassis_IMU_t chassis_imu;
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_ctrl_chassis(void *argument) { void Task_ctrl_chassis(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */

View File

@ -24,6 +24,9 @@ Gimbal_AI_t gimbal_ai;
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_ctrl_gimbal(void *argument) { void Task_ctrl_gimbal(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */

View File

@ -20,9 +20,13 @@ Shoot_CMD_t shoot_cmd;
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_ctrl_shoot(void *argument) { void Task_ctrl_shoot(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */
/* 计算任务运行到指定频率需要等待的tick数 */ /* 计算任务运行到指定频率需要等待的tick数 */
const uint32_t delay_tick = osKernelGetTickFreq() / CTRL_SHOOT_FREQ; const uint32_t delay_tick = osKernelGetTickFreq() / CTRL_SHOOT_FREQ;

View File

@ -40,7 +40,7 @@ void Task_Init(void *argument) {
task_runtime.thread.blink = osThreadNew(Task_blink, NULL, &attr_blink); task_runtime.thread.blink = osThreadNew(Task_blink, NULL, &attr_blink);
task_runtime.thread.ctrl_shoot = osThreadNew(Task_ctrl_shoot, NULL, &attr_ctrl_shoot); task_runtime.thread.ctrl_shoot = osThreadNew(Task_ctrl_shoot, NULL, &attr_ctrl_shoot);
task_runtime.thread.ai = osThreadNew(Task_ai, NULL, &attr_ai); task_runtime.thread.ai = osThreadNew(Task_ai, NULL, &attr_ai);
// task_runtime.thread.vofa = osThreadNew(Task_vofa, NULL, &attr_vofa); task_runtime.thread.vofa = osThreadNew(Task_vofa, NULL, &attr_vofa);
task_runtime.thread.cli = osThreadNew(Task_cli, NULL, &attr_cli); task_runtime.thread.cli = osThreadNew(Task_cli, NULL, &attr_cli);
// 创建消息队列 // 创建消息队列

View File

@ -18,6 +18,9 @@
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_monitor(void *argument) { void Task_monitor(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */

View File

@ -25,6 +25,9 @@ Gimbal_CMD_t cmd_for_gimbal;
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_rc(void *argument) { void Task_rc(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */

View File

@ -57,5 +57,5 @@ const osThreadAttr_t attr_vofa = {
const osThreadAttr_t attr_cli = { const osThreadAttr_t attr_cli = {
.name = "cli", .name = "cli",
.priority = osPriorityNormal, .priority = osPriorityNormal,
.stack_size = 256 * 16, .stack_size = 1024 * 4,
}; };

View File

@ -19,6 +19,9 @@ Chassis_t chassis_vofa;
/* USER STRUCT END */ /* USER STRUCT END */
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* USER PRIVATE CODE BEGIN */
/* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_vofa(void *argument) { void Task_vofa(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */