26 lines
		
	
	
		
			522 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			522 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?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();
 | 
						|
 | 
						|
// 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);
 |