增加了额外的注释

This commit is contained in:
NeoZng 2023-01-02 23:50:04 +08:00
parent bfaae13b59
commit f37d813bcd
11 changed files with 37 additions and 17 deletions

View File

@ -2,7 +2,7 @@
#define CHASSIS_H #define CHASSIS_H
/** /**
* @brief ,rtos之前调用 * @brief ,rtos之前调用(RobotInit())
* *
*/ */
void ChassisInit(); void ChassisInit();

View File

@ -134,7 +134,7 @@ static void RemoteControlSet()
; // 弹舱舵机控制,待添加servo_motor模块,关闭 ; // 弹舱舵机控制,待添加servo_motor模块,关闭
// 摩擦轮控制,拨轮向上打为负,向下为正 // 摩擦轮控制,拨轮向上打为负,向下为正
if (rc_data[TEMP].rc.dial < -100) if (rc_data[TEMP].rc.dial < -100) // 向上超过100,打开摩擦轮
shoot_cmd_send.friction_mode = FRICTION_ON; shoot_cmd_send.friction_mode = FRICTION_ON;
else else
shoot_cmd_send.friction_mode = FRICTION_OFF; shoot_cmd_send.friction_mode = FRICTION_OFF;

View File

@ -1,8 +1,16 @@
#ifndef GIMBAL_CMD_H #ifndef GIMBAL_CMD_H
#define GIMBAL_CMD_H #define GIMBAL_CMD_H
/**
* @brief ,RobotInit()
*
*/
void RobotCMDInit(); void RobotCMDInit();
/**
* @brief ,200Hz频率运行()
*
*/
void RobotCMDTask(); void RobotCMDTask();
#endif // !GIMBAL_CMD_H #endif // !GIMBAL_CMD_H

View File

@ -2,7 +2,7 @@
#define GIMBAL_H #define GIMBAL_H
/** /**
* @brief * @brief ,RobotInit()
* *
*/ */
void GimbalInit(); void GimbalInit();

View File

@ -5,6 +5,7 @@
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD) #if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
#include "chassis.h" #include "chassis.h"
#endif #endif
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD) #if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
#include "gimbal.h" #include "gimbal.h"
#include "shoot.h" #include "shoot.h"

View File

@ -1,8 +1,18 @@
#ifndef ROBOT_H #ifndef ROBOT_H
#define ROBOT_H #define ROBOT_H
/* Robot利用robot_def.h中的宏对不同的机器人进行了大量的兼容,同时兼容了两个开发板(云台板和底盘板)的配置 */
/**
* @brief ,rtos之前调用.main函数的函数
*
*/
void RobotInit(); void RobotInit();
/**
* @brief ,,
*
*/
void RobotTask(); void RobotTask();
#endif #endif

View File

@ -21,6 +21,7 @@
// #define CHASSIS_BOARD //底盘板 // #define CHASSIS_BOARD //底盘板
// #define GIMBAL_BOARD //云台板 // #define GIMBAL_BOARD //云台板
// @todo: 增加机器人类型定义,后续是否要兼容所有机器人?(只兼容步兵英雄哨兵似乎就够了)
/* 机器人类型定义 */ /* 机器人类型定义 */
// #define ROBOT_HERO 1 // 英雄机器人 // #define ROBOT_HERO 1 // 英雄机器人
// #define ROBOT_ENINEER 2 // 工程机器人 // #define ROBOT_ENINEER 2 // 工程机器人
@ -46,11 +47,11 @@
#define RADIUS_WHEEL 60 // 轮子半径 #define RADIUS_WHEEL 60 // 轮子半径
#define REDUCTION_RATIO_WHEEL 19.0f // 电机减速比,因为编码器量测的是转子的速度而不是输出轴的速度故需进行转换 #define REDUCTION_RATIO_WHEEL 19.0f // 电机减速比,因为编码器量测的是转子的速度而不是输出轴的速度故需进行转换
// 检查是否出现定义冲突 // 检查是否出现定义冲突,只允许一个开发板定义存在,否则编译会自动报错
#if (defined(ONE_BOARD) && defined(CHASSIS_BOARD)) || \ #if (defined(ONE_BOARD) && defined(CHASSIS_BOARD)) || \
(defined(ONE_BOARD) && defined(GIMBAL_BOARD)) || \ (defined(ONE_BOARD) && defined(GIMBAL_BOARD)) || \
(defined(CHASSIS_BOARD) && defined(GIMBAL_BOARD)) (defined(CHASSIS_BOARD) && defined(GIMBAL_BOARD))
#error Conflict board definition! You can only define one type. #error Conflict board definition! You can only define one board type.
#endif #endif
#pragma pack(1) // 压缩结构体,取消字节对齐 #pragma pack(1) // 压缩结构体,取消字节对齐

