spi_read()


读取SPI接收数据

Description

int spi_read(int $spi_id, string &$rbuf, int $rlen)

Parameters

Return Value

成功时读取数据长度(byte),失败时0

Example

<?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);
}
?>

See also