向SPI传送数据读取接收数据
int spi_write_read(int $spi_id, string $wbuf, string &$rbuf, int $rlen)
读取或写的数据长度(byte)
<?php
include "/lib/sd_340.php";
$rbuf = "";
$wbuf = "\x1E\x07";
$rlen = 0;
spi_setup(0); // configuring SPI
$rlen = spi_write_read(0, $wbuf, $rbuf, 2); // writing and reading to/from the SPI
if($rlen == 2)
echo "$rbuf\r\n"; // outputting the received data
?>