modified how buffer was written to spi.