If MCP2515::intHandler() is called from an actual interrupt handler while another SPI transfer is in progress, it will try to initiate another SPI transfer, causing one or both transfers to fail.
There are two ways to work around this in client code:
- Surround every call to sendFrame(), Mode(), SetRXFilter(), etc. with noInterrupts()/interrupts()
- Do nothing except set a flag in the actual interrupt handler, then call MCP2515::intHandler later.
The first method works for me because I am not using any other SPI devices on the bus. If I were, then I would have to also disable interrupts for those operations. The second method works best if the flag can be polled frequently, otherwise received frames might get lost.
I'm not sure what the best solution would be for fixing the library, though.
If MCP2515::intHandler() is called from an actual interrupt handler while another SPI transfer is in progress, it will try to initiate another SPI transfer, causing one or both transfers to fail.
There are two ways to work around this in client code:
The first method works for me because I am not using any other SPI devices on the bus. If I were, then I would have to also disable interrupts for those operations. The second method works best if the flag can be polled frequently, otherwise received frames might get lost.
I'm not sure what the best solution would be for fixing the library, though.