Hi, I have to following design question.
In my application I have to quickly respond to an SPI request. The first byte of the SPI frame is the command. Based on that, different data should be sent to the SPI master. To allow the device to prepare the tx frame several dummy bytes can be sent by the device until data is ready.
My architecture is like follows: An SPI irq handler receives the SPI frame and sends an event to a task. The task wakes up, prepares the result frame and puts it in the SPI transmit queue. The task is mainly there to prepare the frame, which involves access to a semaphore that protects global data. Global data was written from tasks, which reads out ADC ....
I like to get rid of the task and do assembling of the frame directly in the irq handler to speed up device response time. But then I can't use the semaphore anymore to do not block the IRQ. What is a good way to ensure consistency of the global data? What is a typical design pattern to realize the problem described above? I could think of some kind of double buffer (reading/writing global data without a semaphore). How can this be realized?
Thanks, Peter