ECE471/571 (RTOS) STM32 FreeRTOS Example - Signal a task from an interrupt using a semaphore

In STM32CubeMX

  1. Initialize all peripherals with in default mode? - yes
  2. System Core
  3. Middleware - enable FreeRTOS
  4. System Core Again

Adapt and compile a project

  1. Open source/main.c
  2. Update the following code fragment:
    void StartDefaultTask(void const * argument)
    {
      /* USER CODE BEGIN 5 */
      /* Infinite loop */
      for(;;)
      {
        if( xSemaphoreTake( detected_buttonHandle, 1000 / portTICK_PERIOD_MS ) == pdTRUE ) {
          HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
        }
      }
      /* USER CODE END 5 */ 
    }
    
  1. Open inc/main.h
  2. Update the following code fragment:
    /* USER CODE BEGIN Includes */
    #include "cmsis_os.h"
    /* USER CODE END Includes */
    
  3. Update the following code fragment:
    /* USER CODE BEGIN EM */
    extern osSemaphoreId detected_buttonHandle;
    /* USER CODE END EM */
    
  1. Open source/stm32f7xx_it.c
  2. Update the following code fragment:
    void EXTI15_10_IRQHandler(void)
    {
      /* USER CODE BEGIN EXTI15_10_IRQn 0 */
      BaseType_t xSchedulerChanged = pdFALSE;
      xSemaphoreGiveFromISR( detected_buttonHandle, &xSchedulerChanged );
      portYIELD_FROM_ISR( xSchedulerChanged );
      /* USER CODE END EXTI15_10_IRQn 0 */
      HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);
      /* USER CODE BEGIN EXTI15_10_IRQn 1 */
    
      /* USER CODE END EXTI15_10_IRQn 1 */
    }
    

web site front local main page local list page general bookmarks software bookmarks go back copyright info