A SPI master for the PHP that runs on your board. Baremetal\Spi\Bus opens a SPI host on your pins (four data
lines for QSPI), Baremetal\Spi\Device exchanges raw bytes with one chip on it, and device-driver packages add
typed classes under Baremetal\Spi\Driver\ (for example St77916, a QSPI round display).
ext-spi is platform-neutral: it requires the virtual php-baremetal/spi-hal, and conductor adds the HAL for your
SDK platform (php-baremetal/esp32-spi-hal on ESP32).
In a project created with phpbm init:
composer require php-baremetal/ext-spiAdd a device driver the same way; a driver requires ext-spi, so it is enough on its own:
composer require php-baremetal/esp32-display-st77916<?php
use Baremetal\Spi\Bus;
$bus = new Bus(sclk: 12, mosi: 11, miso: 13);
$flash = $bus->device(cs: 10, hz: 10_000_000);
$rx = $flash->transfer("\x9F\x00\x00\x00"); // JEDEC ID command + 3 dummy bytes
printf("JEDEC id: %s\n", bin2hex(substr($rx, 1)));- Overview: requirements, install, a first project, limits.
- Bus and Device: the PHP API.
- Errors and limits
- The spi_drivers registry and Writing a driver
- Read a SPI flash ID
MIT.