设定SPI通信设定
void spi_setup(int $spi_id[, int $div = 256[, int $mode = 3]])
$div:SPI时钟分频 (2, 4, 8, 16, 32, 64, 128或256)
分频比 | 通信速度(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
?>