spi_read()


Reading data from the SPI

Description

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

Parameters

Return Value

data length (byte) on success, 0 on fail

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