读取SPI接收数据
int spi_read(int $spi_id, string &$rbuf, int $rlen)
成功时读取数据长度(byte),失败时0
<?php
include "/lib/sd_340.php";
$rbuf = "";
$rlen = 0;
spi_setup(0); // configuring SPI
while(1)
{
$rlen = spi_read(0, $rbuf, 2); // Reading 2 bytes data from the SPI
if($rlen == 2)
echo "$rbuf\r\n";
sleep(1);
}
?>