Add new content to spi-frequency.md

This commit is contained in:
ganicke 2017-11-27 14:21:21 -08:00
parent bb962ecd45
commit 419dbdb398

View File

@ -1,18 +1,31 @@
# SPI Write
# SPI Frequency
Write to the SPI Slave and return the response.
Set the SPI clock frequency.
```sig
pins.spiWrite(0);
pins.spiFrequency(1000000);
```
## Parameters
* ``value``: value Data to be sent to the SPI slave
* **frequency**: a [number](/types/number) to set as the frequency for SPI bus clock. This value is the number of clock changes per second (Hz).
## Returns
## Example
* a [number](/types/number) Response from the SPI slave
Read the value of the _WHOAMI_ register from the device connected to the SPI bus. The chip select line is connected to pin **0** and the SPI signals use pins **13**, **14**, and **15**.
```blocks
pins.digitalWritePin(DigitalPin.P0, 1);
pins.spiPins(DigitalPin.P15, DigitalPin.P14, DigitalPin.P13);
pins.spiFormat(8, 3);
pins.spiFrequency(1000000);
pins.digitalWritePin(DigitalPin.P0, 0);
let command = pins.spiWrite(143);
let whoami = pins.spiWrite(0);
pins.digitalWritePin(DigitalPin.P0, 1);
basic.showNumber(whoami);
serial.writeLine("WHOAMI register value: " + whoami)
```
## See also