2015-07-24 04:10 PM
I'm developing a custom CAN bridge with the stm3210c-eval board, such that I can hook up the board's CAN port to a car's CAN bus and the USART port to a computer and read in received frames over a serial terminal. In the CAN interrupt handler I populate a CANRx struct that is shared with my main.c. I want to put in a flag so that the main program knows when to do a printf (which is redirected over USART), which requires that I disable the CAN interrupt (to do a flag check and printf). However, I can't find any exposed interface to block an irq. Does it exist, and if so, what do I need to import?
#irq-handling-stm322015-07-24 06:26 PM
You have the NVIC and the peripheral level.
Consider however if you can just buffer things more effectively so you're not writing to a singular common buffer. If you have a single writer, you can have multiple readers without requiring an atomic write. ie you can increment a sequence count in the interrupt, and then observe that change in the main loop.