fixed spi_r bug