cancel
Showing results for 
Search instead for 
Did you mean: 

RTOS use Taskhandle in other .c file

DeBa92
Associate II

Hello guys,
i try to use RTOS with my STM32H723, but i have some trouble with the RTOS Tasks and the proper definition of the task.

As an example i want to push the blue button on my Nucleo board, which triggers an Interrupt, which executes a RTOS Task (https://www.freertos.org/taskresumefromisr.html)
When you create a RTOS Task in CubeMX the IDE generates the following code in the main.c file:

/* Definitions for BlueButton */
osThreadId_t BlueButtonHandle;
const osThreadAttr_t BlueButton_attributes = {
  .name = "BlueButton",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityHigh,
};

The interrupt handler functions, that I want to use, are in the stm32H/xx_it.c file.
In this file I have the following IRQ handler:

void EXTI15_10_IRQHandler(void)
{
  /* USER CODE BEGIN EXTI15_10_IRQn 0 */
	if(__HAL_GPIO_EXTI_GET_FLAG(BLUE_BUTTON_Pin))
	{
		BaseType_t checkIfYieldRequired;
		checkIfYieldRequired = xTaskResumeFromISR(BlueButtonHandle);
		portYIELD_FROM_ISR(checkIfYieldRequired);

		//Blink_LEDs();
	}
  /* USER CODE END EXTI15_10_IRQn 0 */
  HAL_GPIO_EXTI_IRQHandler(BLUE_BUTTON_Pin);
  /* USER CODE BEGIN EXTI15_10_IRQn 1 */

  /* USER CODE END EXTI15_10_IRQn 1 */
}

But obviously the "BlueButtonHandle" is not declared in the _it.c file.

Since I am a beginner to c++ programming I cant figure out how to properly define the TaskHandler in my header file.
When I copy the IRQ Handler in my main.c file, everything works fine, but this is not a good solution.
Can someone help me with this problem?

Best regards,
Dennis

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Within your *_it.h file, or at the top of your *_it.c file, declare (not define) the variables you want to use.

extern osThreadId_t BlueButtonHandle;

It will also need to know what osThreadId_t is, you'll need to include the appropriate header there.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

1 REPLY 1
TDK
Guru

Within your *_it.h file, or at the top of your *_it.c file, declare (not define) the variables you want to use.

extern osThreadId_t BlueButtonHandle;

It will also need to know what osThreadId_t is, you'll need to include the appropriate header there.

If you feel a post has answered your question, please click "Accept as Solution".