From 6c56d4d19f25eeb14c15becba5d3ea7094eeffda Mon Sep 17 00:00:00 2001 From: kidneygood <2979564623@qq.com> Date: Sat, 19 Nov 2022 14:30:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BC=96=E8=AF=91=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E6=B6=88=E9=99=A4packed=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 54 ++---------------------------------- HAL_N_Middlewares/Src/main.c | 2 +- Makefile | 5 +--- bsp/bsp_usart.c | 2 ++ modules/referee/referee.h | 53 +++++++++++++++-------------------- 5 files changed, 29 insertions(+), 87 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 967911d..4d64b69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,54 +1,6 @@ { - "C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools", "files.associations": { - "arm_math.h": "c", - "task.h": "c", - "main.h": "c", - "cmsis_os.h": "c", - "freertos.h": "c", - "bmi088driver.h": "c", - "user_lib.h": "c", - "mpu_armv7.h": "c", - "stm32f4xx_hal.h": "c", - "stm32f4xx_hal_conf.h": "c", - "stm32_hal_legacy.h": "c", - "stm32f4xx.h": "c", - "cstdint": "c", - "tim.h": "c", - "struct_typedef.h": "c", - "bsp_can.h": "c", - "stdint.h": "c", - "bsp_temperature.h": "c", - "bsp_rc.h": "c", - "remote_control.h": "c", - "bsp_usart.h": "c", - "led_task.h": "c", - "can_receive.h": "c", - "can_process.h": "c", - "can.h": "c", - "stdlib.h": "c", - "lk9025.h": "c", - "dji_motor.h": "c", - "ht04.h": "c", - "controller.h": "c", - "memory.h": "c", - "motor_task.h": "c", - "functional": "c", - "stdexcept": "c", - "tuple": "c", - "typeinfo": "c", - "chrono": "c", - "complex": "c", - "usb_device.h": "c", - "vofa_protocol.h": "c", - "master_process.h": "c", - "stdint-gcc.h": "c", - "string.h": "c", - "motor_def.h": "c", - "stdio.h": "c", - "segger_rtt_conf.h": "c", - "segger_rtt.h": "c", - "bsp_log.h": "c", - "referee.h": "c" - } + "memory.h": "c" + }, + "C_Cpp.errorSquiggles": "Disabled" } \ No newline at end of file diff --git a/HAL_N_Middlewares/Src/main.c b/HAL_N_Middlewares/Src/main.c index 8a0d487..b8c8b3f 100644 --- a/HAL_N_Middlewares/Src/main.c +++ b/HAL_N_Middlewares/Src/main.c @@ -119,7 +119,7 @@ int main(void) RC_init(&huart3); DWT_Init(168); Motor_Init_Config_s config = { - .motor_type = M3508, + .motor_type = M2006, .can_init_config = { .can_handle = &hcan1, .tx_id = 1}, diff --git a/Makefile b/Makefile index a0c7040..66827ed 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,6 @@ HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_ HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \ HAL_N_Middlewares/Middlewares/Third_Party/SEGGER/RTT/SEGGER_RTT_printf.c \ HAL_N_Middlewares/Middlewares/Third_Party/SEGGER/RTT/SEGGER_RTT.c \ -\ \ bsp/bsp_dwt.c \ bsp/bsp_temperature.c \ bsp/bsp_led.c \ @@ -106,7 +105,6 @@ bsp/bsp_buzzer.c \ bsp/bsp_usart.c \ bsp/bsp_log.c \ bsp/bsp_init.c \ -\ \ modules/algorithm/controller.c \ modules/algorithm/kalman_filter.c \ modules/algorithm/QuaternionEKF.c \ @@ -130,7 +128,6 @@ modules/master_machine/seasky_protocol.c \ modules/algorithm/crc8.c \ modules/algorithm/crc16.c \ modules/can_comm/can_comm.c \ -\ \ application/gimbal.c \ application/chassis.c \ application/shoot.c \ @@ -190,7 +187,7 @@ C_DEFS = \ -DARM_MATH_ROUNDING # AS includes -AS_INCLUDES = +AS_INCLUDES = -IHAL_N_Middlewares/Inc # C includes C_INCLUDES = \ diff --git a/bsp/bsp_usart.c b/bsp/bsp_usart.c index c473608..3470139 100644 --- a/bsp/bsp_usart.c +++ b/bsp/bsp_usart.c @@ -10,6 +10,7 @@ */ #include "bsp_usart.h" #include "stdlib.h" +#include "memory.h" /* usart service instance, modules' info would be recoreded here using USARTRegister() */ /* usart服务实例,所有注册了usart的模块信息会被保存在这里 */ @@ -67,6 +68,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) { instance[i]->module_callback(); memset(instance[i]->recv_buff,0,instance[i]->recv_buff_size); + HAL_UARTEx_ReceiveToIdle_DMA(instance[i]->usart_handle, instance[i]->recv_buff, instance[i]->recv_buff_size); __HAL_DMA_DISABLE_IT(instance[i]->usart_handle->hdmarx, DMA_IT_HT); break; diff --git a/modules/referee/referee.h b/modules/referee/referee.h index d8e967c..57d9b04 100644 --- a/modules/referee/referee.h +++ b/modules/referee/referee.h @@ -1,9 +1,9 @@ /** * @file referee.h - * @author your name (you@domain.com) + * @author kidneygood (you@domain.com) * @brief * @version 0.1 - * @date 2022-11-04 + * @date 2022-11-18 * * @copyright Copyright (c) 2022 * @@ -14,10 +14,6 @@ #include"bsp_usart.h" #include"usart.h" -// #include "struct_typedef.h" -// #include "main.h" - - #define FALSE 0 #define TRUE 1 @@ -90,7 +86,7 @@ typedef enum } JudgeDataLength; /* 自定义帧头 */ -typedef __packed struct +typedef struct { uint8_t SOF; uint16_t DataLength; @@ -100,7 +96,7 @@ typedef __packed struct } xFrameHeader; /* ID: 0x0001 Byte: 3 比赛状态数据 */ -typedef __packed struct +typedef struct { uint8_t game_type : 4; uint8_t game_progress : 4; @@ -108,18 +104,13 @@ typedef __packed struct } ext_game_state_t; /* ID: 0x0002 Byte: 1 比赛结果数据 */ -typedef __packed struct +typedef struct { uint8_t winner; } ext_game_result_t; -/* ID: 0x0003 Byte: 2 比赛机器人血量数据 */ -// typedef __packed struct -// { -// uint16_t robot_legion; -// } ext_game_robot_survivors_t; - -typedef __packed struct +/* ID: 0x0003 Byte: 32 比赛机器人血量数据 */ +typedef struct { uint16_t red_1_robot_HP; uint16_t red_2_robot_HP; @@ -138,15 +129,15 @@ typedef __packed struct uint16_t blue_outpost_HP; uint16_t blue_base_HP; } ext_game_robot_HP_t; -/////////////////////////////////////////////////////////// + /* ID: 0x0101 Byte: 4 场地事件数据 */ -typedef __packed struct +typedef struct { uint32_t event_type; } ext_event_data_t; /* ID: 0x0102 Byte: 3 场地补给站动作标识数据 */ -typedef __packed struct +typedef struct { uint8_t supply_projectile_id; uint8_t supply_robot_id; @@ -155,7 +146,7 @@ typedef __packed struct } ext_supply_projectile_action_t; /* ID: 0X0201 Byte: 27 机器人状态数据 */ -typedef __packed struct +typedef struct { uint8_t robot_id; uint8_t robot_level; @@ -177,7 +168,7 @@ typedef __packed struct } ext_game_robot_state_t; /* ID: 0X0202 Byte: 14 实时功率热量数据 */ -typedef __packed struct +typedef struct { uint16_t chassis_volt; uint16_t chassis_current; @@ -188,7 +179,7 @@ typedef __packed struct } ext_power_heat_data_t; /* ID: 0x0203 Byte: 16 机器人位置数据 */ -typedef __packed struct +typedef struct { float x; float y; @@ -197,26 +188,26 @@ typedef __packed struct } ext_game_robot_pos_t; /* ID: 0x0204 Byte: 1 机器人增益数据 */ -typedef __packed struct +typedef struct { uint8_t power_rune_buff; } ext_buff_musk_t; /* ID: 0x0205 Byte: 1 空中机器人能量状态数据 */ -typedef __packed struct +typedef struct { uint8_t attack_time; } aerial_robot_energy_t; /* ID: 0x0206 Byte: 1 伤害状态数据 */ -typedef __packed struct +typedef struct { uint8_t armor_id : 4; uint8_t hurt_type : 4; } ext_robot_hurt_t; /* ID: 0x0207 Byte: 7 实时射击数据 */ -typedef __packed struct +typedef struct { uint8_t bullet_type; uint8_t shooter_id; @@ -256,7 +247,7 @@ typedef __packed struct 0x0116,空中操作手客户端(蓝)。 */ /* 交互数据接收信息:0x0301 */ -typedef __packed struct +typedef struct { uint16_t data_cmd_id; uint16_t send_ID; @@ -277,7 +268,7 @@ typedef __packed struct 18 1 自定义 8 位数据 4 */ -typedef __packed struct +typedef struct { float data1; float data2; @@ -300,14 +291,14 @@ typedef __packed struct 6 n 数据段 n 需要小于 113 */ -typedef __packed struct +typedef struct { uint8_t data[10]; //数据段,n需要小于113 } robot_interactive_data_t; //发送给客户端的信息 //帧头 命令码 数据段头结构 数据段 帧尾 -typedef __packed struct +typedef struct { xFrameHeader txFrameHeader; //帧头 uint16_t CmdID; //命令码 @@ -317,7 +308,7 @@ typedef __packed struct } ext_SendClientData_t; //机器人交互信息 -typedef __packed struct +typedef struct { xFrameHeader txFrameHeader; //帧头 uint16_t CmdID; //命令码