From b808fe17ad3889ac78620693f874e0d64797e56d Mon Sep 17 00:00:00 2001 From: iorebuild Date: Tue, 1 Jul 2025 21:32:04 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0OS=E5=AE=8F=202?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=AD=A3Board.h=E7=9A=84=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=203=E3=80=81Main=E5=87=BD=E6=95=B0=E4=B8=ADThreadX=E7=9A=84?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E5=87=BD=E6=95=B0=E5=90=8D=E5=AD=97=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Inc/Board.h | 75 ++++++++++++++++++++++++----------------------- App/Src/LedTest.c | 2 ++ App/Src/Main.c | 2 +- 3 files changed, 42 insertions(+), 37 deletions(-) diff --git a/App/Inc/Board.h b/App/Inc/Board.h index a5373fb..c515791 100644 --- a/App/Inc/Board.h +++ b/App/Inc/Board.h @@ -9,6 +9,9 @@ #define NVIC_GROUP_LEVEL NVIC_PriorityGroup_2 /* **********END********** */ +/* 使用OS,ThreadX */ +#define USE_THREADX + /* **********SystemClock相关********** */ // GPIO #define GPIO_ENABLE @@ -33,17 +36,17 @@ // 数字输出 #undef USE_DIGITAL_OUTPUT #ifdef USE_DIGITAL_OUTPUT -#define DO_NUM 2 -#define DO1 0 -#define DO2 1 + #define DO_NUM 2 + #define DO1 0 + #define DO2 1 #endif // 数字输入 #undef USE_DIGITAL_INPUT #ifdef USE_DIGITAL_INPUT -#define DI_NUM 2 -#define DI1 0 -#define DI2 1 + #define DI_NUM 2 + #define DI1 0 + #define DI2 1 #endif // LED灯 @@ -58,44 +61,44 @@ /* **********串口相关********** */ #ifdef USE_USART1 -#define COM0 USART1_BASE -#define COM0_IRQN USART1_IRQn -#define COM0_TX_PORT GPIOA -#define COM0_RX_PORT GPIOA -#define COM0_TX_PIN GPIO_Pin_9 -#define COM0_RX_PIN GPIO_Pin_10 + #define COM0 USART1_BASE + #define COM0_IRQN USART1_IRQn + #define COM0_TX_PORT GPIOA + #define COM0_RX_PORT GPIOA + #define COM0_TX_PIN GPIO_Pin_9 + #define COM0_RX_PIN GPIO_Pin_10 #endif #ifdef USE_USART2 -#define COM1 USART2_BASE -#define COM1_IRQN USART2_IRQn -#define COM1_TX_PORT GPIOA -#define COM1_RX_PORT GPIOA -#define COM1_TX_PIN GPIO_Pin_2 -#define COM1_RX_PIN GPIO_Pin_3 + #define COM1 USART2_BASE + #define COM1_IRQN USART2_IRQn + #define COM1_TX_PORT GPIOA + #define COM1_RX_PORT GPIOA + #define COM1_TX_PIN GPIO_Pin_2 + #define COM1_RX_PIN GPIO_Pin_3 #endif #ifdef USE_USART3 -#define COM2 USART3_BASE -#define COM2_IRQN USART3_IRQn -#define COM2_TX_PORT GPIOB -#define COM2_RX_PORT GPIOB -#define COM2_TX_PIN GPIO_Pin_10 -#define COM2_RX_PIN GPIO_Pin_11 + #define COM2 USART3_BASE + #define COM2_IRQN USART3_IRQn + #define COM2_TX_PORT GPIOB + #define COM2_RX_PORT GPIOB + #define COM2_TX_PIN GPIO_Pin_10 + #define COM2_RX_PIN GPIO_Pin_11 #endif #ifdef USE_USART4 -#define COM3 UART4_BASE -#define COM3_IRQN UART4_IRQn -#define COM3_TX_PORT GPIOC -#define COM3_RX_PORT GPIOC -#define COM3_TX_PIN GPIO_Pin_10 -#define COM3_RX_PIN GPIO_Pin_11 + #define COM3 UART4_BASE + #define COM3_IRQN UART4_IRQn + #define COM3_TX_PORT GPIOC + #define COM3_RX_PORT GPIOC + #define COM3_TX_PIN GPIO_Pin_10 + #define COM3_RX_PIN GPIO_Pin_11 #endif #ifdef USE_USART5 -#define COM4 UART5_BASE -#define COM4_IRQN UART5_IRQn -#define COM4_TX_PORT GPIOB -#define COM4_RX_PORT GPIOD -#define COM4_TX_PIN GPIO_Pin_12 -#define COM4_RX_PIN GPIO_Pin_2 + #define COM4 UART5_BASE + #define COM4_IRQN UART5_IRQn + #define COM4_TX_PORT GPIOB + #define COM4_RX_PORT GPIOD + #define COM4_TX_PIN GPIO_Pin_12 + #define COM4_RX_PIN GPIO_Pin_2 #endif /* LetterShell */ #define USE_SHELL diff --git a/App/Src/LedTest.c b/App/Src/LedTest.c index 6ea080d..63096d3 100644 --- a/App/Src/LedTest.c +++ b/App/Src/LedTest.c @@ -42,6 +42,8 @@ void LedCtlTask(ULONG ThreadXInput) while (true) { + IoCtlLedToggle(LED0); + IoCtlLedToggle(LED1); IoCtlLedToggle(LED2); tx_thread_sleep(100); } diff --git a/App/Src/Main.c b/App/Src/Main.c index d16fd4f..90baed4 100644 --- a/App/Src/Main.c +++ b/App/Src/Main.c @@ -14,7 +14,7 @@ * @note 此函数应该将所有OS相关的初始化放到这里 * @example void */ -void tx_application_define(void* FirstUnusedMemory) +void ThreadXTaskInit(void* FirstUnusedMemory) { /* 优先级31,抢占10 */ LedCtlTaskInit(31,10);