From 334c0b057e7d20e6fe1e7025c4bdf54500237556 Mon Sep 17 00:00:00 2001 From: caixiang2014 <953748225@qq.com> Date: Fri, 14 Aug 2026 18:38:51 +0800 Subject: [PATCH] fix: enable stable USB VCOM logging --- .config | 32 +- applications/VK_Client.c | 12 + applications/VK_Log.c | 40 ++- applications/VK_Log.h | 2 +- applications/main.c | 19 +- board/CubeMX_Config/Src/stm32f1xx_hal_msp.c | 5 +- libraries/HAL_Drivers/drivers/drv_usbd.c | 4 +- project.uvprojx | 305 ++++++++++++-------- rtconfig.h | 20 +- 9 files changed, 269 insertions(+), 170 deletions(-) diff --git a/.config b/.config index 903b7db..ce57fe3 100644 --- a/.config +++ b/.config @@ -92,7 +92,7 @@ CONFIG_ARCH_ARM_CORTEX_M3=y # CONFIG_RT_USING_COMPONENTS_INIT=y CONFIG_RT_USING_USER_MAIN=y -CONFIG_RT_MAIN_THREAD_STACK_SIZE=1536 +CONFIG_RT_MAIN_THREAD_STACK_SIZE=1024 CONFIG_RT_MAIN_THREAD_PRIORITY=10 # CONFIG_RT_USING_LEGACY is not set @@ -149,8 +149,28 @@ CONFIG_RT_USING_PIN=y # # Using USB # +CONFIG_RT_USING_USB=y # CONFIG_RT_USING_USB_HOST is not set -# CONFIG_RT_USING_USB_DEVICE is not set +CONFIG_RT_USING_USB_DEVICE=y +CONFIG_RT_USBD_THREAD_STACK_SZ=1024 +CONFIG_USB_VENDOR_ID=0x0FFE +CONFIG_USB_PRODUCT_ID=0x0001 +# CONFIG_RT_USB_DEVICE_COMPOSITE is not set +# CONFIG__RT_USB_DEVICE_NONE is not set +CONFIG__RT_USB_DEVICE_CDC=y +# CONFIG__RT_USB_DEVICE_MSTORAGE is not set +# CONFIG__RT_USB_DEVICE_HID is not set +# CONFIG__RT_USB_DEVICE_RNDIS is not set +# CONFIG__RT_USB_DEVICE_ECM is not set +# CONFIG__RT_USB_DEVICE_WINUSB is not set +# CONFIG__RT_USB_DEVICE_AUDIO is not set +CONFIG_RT_USB_DEVICE_CDC=y +CONFIG_RT_VCOM_TASK_STK_SIZE=1024 +CONFIG_RT_CDC_RX_BUFSIZE=128 +# CONFIG_RT_VCOM_TX_USE_DMA is not set +CONFIG_RT_VCOM_SERNO="32021919830108" +CONFIG_RT_VCOM_SER_LEN=14 +CONFIG_RT_VCOM_TX_TIMEOUT=1000 # end of Using USB # end of Device Drivers @@ -229,11 +249,7 @@ CONFIG_ULOG_OUTPUT_LVL=7 CONFIG_ULOG_USING_ISR_LOG=y CONFIG_ULOG_ASSERT_ENABLE=y CONFIG_ULOG_LINE_BUF_SIZE=128 -CONFIG_ULOG_USING_ASYNC_OUTPUT=y -CONFIG_ULOG_ASYNC_OUTPUT_BUF_SIZE=512 -CONFIG_ULOG_ASYNC_OUTPUT_BY_THREAD=y -CONFIG_ULOG_ASYNC_OUTPUT_THREAD_STACK=1024 -CONFIG_ULOG_ASYNC_OUTPUT_THREAD_PRIORITY=20 +# CONFIG_ULOG_USING_ASYNC_OUTPUT is not set # # log format @@ -1290,7 +1306,7 @@ CONFIG_SOC_SERIES_STM32F1=y # On-chip Peripheral Drivers # CONFIG_BSP_USING_GPIO=y -# CONFIG_BSP_USING_USBD is not set +CONFIG_BSP_USING_USBD=y CONFIG_BSP_USING_UART=y CONFIG_BSP_USING_UART1=y # CONFIG_BSP_UART1_RX_USING_DMA is not set diff --git a/applications/VK_Client.c b/applications/VK_Client.c index 59aa7a1..c5448a6 100644 --- a/applications/VK_Client.c +++ b/applications/VK_Client.c @@ -8,9 +8,21 @@ #include "rtdef.h" #include "rtthread.h" #include "rttypes.h" + +#if defined(__CC_ARM) && !defined(__clang__) +#define VK_MAVLINK_DO_PRAGMA(x) _Pragma(#x) +#define __pragma(x) VK_MAVLINK_DO_PRAGMA(x) +#pragma anon_unions +#endif + #include "VKFly/mavlink.h" #include "mavlink_helpers.h" +#if defined(__CC_ARM) && !defined(__clang__) +#undef __pragma +#undef VK_MAVLINK_DO_PRAGMA +#endif + #define DBG_TAG "LINK_LOG" #define DBG_LVL DBG_INFO #include "rtdbg.h" diff --git a/applications/VK_Log.c b/applications/VK_Log.c index 482a103..17ae994 100644 --- a/applications/VK_Log.c +++ b/applications/VK_Log.c @@ -1,29 +1,37 @@ #include "VK_Log.h" #include -static struct ulog_backend dev_backend; - +static struct ulog_backend vcom_backend; static rt_device_t log_dev = RT_NULL; - -static void dev_log_output(struct ulog_backend *backend, - rt_uint32_t level, - const char *tag, - rt_bool_t is_raw, - const char *log, - size_t len) +static void vcom_log_output(struct ulog_backend *backend, + rt_uint32_t level, + const char *tag, + rt_bool_t is_raw, + const char *log, + size_t len) { + (void)backend; + (void)level; + (void)tag; + (void)is_raw; + if (log_dev != RT_NULL && len > 0) { - rt_device_write(log_dev, 0, log, len); + (void)rt_device_write(log_dev, 0, log, len); } } +int dev_log_backend_init(rt_device_t dev) +{ + if (dev == RT_NULL) + { + return -RT_EINVAL; + } -int dev_log_backend_init(rt_device_t dev){ - log_dev = dev; - rt_memset(&dev_backend, 0 , sizeof(dev_backend)); - dev_backend.output = dev_log_output; + log_dev = dev; + rt_memset(&vcom_backend, 0, sizeof(vcom_backend)); + vcom_backend.output = vcom_log_output; - return ulog_backend_register(&dev_backend, "uart3", RT_FALSE); -} \ No newline at end of file + return ulog_backend_register(&vcom_backend, "vcom", RT_FALSE); +} diff --git a/applications/VK_Log.h b/applications/VK_Log.h index 4bc536a..a4f8024 100644 --- a/applications/VK_Log.h +++ b/applications/VK_Log.h @@ -14,4 +14,4 @@ int dev_log_backend_init(rt_device_t dev); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/applications/main.c b/applications/main.c index a4e785f..5ce6387 100644 --- a/applications/main.c +++ b/applications/main.c @@ -21,7 +21,7 @@ #include "drv_ec800k.h" #include "VK_Log.h" -static rt_device_t u2, u3; +static rt_device_t u2, u3, vcom; static void task_let_entry(void *arg) { client_task(); } @@ -29,24 +29,31 @@ static void task_com_entry(void *arg) { com_task(); } int main(void) { - // rt_device_t vcom = rt_device_find("vcom"); - // rt_device_open(vcom, RT_DEVICE_FLAG_RDWR); - // rt_console_set_device("vcom"); + /* Bring up diagnostics before UART initialization can fail. */ + vcom = rt_device_find("vcom"); + if (vcom != RT_NULL && + rt_device_open(vcom, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM) == RT_EOK) { + dev_log_backend_init(vcom); + } u3 = rt_device_find("uart3"); + if (u3 == RT_NULL) { + return -RT_ERROR; + } rt_device_open(u3, RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_INT_TX | RT_DEVICE_FLAG_RX_NON_BLOCKING | RT_DEVICE_FLAG_TX_BLOCKING); fmu_com_register(u3); u2 = rt_device_find("uart2"); + if (u2 == RT_NULL) { + return -RT_ERROR; + } rt_device_open(u2, RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_INT_TX | RT_DEVICE_FLAG_RX_NON_BLOCKING | RT_DEVICE_FLAG_TX_BLOCKING); BSP_LET_Register_Com(u2); - //初始化ulog端口 - dev_log_backend_init(u3); /* 创建任务2和任务3,分别从U2和U3收发数据 */ lte_dev.tid1 = rt_thread_create("lte", task_let_entry, RT_NULL, 2048, 10, 5); diff --git a/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c b/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c index 9f016e3..bdaddfa 100644 --- a/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c +++ b/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c @@ -245,9 +245,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) /* Peripheral clock enable */ __HAL_RCC_USB_CLK_ENABLE(); /* USB interrupt Init */ - HAL_NVIC_SetPriority(USB_HP_CAN1_TX_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(USB_HP_CAN1_TX_IRQn); - HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0); + HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 2, 0); HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); /* USER CODE BEGIN USB_MspInit 1 */ @@ -274,7 +272,6 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) __HAL_RCC_USB_CLK_DISABLE(); /* USB interrupt DeInit */ - HAL_NVIC_DisableIRQ(USB_HP_CAN1_TX_IRQn); HAL_NVIC_DisableIRQ(USB_LP_CAN1_RX0_IRQn); /* USER CODE BEGIN USB_MspDeInit 1 */ diff --git a/libraries/HAL_Drivers/drivers/drv_usbd.c b/libraries/HAL_Drivers/drivers/drv_usbd.c index 6acfad2..189342c 100644 --- a/libraries/HAL_Drivers/drivers/drv_usbd.c +++ b/libraries/HAL_Drivers/drivers/drv_usbd.c @@ -112,14 +112,14 @@ void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) { if (state == 1) { -#if defined(SOC_SERIES_STM32F1) +#if defined(SOC_SERIES_STM32F1) && (BSP_USB_CONNECT_PIN >= 0) rt_pin_mode(BSP_USB_CONNECT_PIN,PIN_MODE_OUTPUT); rt_pin_write(BSP_USB_CONNECT_PIN, BSP_USB_PULL_UP_STATUS); #endif } else { -#if defined(SOC_SERIES_STM32F1) +#if defined(SOC_SERIES_STM32F1) && (BSP_USB_CONNECT_PIN >= 0) rt_pin_mode(BSP_USB_CONNECT_PIN,PIN_MODE_OUTPUT); rt_pin_write(BSP_USB_CONNECT_PIN, !BSP_USB_PULL_UP_STATUS); #endif diff --git a/project.uvprojx b/project.uvprojx index 8c0db5c..26ca436 100644 --- a/project.uvprojx +++ b/project.uvprojx @@ -10,7 +10,7 @@ DTU_4G 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::ARMCC + 5060750::V5.06 update 6 (build 750)::.\ARMCC 0 @@ -186,6 +186,7 @@ 0 0 0 + 0 0 0 8 @@ -337,9 +338,9 @@ 0 - STM32F103xB, __STDC_LIMIT_MACROS, RT_USING_ARMLIBC, USE_HAL_DRIVER, RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, __RTTHREAD__ + STM32F103xB, __RTTHREAD__, __STDC_LIMIT_MACROS, __CLK_TCK=RT_TICK_PER_SECOND, RT_USING_LIBC, RT_USING_ARMLIBC, USE_HAL_DRIVER - ..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\libcpu\arm\cortex-m3;..\libraries\HAL_Drivers\CMSIS\Include;..\libraries\STM32F1xx_HAL\CMSIS\Device\ST\STM32F1xx\Include;..\..\..\components\libc\compilers\common\include;board;board\ports;..\libraries\HAL_Drivers\drivers;..\libraries\HAL_Drivers\drivers\config;..\..\..\components\finsh;.;..\..\..\components\libc\posix\io\epoll;..\..\..\libcpu\arm\common;..\libraries\HAL_Drivers;..\..\..\components\drivers\include;..\..\..\include;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\libc\posix\io\poll;board\CubeMX_Config\Inc;..\..\..\components\drivers\include;applications;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Inc;..\..\..\components\drivers\include;..\..\..\components\libc\posix\ipc + libraries\HAL_Drivers;libraries\STM32F1xx_HAL\CMSIS\Device\ST\STM32F1xx\Include;..\rt-thread\rt-thread-v5.1.0\components\drivers\include;board\CubeMX_Config\Inc;..\rt-thread\rt-thread-v5.1.0\components\utilities\ulog;libraries\HAL_Drivers\CMSIS\Include;lib\mavlink\v2.0;..\rt-thread\rt-thread-v5.1.0\libcpu\arm\common;..\rt-thread\rt-thread-v5.1.0\components\libc\posix\io\eventfd;..\rt-thread\rt-thread-v5.1.0\components\libc\posix\io\poll;..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\include;..\rt-thread\rt-thread-v5.1.0\components\drivers\include;..\rt-thread\rt-thread-v5.1.0\components\libc\posix\io\epoll;..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\extension;..\rt-thread\rt-thread-v5.1.0\include;libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Inc;..\rt-thread\rt-thread-v5.1.0\components\libc\posix\ipc;libraries\HAL_Drivers\drivers\config;libraries\HAL_Drivers\drivers;..\rt-thread\rt-thread-v5.1.0\components\drivers\include;applications;board\ports;..\rt-thread\rt-thread-v5.1.0\components\drivers\usb\usbdevice;board;..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\extension\fcntl\octal;..\rt-thread\rt-thread-v5.1.0\components\drivers\include;..\rt-thread\rt-thread-v5.1.0\libcpu\arm\cortex-m3;. @@ -383,6 +384,26 @@ Applications + + drv_ec800k.c + 1 + applications\drv_ec800k.c + + + VK_Client.c + 1 + applications\VK_Client.c + + + VK_Com.c + 1 + applications\VK_Com.c + + + VK_Log.c + 1 + applications\VK_Log.c + main.c 1 @@ -396,42 +417,42 @@ syscall_mem.c 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c + ..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\armlibc\syscall_mem.c syscalls.c 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c + ..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\armlibc\syscalls.c cctype.c 1 - ..\..\..\components\libc\compilers\common\cctype.c + ..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\cctype.c cstdlib.c 1 - ..\..\..\components\libc\compilers\common\cstdlib.c + ..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\cstdlib.c cstring.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\cstring.c ctime.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\ctime.c cunistd.c 1 - ..\..\..\components\libc\compilers\common\cunistd.c + ..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\cunistd.c cwchar.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\rt-thread\rt-thread-v5.1.0\components\libc\compilers\common\cwchar.c @@ -441,7 +462,7 @@ device.c 1 - ..\..\..\components\drivers\core\device.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\core\device.c 2 @@ -488,7 +509,7 @@ __RT_IPC_SOURCE__ - + @@ -497,7 +518,7 @@ completion.c 1 - ..\..\..\components\drivers\ipc\completion.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\ipc\completion.c 2 @@ -544,7 +565,7 @@ __RT_IPC_SOURCE__ - + @@ -553,7 +574,7 @@ condvar.c 1 - ..\..\..\components\drivers\ipc\condvar.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\ipc\condvar.c 2 @@ -600,7 +621,7 @@ __RT_IPC_SOURCE__ - + @@ -609,7 +630,7 @@ dataqueue.c 1 - ..\..\..\components\drivers\ipc\dataqueue.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\ipc\dataqueue.c 2 @@ -656,7 +677,7 @@ __RT_IPC_SOURCE__ - + @@ -665,7 +686,7 @@ pipe.c 1 - ..\..\..\components\drivers\ipc\pipe.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\ipc\pipe.c 2 @@ -712,7 +733,7 @@ __RT_IPC_SOURCE__ - + @@ -721,7 +742,7 @@ ringblk_buf.c 1 - ..\..\..\components\drivers\ipc\ringblk_buf.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\ipc\ringblk_buf.c 2 @@ -768,7 +789,7 @@ __RT_IPC_SOURCE__ - + @@ -777,7 +798,7 @@ ringbuffer.c 1 - ..\..\..\components\drivers\ipc\ringbuffer.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\ipc\ringbuffer.c 2 @@ -824,7 +845,7 @@ __RT_IPC_SOURCE__ - + @@ -833,7 +854,7 @@ waitqueue.c 1 - ..\..\..\components\drivers\ipc\waitqueue.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\ipc\waitqueue.c 2 @@ -880,7 +901,7 @@ __RT_IPC_SOURCE__ - + @@ -889,7 +910,7 @@ workqueue.c 1 - ..\..\..\components\drivers\ipc\workqueue.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\ipc\workqueue.c 2 @@ -936,7 +957,7 @@ __RT_IPC_SOURCE__ - + @@ -945,7 +966,7 @@ pin.c 1 - ..\..\..\components\drivers\pin\pin.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\pin\pin.c 2 @@ -992,16 +1013,16 @@ __RT_IPC_SOURCE__ - + - serial.c + serial_v2.c 1 - ..\..\..\components\drivers\serial\serial.c + ..\rt-thread\rt-thread-v5.1.0\components\drivers\serial\serial_v2.c 2 @@ -1048,7 +1069,7 @@ __RT_IPC_SOURCE__ - + @@ -1059,26 +1080,6 @@ Drivers - - drv_gpio.c - 1 - ..\libraries\HAL_Drivers\drivers\drv_gpio.c - - - drv_usart.c - 1 - ..\libraries\HAL_Drivers\drivers\drv_usart.c - - - drv_common.c - 1 - ..\libraries\HAL_Drivers\drv_common.c - - - startup_stm32f103xb.s - 2 - ..\libraries\STM32F1xx_HAL\CMSIS\Device\ST\STM32F1xx\Source\Templates\arm\startup_stm32f103xb.s - stm32f1xx_hal_msp.c 1 @@ -1089,30 +1090,30 @@ 1 board\board.c - - - - Finsh - - shell.c + drv_gpio.c 1 - ..\..\..\components\finsh\shell.c + libraries\HAL_Drivers\drivers\drv_gpio.c - msh.c + drv_usart_v2.c 1 - ..\..\..\components\finsh\msh.c + libraries\HAL_Drivers\drivers\drv_usart_v2.c - msh_parse.c + drv_usbd.c 1 - ..\..\..\components\finsh\msh_parse.c + libraries\HAL_Drivers\drivers\drv_usbd.c - cmd.c + drv_common.c 1 - ..\..\..\components\finsh\cmd.c + libraries\HAL_Drivers\drv_common.c + + + startup_stm32f103xb.s + 2 + libraries\STM32F1xx_HAL\CMSIS\Device\ST\STM32F1xx\Source\Templates\arm\startup_stm32f103xb.s @@ -1122,7 +1123,7 @@ clock.c 1 - ..\..\..\src\clock.c + ..\rt-thread\rt-thread-v5.1.0\src\clock.c 2 @@ -1169,7 +1170,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1178,7 +1179,7 @@ components.c 1 - ..\..\..\src\components.c + ..\rt-thread\rt-thread-v5.1.0\src\components.c 2 @@ -1225,7 +1226,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1234,7 +1235,7 @@ idle.c 1 - ..\..\..\src\idle.c + ..\rt-thread\rt-thread-v5.1.0\src\idle.c 2 @@ -1281,7 +1282,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1290,7 +1291,7 @@ ipc.c 1 - ..\..\..\src\ipc.c + ..\rt-thread\rt-thread-v5.1.0\src\ipc.c 2 @@ -1337,7 +1338,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1346,7 +1347,7 @@ irq.c 1 - ..\..\..\src\irq.c + ..\rt-thread\rt-thread-v5.1.0\src\irq.c 2 @@ -1393,7 +1394,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1402,7 +1403,7 @@ kstdio.c 1 - ..\..\..\src\klibc\kstdio.c + ..\rt-thread\rt-thread-v5.1.0\src\klibc\kstdio.c 2 @@ -1449,7 +1450,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1458,7 +1459,7 @@ kstring.c 1 - ..\..\..\src\klibc\kstring.c + ..\rt-thread\rt-thread-v5.1.0\src\klibc\kstring.c 2 @@ -1505,7 +1506,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1514,7 +1515,7 @@ kservice.c 1 - ..\..\..\src\kservice.c + ..\rt-thread\rt-thread-v5.1.0\src\kservice.c 2 @@ -1561,7 +1562,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1570,7 +1571,7 @@ mem.c 1 - ..\..\..\src\mem.c + ..\rt-thread\rt-thread-v5.1.0\src\mem.c 2 @@ -1617,7 +1618,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1626,7 +1627,7 @@ memheap.c 1 - ..\..\..\src\memheap.c + ..\rt-thread\rt-thread-v5.1.0\src\memheap.c 2 @@ -1673,7 +1674,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1682,7 +1683,7 @@ mempool.c 1 - ..\..\..\src\mempool.c + ..\rt-thread\rt-thread-v5.1.0\src\mempool.c 2 @@ -1729,7 +1730,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1738,7 +1739,7 @@ object.c 1 - ..\..\..\src\object.c + ..\rt-thread\rt-thread-v5.1.0\src\object.c 2 @@ -1785,7 +1786,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1794,7 +1795,7 @@ scheduler_comm.c 1 - ..\..\..\src\scheduler_comm.c + ..\rt-thread\rt-thread-v5.1.0\src\scheduler_comm.c 2 @@ -1841,7 +1842,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1850,7 +1851,7 @@ scheduler_up.c 1 - ..\..\..\src\scheduler_up.c + ..\rt-thread\rt-thread-v5.1.0\src\scheduler_up.c 2 @@ -1897,7 +1898,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1906,7 +1907,7 @@ thread.c 1 - ..\..\..\src\thread.c + ..\rt-thread\rt-thread-v5.1.0\src\thread.c 2 @@ -1953,7 +1954,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1962,7 +1963,7 @@ timer.c 1 - ..\..\..\src\timer.c + ..\rt-thread\rt-thread-v5.1.0\src\timer.c 2 @@ -2009,7 +2010,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2023,27 +2024,27 @@ atomic_arm.c 1 - ..\..\..\libcpu\arm\common\atomic_arm.c + ..\rt-thread\rt-thread-v5.1.0\libcpu\arm\common\atomic_arm.c div0.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\rt-thread\rt-thread-v5.1.0\libcpu\arm\common\div0.c showmem.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\rt-thread\rt-thread-v5.1.0\libcpu\arm\common\showmem.c context_rvds.S 2 - ..\..\..\libcpu\arm\cortex-m3\context_rvds.S + ..\rt-thread\rt-thread-v5.1.0\libcpu\arm\cortex-m3\context_rvds.S cpuport.c 1 - ..\..\..\libcpu\arm\cortex-m3\cpuport.c + ..\rt-thread\rt-thread-v5.1.0\libcpu\arm\cortex-m3\cpuport.c @@ -2051,69 +2052,119 @@ Libraries - stm32f1xx_hal_rcc_ex.c + stm32f1xx_hal_cortex.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c - stm32f1xx_hal_cortex.c + stm32f1xx_hal_cec.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cec.c - stm32f1xx_hal_gpio_ex.c + stm32f1xx_hal_crc.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_crc.c - stm32f1xx_hal_rcc.c + system_stm32f1xx.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c + libraries\STM32F1xx_HAL\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c - stm32f1xx_hal_pwr.c + stm32f1xx_hal_uart.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c - stm32f1xx_hal_dma.c + stm32f1xx_hal_pcd_ex.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd_ex.c - stm32f1xx_hal_crc.c + stm32f1xx_hal_dma.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_crc.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c - system_stm32f1xx.c + stm32f1xx_hal_gpio_ex.c 1 - ..\libraries\STM32F1xx_HAL\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c - stm32f1xx_hal_uart.c + stm32f1xx_hal_rcc_ex.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c stm32f1xx_hal.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c - stm32f1xx_hal_cec.c + stm32f1xx_hal_hcd.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cec.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_hcd.c stm32f1xx_hal_usart.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_usart.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_usart.c + + + stm32f1xx_hal_rcc.c + 1 + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c + + + stm32f1xx_hal_pcd.c + 1 + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd.c + + + stm32f1xx_ll_usb.c + 1 + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usb.c stm32f1xx_hal_gpio.c 1 - ..\libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c + + + stm32f1xx_hal_pwr.c + 1 + libraries\STM32F1xx_HAL\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c + + + + + rt_usbd + + + usbdevice.c + 1 + ..\rt-thread\rt-thread-v5.1.0\components\drivers\usb\usbdevice\core\usbdevice.c + + + usbdevice_core.c + 1 + ..\rt-thread\rt-thread-v5.1.0\components\drivers\usb\usbdevice\core\usbdevice_core.c + + + cdc_vcom.c + 1 + ..\rt-thread\rt-thread-v5.1.0\components\drivers\usb\usbdevice\class\cdc_vcom.c + + + + + Utilities + + + ulog.c + 1 + ..\rt-thread\rt-thread-v5.1.0\components\utilities\ulog\ulog.c diff --git a/rtconfig.h b/rtconfig.h index 61dd2eb..ff176b5 100644 --- a/rtconfig.h +++ b/rtconfig.h @@ -57,7 +57,7 @@ #define RT_USING_COMPONENTS_INIT #define RT_USING_USER_MAIN -#define RT_MAIN_THREAD_STACK_SIZE 512 +#define RT_MAIN_THREAD_STACK_SIZE 1024 #define RT_MAIN_THREAD_PRIORITY 10 /* DFS: device virtual file system */ @@ -75,6 +75,18 @@ /* Using USB */ +#define RT_USING_USB +#define RT_USING_USB_DEVICE +#define RT_USBD_THREAD_STACK_SZ 1024 +#define USB_VENDOR_ID 0x0FFE +#define USB_PRODUCT_ID 0x0001 +#define _RT_USB_DEVICE_CDC +#define RT_USB_DEVICE_CDC +#define RT_VCOM_TASK_STK_SIZE 1024 +#define RT_CDC_RX_BUFSIZE 128 +#define RT_VCOM_SERNO "32021919830108" +#define RT_VCOM_SER_LEN 14 +#define RT_VCOM_TX_TIMEOUT 1000 /* end of Using USB */ /* end of Device Drivers */ @@ -119,11 +131,6 @@ #define ULOG_USING_ISR_LOG #define ULOG_ASSERT_ENABLE #define ULOG_LINE_BUF_SIZE 128 -#define ULOG_USING_ASYNC_OUTPUT -#define ULOG_ASYNC_OUTPUT_BUF_SIZE 512 -#define ULOG_ASYNC_OUTPUT_BY_THREAD -#define ULOG_ASYNC_OUTPUT_THREAD_STACK 1024 -#define ULOG_ASYNC_OUTPUT_THREAD_PRIORITY 20 /* log format */ @@ -339,6 +346,7 @@ /* On-chip Peripheral Drivers */ #define BSP_USING_GPIO +#define BSP_USING_USBD #define BSP_USING_UART #define BSP_USING_UART1 #define BSP_USING_UART2