Added spi_write function