View File

@ -205,7 +205,7 @@ void ShootTask()
DJIMotorSetRef(friction_l, 0); DJIMotorSetRef(friction_l, 0);
DJIMotorSetRef(friction_r, 0); DJIMotorSetRef(friction_r, 0);
break; break;
default: // 当前为了调试设定的4000,因为还没有加入裁判系统无法读取弹速.后续修改为while(1);表明模式错误 default: // 当前为了调试设定的默认值4000,因为还没有加入裁判系统无法读取弹速.
DJIMotorSetRef(friction_l, 4000); DJIMotorSetRef(friction_l, 4000);
DJIMotorSetRef(friction_r, 4000); DJIMotorSetRef(friction_r, 4000);
break; break;

View File

@ -2,7 +2,7 @@
#define SHOOT_H #define SHOOT_H
/** /**
* @brief * @brief ,RobotInit()
* *
*/ */
void ShootInit(); void ShootInit();

View File

@ -11,7 +11,7 @@ void BSPInit()
DWT_Init(168); DWT_Init(168);
BSPLogInit(); BSPLogInit();
// 下面都是待删除的,将在实现了module之后移动到app层 // legacy support待删除,将在实现了led/tempctrl/buzzer的module之后移动到app层
LEDInit(); LEDInit();
IMUTempInit(); IMUTempInit();
BuzzerInit(); BuzzerInit();

View File

@ -26,15 +26,15 @@ static uint8_t idx; // 全局CAN实例索引,每次有新的模块注册会自
static void CANAddFilter(CANInstance *_instance) static void CANAddFilter(CANInstance *_instance)
{ {
CAN_FilterTypeDef can_filter_conf; CAN_FilterTypeDef can_filter_conf;
static uint8_t can1_filter_idx = 0, can2_filter_idx = 14; static uint8_t can1_filter_idx = 0, can2_filter_idx = 14; // 0-13给can1用,14-27给can2用
can_filter_conf.FilterMode = CAN_FILTERMODE_IDLIST; can_filter_conf.FilterMode = CAN_FILTERMODE_IDLIST; //使用id list模式,即只有将rxid添加到过滤器中才会接收到,其他报文会被过滤
can_filter_conf.FilterScale = CAN_FILTERSCALE_16BIT; can_filter_conf.FilterScale = CAN_FILTERSCALE_16BIT; //使用16位id模式,即只有低16位有效
can_filter_conf.FilterFIFOAssignment = (_instance->tx_id & 1) ? CAN_RX_FIFO0 : CAN_RX_FIFO1; can_filter_conf.FilterFIFOAssignment = (_instance->tx_id & 1) ? CAN_RX_FIFO0 : CAN_RX_FIFO1; //奇数id的模块会被分配到FIFO0,偶数id的模块会被分配到FIFO1
can_filter_conf.SlaveStartFilterBank = 14; can_filter_conf.SlaveStartFilterBank = 14; // 从第14个过滤器开始配置从机过滤器(在STM32的BxCAN控制器中CAN2是CAN1的从机)
can_filter_conf.FilterIdLow = _instance->rx_id << 5; can_filter_conf.FilterIdLow = _instance->rx_id << 5; // 过滤器寄存器的低16位,因为使用STDID,所以只有低11位有效,高5位要填0
can_filter_conf.FilterBank = _instance->can_handle == &hcan1 ? (can1_filter_idx++) : (can2_filter_idx++); can_filter_conf.FilterBank = _instance->can_handle == &hcan1 ? (can1_filter_idx++) : (can2_filter_idx++); // 根据can_handle判断是CAN1还是CAN2,然后自增
can_filter_conf.FilterActivation = CAN_FILTER_ENABLE; can_filter_conf.FilterActivation = CAN_FILTER_ENABLE; // 启用过滤器
HAL_CAN_ConfigFilter(_instance->can_handle, &can_filter_conf); HAL_CAN_ConfigFilter(_instance->can_handle, &can_filter_conf);
} }