SPI
API Documents
Constructors
unit_id: The unit ID of the hardware SPI, assume default value if left blankbaudrate: The speed of SPIpolarity: one of factor determining SPI mode. (deprecated)phase: one of factor determining SPI mode. (deprecated)databits: number of data bitsFirstbit: this determine whether first bit is MSB or LSBmiso`: miso pin. (deprecated)mosi: mosi pin. (deprecated)sck: clock pin. (deprecated)mode: either MASTER mode or SLAVE mode
Note
All optional parameters have default values as follows:
Parameter |
Default |
|---|---|
Baudrate |
2000000 Hz |
Polarity |
Inactive_low |
Phase |
Toggle_middle |
Databits |
8 |
Firstbit |
MSB |
Miso |
N.A. |
Mosi |
N.A. |
Sck |
N.A. |
Mode |
MASTER |
There is currently 2 set of SPI, they are:
unit |
MOSI |
MISO |
SCK |
CS |
|---|---|---|---|---|
0 |
PB_18 |
PB_19 |
PB_20 |
PB_21 |
1 |
PB_4 |
PB_5 |
PB_6 |
PB_7 |
Note
both unit support master mode, but only unit 0 supports slave mode.
Methods
value: an integer value to be sent on SPI bus