Configuring SPI
void spi_setup(int $spi_id[, int $div = 256[, int $mode = 3]])
$div: clock divider for SPI (2, 4, 8, 16, 32, 64, 128 or 256)
divider | communication rate(bps) |
---|---|
2 | 21M |
4 | 10.5M |
8 | 5.25M |
16 | about 2.6M |
32 | about 1.3M |
64 | about 656K |
128 | about 328K |
256 | about 164K |
<?php
include "/lib/sd_340.php";
spi_setup(0); // Configuring SPI0 with divider 256 and mode 3
spi_setup(0, 128); // Configuring SPI0 with divider 128 and mode 3
spi_setup(0, 128, 0); // Configuring SPI0 with divider 128 and mode 0
?>