diff --git a/docs/reference/pins/spi-frequency.md b/docs/reference/pins/spi-frequency.md index af5e6d42..3752017a 100644 --- a/docs/reference/pins/spi-frequency.md +++ b/docs/reference/pins/spi-frequency.md @@ -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