How to force a memory save on power interrupt?
Sonnengruesser opened this issue · comments
Hi,
I'm using an NCN5120 based TPUART with the "save" pin wired to the SAMD21. Now I've defined an interrupt that triggers in case the KNX power is lost and I would like to force the SAMD to call the "save" callback (save_restore.h).
Saving/loading user data works using the callbacks, but I didn't find a function to manually trigger the save callback. Is this implemented somewhere in the framework?
Thanks!
Edit: would it make sense to add this save function when calling knx.enabled(0); as defined in tpuart_data_link_layer.h?
You just need to add a method like save() to the knx-facade to call _bau.writeMemory(). Then you can just use knx.save() in the interrupt handler.
I don't think that the interupt registration should be added to the stack, as it depends on how the board is wired. But it could be added to an example like knx-demo.
Thank you for the hint, works perfectly as you suggested.