Hi Felix
Hi Tom
I have made a small improvement to the RFM69 library, as discussed in the above thread.
In summary
The purpose of this change is to support improvements to the core Arduino SPI libraries that have been first released in Arduino 1.5.8
In summary the SPI changes improve reliability when there are multiple slave devices on the same SPI bus. This is by creating exclusion zones (transactions) around SPI interaction, managing different SPI configuration, and preventing interrupts where the interrupt handler uses SPI.
The full description of the changed SPI libraries is here
http://dorkbotpdx.org/blog/paul/spi_transactions_in_arduinoI can confirm the Ethernet libraries in 1.5.8 have been enhanced with these changes, so by upgrading the RFM libraries, then these two should work more reliably together, this is the main use case I want to support.
My changed RFM69 library is on GitHub. It is backwards compatible with traditional (legacy) SPI libraries, by #ifdef compiler directive.
https://github.com/kiwisincebirth/RFM69.
The main change in the RFM library is in the select() and unselect() methods, with a further small change in the init() method, where there interrupt handler is attached.
There is a small fix in readAllRegs() method to remove an unnecessary (duplicated) unselect() method call.
Lastly in the receiveDone() method, a call the interrupts() method has been added before every return statement. This is to ensure interrupts are fully enabled before the function ends. Previously this was implicit via a sub-functon calling unselect(), but this cannot be relied upon in the amended unselect(). The new SPI libraries disable (mask) only the interrupts that it knows need to be masked, rather then globally disable all interrupts.
It is lastly this last change that needs the most review, as I am not across the reason for disabling interrupts globally in this way, with the new SPI libraries this may not even be needed.
I am still testing it, and invite others to do the same. I will confirm once I have a amount of “multiple device” testing done. But the library ran successfully for 20 hours, running a gateway sketch, handling 360 messages an hour.
I have resisted the urge to tidy up other areas of the code (removing static declarations), concentrating on Just what IS needed. I know Tom has other cleanups and improvements he wishes to do.
I would like to consider this to be included for inclusion in the main library.
Regards
Kiwi