增加了一键下载(不调试)的支持,并更新了makefile,添加了make clean支持
This commit is contained in:
parent
a539072052
commit
6dd2f9c504
|
@ -3,27 +3,29 @@
|
|||
"configurations": [
|
||||
// 使用dap-link(如无线调试器时的参考配置)
|
||||
{
|
||||
"name": "Debug-dap",
|
||||
"name": "Debug-DAP",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"executable": "${workspaceRoot}\\build\\basic_framework.elf", // 要下载到调试器的文件
|
||||
"executable": "${workspaceRoot}\\build\\${workspaceFolderBasename}.elf", // 要下载到调试器的文件,花括号中的是vscode两个预定义的参数
|
||||
"request": "launch",
|
||||
"type": "cortex-debug",
|
||||
"device": "STM32F407IG", //使用J-link GDB Server时必须;其他GBD Server时可选(有可能帮助自动选择SVD文件)。支持的设备见 https://www.segger.com/downloads/supported-devices.php
|
||||
"svdFile": ".\\STM32F407.svd", //svd文件,有这个文件才能查看寄存器的值,每个单片机都不同。可以在以下地址找到 https://github.com/posborne/cmsis-svd
|
||||
// 该项目的根目录已经提供了C型开发板使用的外设svd文件
|
||||
//使用J-link GDB Server时必须;其他GBD Server时可选(有可能帮助自动选择SVD文件)
|
||||
//支持的设备见 https://www.segger.com/downloads/supported-devices.php
|
||||
"device": "STM32F407IG",
|
||||
//svd文件,有这个文件才能查看寄存器的值,每个单片机都不同。可以在以下地址找到 https://github.com/posborne/cmsis-svd
|
||||
//该项目的根目录已经提供了C型开发板使用的外设svd文件
|
||||
"svdFile": "STM32F407.svd",
|
||||
"servertype": "openocd", //使用的GDB Server
|
||||
"configFiles": [
|
||||
".\\openocd.cfg", // 配置文件已经在根目录提供,若要修改以此类推,openocd的路径下的share/scripts中有各种写好的配置文件
|
||||
"openocd_dap.cfg", // 配置文件已经在根目录提供,若要修改以此类推,openocd的路径下的share/scripts中有各种写好的配置文件
|
||||
],
|
||||
// path to your gcc-arm-none-eabi/arm-none-eabi-gdb.exe,如果在cortex-debug的设置中写入了全局路径,这里不需要再写
|
||||
// "gdbPath": "D:\\gcc-arm-none-eabi\\bin\\arm-none-eabi-gdb.exe",
|
||||
//"preLaunchTask": "build task",//先运行Build任务,取消注释即可使用
|
||||
"runToEntryPoint": "main" // 调试时在main函数入口停下
|
||||
//"preLaunchTask": "build task",//先运行Build任务编译项目,取消注释即可使用
|
||||
},
|
||||
// 使用j-link时的参考配置
|
||||
// 使用j-link进行调试时的参考配置
|
||||
{
|
||||
"name": "Debug-jlink",
|
||||
"name": "Debug-Jlink",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"executable": "${workspaceRoot}\\build\\basic_framework.elf",
|
||||
"executable": "${workspaceRoot}\\build\\${workspaceFolderBasename}.elf",
|
||||
"request": "launch",
|
||||
"type": "cortex-debug",
|
||||
"device": "STM32F407IG",
|
||||
|
@ -31,8 +33,8 @@
|
|||
"showDevDebugOutput": "none",
|
||||
"servertype": "jlink",
|
||||
"interface": "swd",
|
||||
"svdFile": ".\\STM32F407.svd",
|
||||
"svdFile": "STM32F407.svd",
|
||||
// "preLaunchTask": "build task",//先运行Build任务,取消注释即可使用
|
||||
},
|
||||
]
|
||||
],
|
||||
}
|
|
@ -5,12 +5,30 @@
|
|||
{
|
||||
"label": "build task", // 任务标签
|
||||
"type": "shell", // 任务类型,因为要调用mingw32-make,是在终端(CMD)里运行的,所以是shell任务
|
||||
"command": "mingw32-make -j24",// 任务命令
|
||||
"command": "mingw32-make -j24",// 任务命令,线程数可以根据自己的电脑修改,建议为核数的4~8倍
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "download dap",
|
||||
"type": "shell",
|
||||
"command":"make download_dap",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": false,
|
||||
},
|
||||
},
|
||||
{
|
||||
"label": "download jlink",
|
||||
"type": "shell",
|
||||
"command":"make download_jlink",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": false,
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
|
@ -42,6 +42,8 @@
|
|||
#include "ins_task.h"
|
||||
#include "can_comm.h"
|
||||
#include "master_process.h"
|
||||
#include "led_task.h"
|
||||
#include "bsp_led.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
@ -127,6 +129,7 @@ int main(void)
|
|||
/* USER CODE BEGIN 2 */
|
||||
RC_init(&huart3);
|
||||
DWT_Init(168);
|
||||
|
||||
Motor_Init_Config_s config = {
|
||||
.motor_type = GM6020,
|
||||
.can_init_config = {
|
||||
|
@ -146,6 +149,7 @@ int main(void)
|
|||
RefereeInit(&huart6);
|
||||
Vision_Recv_s* recv=VisionInit(&huart1);
|
||||
Vision_Send_s send={.pitch=1,.roll=2,.yaw=3};
|
||||
LED_init();
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Call init function for freertos objects (in freertos.c) */
|
||||
|
@ -164,11 +168,12 @@ int main(void)
|
|||
/* USER CODE END WHILE */
|
||||
DJIMotorSetRef(djimotor, 10);
|
||||
MotorControlTask();
|
||||
HAL_Delay(10);
|
||||
HAL_Delay(1);
|
||||
CANCommSend(in, (uint8_t*)&tx);
|
||||
tx+=1;
|
||||
rx=(sdf*)CANCommGet(in);
|
||||
VisionSend(&send);
|
||||
led_RGB_flow_task();
|
||||
// INS_Task();
|
||||
/* USER CODE BEGIN 3 */
|
||||
}
|
||||
|
|
15
Makefile
15
Makefile
|
@ -292,8 +292,19 @@ $(BUILD_DIR):
|
|||
# clean up
|
||||
#######################################
|
||||
clean:
|
||||
-rm -r -Force $(BUILD_DIR)
|
||||
|
||||
rmdir /q $(BUILD_DIR)
|
||||
|
||||
#######################################
|
||||
# download without debugging
|
||||
#######################################
|
||||
OPENOCD_FLASH_START = 0x08000000 # 如果切换芯片可能需要修改此值
|
||||
|
||||
download_dap:
|
||||
openocd -f openocd_dap.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).hex $(OPENOCD_FLASH_START)" -c reset -c shutdown
|
||||
|
||||
download_jlink:
|
||||
openocd -f openocd_jlink.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).hex $(OPENOCD_FLASH_START)" -c reset -c shutdown
|
||||
|
||||
#######################################
|
||||
# dependencies
|
||||
#######################################
|
||||
|
|
|
@ -37,41 +37,37 @@ uint32_t RGB_flow_color[RGB_FLOW_COLOR_LENGHT + 1] = {0xFF0000FF, 0x0000FF00, 0x
|
|||
*/
|
||||
void led_RGB_flow_task()
|
||||
{
|
||||
uint16_t i, j;
|
||||
float delta_alpha, delta_red, delta_green, delta_blue;
|
||||
float alpha, red, green, blue;
|
||||
uint32_t aRGB;
|
||||
uint16_t i, j;
|
||||
float delta_alpha, delta_red, delta_green, delta_blue;
|
||||
float alpha, red, green, blue;
|
||||
uint32_t aRGB;
|
||||
|
||||
while (1)
|
||||
{
|
||||
for (i = 0; i < RGB_FLOW_COLOR_LENGHT; i++)
|
||||
{
|
||||
alpha = (RGB_flow_color[i] & 0xFF000000) >> 24;
|
||||
red = ((RGB_flow_color[i] & 0x00FF0000) >> 16);
|
||||
green = ((RGB_flow_color[i] & 0x0000FF00) >> 8);
|
||||
blue = ((RGB_flow_color[i] & 0x000000FF) >> 0);
|
||||
|
||||
for (i = 0; i < RGB_FLOW_COLOR_LENGHT; i++)
|
||||
{
|
||||
alpha = (RGB_flow_color[i] & 0xFF000000) >> 24;
|
||||
red = ((RGB_flow_color[i] & 0x00FF0000) >> 16);
|
||||
green = ((RGB_flow_color[i] & 0x0000FF00) >> 8);
|
||||
blue = ((RGB_flow_color[i] & 0x000000FF) >> 0);
|
||||
delta_alpha = (float)((RGB_flow_color[i + 1] & 0xFF000000) >> 24) - (float)((RGB_flow_color[i] & 0xFF000000) >> 24);
|
||||
delta_red = (float)((RGB_flow_color[i + 1] & 0x00FF0000) >> 16) - (float)((RGB_flow_color[i] & 0x00FF0000) >> 16);
|
||||
delta_green = (float)((RGB_flow_color[i + 1] & 0x0000FF00) >> 8) - (float)((RGB_flow_color[i] & 0x0000FF00) >> 8);
|
||||
delta_blue = (float)((RGB_flow_color[i + 1] & 0x000000FF) >> 0) - (float)((RGB_flow_color[i] & 0x000000FF) >> 0);
|
||||
|
||||
delta_alpha = (float)((RGB_flow_color[i + 1] & 0xFF000000) >> 24) - (float)((RGB_flow_color[i] & 0xFF000000) >> 24);
|
||||
delta_red = (float)((RGB_flow_color[i + 1] & 0x00FF0000) >> 16) - (float)((RGB_flow_color[i] & 0x00FF0000) >> 16);
|
||||
delta_green = (float)((RGB_flow_color[i + 1] & 0x0000FF00) >> 8) - (float)((RGB_flow_color[i] & 0x0000FF00) >> 8);
|
||||
delta_blue = (float)((RGB_flow_color[i + 1] & 0x000000FF) >> 0) - (float)((RGB_flow_color[i] & 0x000000FF) >> 0);
|
||||
delta_alpha /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_red /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_green /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_blue /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
for (j = 0; j < RGB_FLOW_COLOR_CHANGE_TIME; j++)
|
||||
{
|
||||
alpha += delta_alpha;
|
||||
red += delta_red;
|
||||
green += delta_green;
|
||||
blue += delta_blue;
|
||||
|
||||
delta_alpha /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_red /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_green /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_blue /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
for (j = 0; j < RGB_FLOW_COLOR_CHANGE_TIME; j++)
|
||||
{
|
||||
alpha += delta_alpha;
|
||||
red += delta_red;
|
||||
green += delta_green;
|
||||
blue += delta_blue;
|
||||
|
||||
aRGB = ((uint32_t)(alpha)) << 24 | ((uint32_t)(red)) << 16 | ((uint32_t)(green)) << 8 | ((uint32_t)(blue)) << 0;
|
||||
aRGB_led_show(aRGB);
|
||||
osDelay(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
aRGB = ((uint32_t)(alpha)) << 24 | ((uint32_t)(red)) << 16 | ((uint32_t)(green)) << 8 | ((uint32_t)(blue)) << 0;
|
||||
aRGB_led_show(aRGB);
|
||||
}
|
||||
}
|
||||
HAL_Delay(1);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* @brief 湖南大学RoBoMatster串口通信协议
|
||||
* @version 0.1
|
||||
* @date 2022-11-03
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "seasky_protocol.h"
|
||||
|
@ -38,7 +38,7 @@ static uint16_t CRC16_Check_Sum(uint8_t *pchMessage, uint32_t dwLength)
|
|||
}
|
||||
|
||||
/*检验数据帧头*/
|
||||
static uint8_t protocol_heade_Check(protocol_rm_struct *pro,uint8_t *rx_buf)
|
||||
static uint8_t protocol_heade_Check(protocol_rm_struct *pro, uint8_t *rx_buf)
|
||||
{
|
||||
if (rx_buf[0] == PROTOCOL_CMD_ID)
|
||||
{
|
||||
|
@ -58,12 +58,12 @@ static uint8_t protocol_heade_Check(protocol_rm_struct *pro,uint8_t *rx_buf)
|
|||
此函数根据待发送的数据更新数据帧格式以及内容,实现数据的打包操作
|
||||
后续调用通信接口的发送函数发送tx_buf中的对应数据
|
||||
*/
|
||||
void get_protocol_send_data(uint16_t send_id, //信号id
|
||||
void get_protocol_send_data(uint16_t send_id, // 信号id
|
||||
uint16_t flags_register, // 16位寄存器
|
||||
float *tx_data, //待发送的float数据
|
||||
float *tx_data, // 待发送的float数据
|
||||
uint8_t float_length, // float的数据长度
|
||||
uint8_t *tx_buf, //待发送的数据帧
|
||||
uint16_t *tx_buf_len) //待发送的数据帧长度
|
||||
uint8_t *tx_buf, // 待发送的数据帧
|
||||
uint16_t *tx_buf_len) // 待发送的数据帧长度
|
||||
{
|
||||
static uint16_t crc16;
|
||||
static uint16_t data_len;
|
||||
|
@ -71,9 +71,9 @@ void get_protocol_send_data(uint16_t send_id, //信号id
|
|||
data_len = float_length * 4 + 2;
|
||||
/*帧头部分*/
|
||||
tx_buf[0] = PROTOCOL_CMD_ID;
|
||||
tx_buf[1] = data_len & 0xff; //低位在前
|
||||
tx_buf[2] = (data_len >> 8) & 0xff; //低位在前
|
||||
tx_buf[3] = Get_CRC8_Check(&tx_buf[0], 3); //获取CRC8校验位
|
||||
tx_buf[1] = data_len & 0xff; // 低位在前
|
||||
tx_buf[2] = (data_len >> 8) & 0xff; // 低位在前
|
||||
tx_buf[3] = crc_8(&tx_buf[0], 3); // 获取CRC8校验位
|
||||
|
||||
/*数据的信号id*/
|
||||
tx_buf[4] = send_id & 0xff;
|
||||
|
@ -90,7 +90,7 @@ void get_protocol_send_data(uint16_t send_id, //信号id
|
|||
}
|
||||
|
||||
/*整包校验*/
|
||||
crc16 = Get_CRC16_Check(&tx_buf[0], data_len + 6);
|
||||
crc16 = crc_16(&tx_buf[0], data_len + 6);
|
||||
tx_buf[data_len + 6] = crc16 & 0xff;
|
||||
tx_buf[data_len + 7] = (crc16 >> 8) & 0xff;
|
||||
|
||||
|
@ -100,21 +100,21 @@ void get_protocol_send_data(uint16_t send_id, //信号id
|
|||
此函数用于处理接收数据,
|
||||
返回数据内容的id
|
||||
*/
|
||||
uint16_t get_protocol_info(uint8_t *rx_buf, //接收到的原始数据
|
||||
uint16_t *flags_register, //接收数据的16位寄存器地址
|
||||
uint8_t *rx_data) //接收的float数据存储地址
|
||||
uint16_t get_protocol_info(uint8_t *rx_buf, // 接收到的原始数据
|
||||
uint16_t *flags_register, // 接收数据的16位寄存器地址
|
||||
uint8_t *rx_data) // 接收的float数据存储地址
|
||||
{
|
||||
static protocol_rm_struct pro;
|
||||
static uint16_t date_length;
|
||||
volatile size_t s=sizeof(pro);
|
||||
volatile size_t aa=sizeof(Vision_Recv_s);
|
||||
volatile size_t s = sizeof(pro);
|
||||
volatile size_t aa = sizeof(Vision_Recv_s);
|
||||
if (protocol_heade_Check(&pro, rx_buf))
|
||||
{
|
||||
date_length = OFFSET_BYTE + pro.header.data_length;
|
||||
if (CRC16_Check_Sum(&rx_buf[0], date_length))
|
||||
{
|
||||
*flags_register = (rx_buf[7] << 8) | rx_buf[6];
|
||||
memcpy(rx_data,rx_buf+8,4*sizeof(pro.header.data_length - 2));
|
||||
memcpy(rx_data, rx_buf + 8, 4 * sizeof(pro.header.data_length - 2));
|
||||
return pro.cmd_id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# 选择调试器为jlink
|
||||
|
||||
source [find interface/jlink.cfg]
|
||||
# source [find interface/jlink.cfg] #使用jlink硬件进行调试,注意其他地方也要更改
|
||||
# OpenOCD作为GDB和硬件调试器的桥梁(为硬件提供抽象,把接口给GDB),支持多种硬件调试器.
|
||||
# OpenOCD会自动在其根目录的share/openocd/scripts/interface里面寻找对应的配置文件
|
||||
|
||||
# 选择接口为SWD
|
||||
transport select swd
|
||||
|
||||
# 选择目标芯片
|
||||
source [find target/stm32f4x.cfg]
|
||||
# OpenOCD会自动在其根目录的share/openocd/scripts/target里面寻找对应的配置文件
|
Loading…
Reference in New Issue