WIP refactoring for SPI lock