Fixed error in spi_write_XX functions. Little bit optimisations.