Example of SPI+DMA / gatekeeper?

I was wondering if there is an example implementation of a “properly” designed gatekeeper task for an SPI peripheral? It would be super helpful to have as a starting reference point. This is for a dsPIC33F ; we’re currently using SPI w/ DMA and installable callbacks to manage access to an SPI bus with a few devices on it. A bunch of time has already been sunk into getting everything to play along well. A proper FreeRTOS port would be a great boon here, but I don’t quite have the savvy to translate this into FreeRTOS API/primitives. Any sort of a reference would be great, even if there’s a solid block diagram to point me towards, laying out how the interactions for a gatekeeper for an SPI+DMA bus should be arranged. Surely such a module would be general enough that someone has already written it, and it’s out there? And I’d just need to implement the chip-support and board-support? Thanks!

Example of SPI+DMA / gatekeeper?

With SPI it might be better to use mutexes. You can use a mutex to access the SPI and a binary semaphore to signal the end of a transfer. I don’t know of any examples specifically for the PIC24, but you can get the idea by looking at the Atmel drivers that use FreeRTOS http://www.atmel.com/images/doc42049.pdf