problem with mutex of peripheral and interrupt

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

I'm writing device driver for a SPI peripheral on UC3B and I want to have lock for driver functions which access the SPI interface, and I don't want to disable global interrupt when the SPI is been accessed by driver functions, because some other interrupt could be triggered which have nothing to do with SPI, and they should be executed first.

But my problem is what if an interrupt happened and it also want to access the SPI which is been locked to another driver function in main(), then this interrupt can't just have a while loop and wait for the lock to be released because this will never happen if interrupt routine is not returned back to main.

I want to have first come first serve for all the SPI access code, so how to handel this kind of interrupt then?

Cheng