Added software spi stuff
This commit is contained in:
25
examples/softwarespi.php
Normal file
25
examples/softwarespi.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__."/../vendor/autoload.php";
|
||||
require_once __DIR__."/GLOBALS.php";
|
||||
|
||||
use NoccyLabs\Gpio\Gpio;
|
||||
use NoccyLabs\Gpio\GpioTickHandler;
|
||||
use NoccyLabs\Gpio\Bus\SoftwareSpiBus as SPI;
|
||||
use NoccyLabs\Crap\Dumper;
|
||||
|
||||
$gpio = new Gpio(true);
|
||||
|
||||
// create spi bus
|
||||
$spi = new SPI();
|
||||
// bind the spi pins
|
||||
$spi->sclk = $gpio[1];
|
||||
$spi->mosi = $gpio[2];
|
||||
$spi->miso = $gpio[3];
|
||||
// write to the spi bus
|
||||
$spi->write("\xBE\xEF");
|
||||
// read the two bytes exchanged with the write()
|
||||
$read = $spi->read(2);
|
||||
|
||||
//
|
||||
Dumper::dump($read);
|
Reference in New Issue
Block a user