Marvee Amasi
DIIDevHeads IoT Integration Server
•Created by Marvee Amasi on 5/23/2024 in #middleware-and-os
Using atomic operations to update the SPI busy flag in FreeRTOS
Hi everyone @Middleware & OS , I'm working on an embedded project using FreeRTOS . I encountered a scenario where I need to atomically clear an SPI busy flag (spiTxRxByteCount) to ensure thread safety. Disabling interrupts is a common approach, but I was wondering if we could achieve the same outcome using atomic operations provided by FreeRTOS.
My current approach utilizes a function like
ClearSpiBusyFlag
that leverages AtomicCompareSet
to update the flag atomically. Is this a valid approach, or are there potential drawbacks compared to interrupt disabling? In your experience, what are the best practices for handling such scenarios in FreeRTOS development?4 replies