Refactor writing part of FIFP
Move SPI logic to a separate module.