/STM32_FreeRTOS_CountingSemaphores

STM32_FreeRTOS Counting Semaphores Example with STM32F3Discovery Kit

Primary LanguageCMIT LicenseMIT

STM32_FreeRTOS : Counting Semaphores

  • STM32_FreeRTOS Example with STM32F3Discovery Kit in STM32CUBEIDE
  • FreeRTOS is used in this project as RTOS Library.
  • If it's not necessary don't regenerate the code from CUBE! If you need to regenerate then you should remove default generated parts of code (handles, functions and etc.) for CMSIS OS!
  • Important points

    1. xSemaphoreGive(semaphore) => This function releases the semaphore
    2. xSemaphoreTake(semaphore, delay) => This function acquires the semaphore
    3. uxSemaphoreGetCount(semaphore) => This function returns count of a semaphore (binary semaphore or counting semaphore)
    4. taskYIELD() or portYIELD() => This function is used to request a context switch to another task. However, if there are no other tasks at a higher or equal priority to the task that calls this function, then the RTOS scheduler will simply select the task that called it to run again.
    5. uxQueueMessagesWaitingFromISR(semaphore) => This function returns count of a semaphore in an ISR(binary semaphore or counting semaphore)
    6. In Binray Semaphores you can just release semaphore in the task which have acquired it!
    7. In Counting Semaphores you can release semaphore at any point of code!
    8. Releasing Semaphore from ISR is not straightforward by using a single function(Commit: "Counting Semaphores release with ISR:Part2")!

    image