Before we jump into coding a peripheral driver that utilizes interrupts, let's take a quick look at how interrupts compare to FreeRTOS tasks.
There are many similarities between tasks and ISRs:
- Both provide a way of achieving parallel code execution.
- Both only run when required.
- Both can be written with C/C++ (ISRs generally no longer need to be written in assembly code).
But there are also many differences between tasks and ISRs:
- ISRs are brought into context by hardware; tasks gain context by the RTOS kernel: Tasks are always brought into context by the FreeRTOS kernel. Interrupts, on the other hand, are generated by hardware in the MCU. There are usually a few different ways of configuring the generation (and masking) of interrupts.
- ISRs must exit as quickly as possible; tasks are more forgiving: FreeRTOS tasks are often set up...