-
-
Notifications
You must be signed in to change notification settings - Fork 24
spi
This class includes full support for using K210 SPI peripheral in master and slave mode
WS2812 (neopixel) support is also include in this module as it uses the SPI peripheral.
Argument | Description |
---|---|
id |
SPI ID; Default: machine.SPI.SPI1 ; following id's can be used:machine.SPI.SPI0 hardware SPI #0machine.SPI.SPI1 hardware SPI #1machine.SPI.SPI_SLAVE hardware SPI slavemachine.SPI.WS2812_0 hardware SPI #0 in WS2812 modemachine.SPI.WS2812_1 hardware SPI #1 in WS2812 mode |
baudrate |
SPI clock speed in Hz; Default: 1000000 |
mode |
defines the SPI operating mode (0-3); Default: 0 |
polarity |
SPI polarity; 0 or 1 ; Default: 0only used if mode is not set |
phase |
SPI phase; 0 or 1 ; Default: 0polarity & phase defines the SPI operating mode (0-3): mode = (polarity<<1) + phase only used if mode is not set |
firstbit |
Send MSB or LSB bit first; default: MSB use constants machine.spi.MSB or machine.spi.LSB
|
sck |
SPI SCK pin; Any valid and used K210 pin |
moosi |
SPI MISI pin; Any valid and used K210 pin |
miso |
SPI MISO pin; Any valid and used K210 pin |
cs |
Optional; SPI CS pin; Any valid and used K210 pin If set, CS activation and deactivation is handled by the driver, if not set, SPI select and deselect must be handled by user |
duplex |
Select wether SPI operates in fullduplex or halfduplex mode In fullduplex mode SPI writes and reads data at the same time In halfduplex mode SPI writes data first, then reads data Default: True
|
bits |
Number of bits; Default: 8; range: 4 - 32 |
Only sck
, mosi
and miso
are required, all the other arguments are optional and will be set to the default values if not given.
All arguments, except for id
are KW arguments and must be entered as arg=value
.
Deinitialize the SPI object, free all used resources.
Read len
bytes from SPI device.
Returns the string of read bytes.
If the optional val
argument is given, outputs val
byte on mosi during read (if duplex mode is used).
Read bytes from SPI device into buffer object buf
. Length of buf
bytes are read.
If the optional val
argument is given, outputs val
byte on mosi during read (if duplex mode is used).
Writes address
to the spi device and reads length
bytes.
The number of the address
bytes to write is determined from the address
value (1 byte for 0-255, 2 bytes for 256-65535, ...).
The number of address
bytes to be written can also be set by the optional argument addrlen
(1-4).
Returns the string of read bytes.
Write bytes from buffer object buf
to the SPI device.
Returns True
on success, False
ion error
Write bytes from buffer object wr_buf
to the SPI device and reads from SPI device into buffer object rd_buf
.
The lenghts of wr_buf
and rd_buf
can be different.
In fullduplex mode write and read are simultaneous. In halfduplex mode the data are first written to the device, then read from it.
Returns True
on success, False
ion error
soon...
soon...
- Maix-M1 schematic
- Maix-Bit schematic
- Maix-Go schematic
- Kendryte K210 datasheet
- RISC-V ISA Design
- RISC-V ISA Manual
- Forum
- MicroPython documentation
If you find this project useful, you can contribute by making a donation