918af4f3ac
* change simulator svg * change radio image * Remove google fonts cdn * change color of 'advanced' button * font fix * font fix 2 * display fix * change fullsceen simulator bg * Continuous servo * handle continuous state * adding shims * update rendering for continuous servos * fixing sim * fix sig * typo * fix sim * bump pxt * bump pxt * rerun travis * Input blocks revision - add Button and Pin event types - merge onPinPressed & onPinReleased in new onPinEvent function - create new onButtonEvent function * update input blocks in docs and tests * remove device_pin_release block * Hide DAL.x behind Enum * bring back deprecated blocks, but hide them * shims and locales files * fix input.input. typing * remove buildpr * bump V3 * update simulator aspect ratio * add Loudness Block * revoke loudness block * Adds soundLevel To be replaced by pxt-common-packages when DAL is updated. * Remove P0 & P3 from AnalogPin Co-authored-by: Juri <gitkraken@juriwolf.de>
44 lines
1.7 KiB
Markdown
44 lines
1.7 KiB
Markdown
# spi Format
|
|
|
|
Set the Serial Peripheral Interface (SPI) format.
|
|
|
|
```sig
|
|
pins.spiFormat(8, 3);
|
|
```
|
|
|
|
The data sent over a SPI connection has a number of _bits_ to represent each value. Also, position of the clock signal (SCK), ``high`` or ``low``, and the exact time when a data value is read is determined by the SPI _mode_. Both the bits and mode values together are called the _SPI format_.
|
|
|
|
### ~ hint
|
|
|
|
**Simulator**: This function needs real hardware to work with. It's not supported in the simulator.
|
|
|
|
### ~
|
|
|
|
The default number of bits is `8` and the default mode value is `3`.
|
|
|
|
## Parameters
|
|
|
|
* **bits**: the [number](types/number) of bits for each data value sent and received on the SPI connection. This value must be ``8`` since only 8 bits is currently supported for SPI data values.
|
|
* **mode**: a [number](/types/number) that is the mode value for the SPI clock (**SCK**) signalling. The different modes are:
|
|
>* `0`: the data line is active when **SCK** goes to ``high`` and the data values are read when **SCK** goes to ``high``
|
|
>* `1`: the data line is active when **SCK** goes to ``high`` and the data values are read when **SCK** goes to ``low``
|
|
>* `2`: the data line is active when **SCK** goes to ``low`` and the data values are read when **SCK** goes to ``high``
|
|
>* `3`: the data line is active when **SCK** goes to ``low`` and the data values are read when **SCK** goes to ``low``
|
|
|
|
## Example
|
|
|
|
Set the pins and format for the SPI connection.
|
|
|
|
```blocks
|
|
pins.spiPins(DigitalPin.C15, DigitalPin.C14, DigitalPin.C13);
|
|
pins.spiFormat(8, 3);
|
|
```
|
|
|
|
## See also
|
|
|
|
[spi write](/reference/pins/spi-write),
|
|
[spi pins](/reference/pins/spi-pins),
|
|
[spi frequency](/reference/pins/spi-frequency)
|
|
|
|
[SPI Programming](https://developer.mbed.org/handbook/SPI)
|