From 714ca43d45dca08d9ef855f257e0dd4bfc76f25b Mon Sep 17 00:00:00 2001 From: Erick Ahmed Date: Mon, 8 Jun 2026 23:50:14 +0200 Subject: [PATCH] Pass LED pin to thread arguments - Create typedef for LED (port:pin) - Define two LED as private variables - Pass them to threads --- Core/Src/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index 03591f9..2ce6640 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -29,6 +29,11 @@ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ +typedef struct { + GPIO_TypeDef* port; + uint16_t pin; +} LED_Config; + /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ @@ -51,6 +56,9 @@ DMA_HandleTypeDef hdma_sdio_tx; /* USER CODE BEGIN PV */ +LED_Config led_can1 = {GPIOB, GPIO_PIN_2}; +LED_Config led_can2 = {GPIOB, GPIO_PIN_5}; + /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ @@ -135,9 +143,8 @@ int main(void) /* Create the thread(s) */ vCAN1_rx = osThreadNew(vCAN_log, (void*)&hcan1, &vCAN1_rx_attributes); vCAN2_rx = osThreadNew(vCAN_log, (void*)&hcan2, &vCAN2_rx_attributes); - vLED_CAN1_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, NULL, &vLED_CAN1_Heartbeat_attributes); - vLED_CAN2_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, NULL, &vLED_CAN2_Heartbeat_attributes); - + vLED_CAN1_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, &led_can1, &vLED_CAN1_Heartbeat_attributes); + vLED_CAN2_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, &led_can2, &vLED_CAN2_Heartbeat_attributes); /* USER CODE BEGIN RTOS_THREADS */ /* add threads, ... */ /* USER CODE END RTOS_THREADS */