maix.peripheral.spi

maix.peripheral.spi module

You can use maix.peripheral.spi to access this module with MaixPy
This module is generated from MaixCDK

Module

No module

Enum

Mode

item doc
brief SPI mode enum
values MASTER: spi master mode
SLAVE: spi slave mode

C++ defination code:

enum Mode
    {
        MASTER = 0x0, // spi master mode
        SLAVE = 0x1,  // spi slave mode
    }

Variable

Function

Class

SPI

item doc
brief Peripheral spi class

C++ defination code:

class SPI

__init__

item doc
type func
brief SPI constructor
param id: direction [in], spi bus id, int type
freq: direction [in], freq of spi, int type
soft_cs: direction [in], not use hardware cs, bool type, if set true, you can operate cs pin use gpio manually.
mode: direction [in], mode of spi, spi.Mode type, spi.Mode.MASTER or spi.Mode.SLAVE.
polarity: direction [in], polarity of spi, 0 means idle level of clock is low, 1 means high, int type, default is 0.
phase: direction [in], phase of spi, 0 means data is captured on the first edge of the SPI clock cycle, 1 means second, int type, default is 0.
bits: direction [in], bits of spi, int type, default is 8.
cs: direction [in], cs pin number, int type, default is 0, if SPI support multi hardware cs, you can set it to other value.
static False

C++ defination code:

SPI(int id, spi::Mode mode, int freq, bool soft_cs = false, int polarity = 0, int phase = 0, int bits = 8, int cs = 0)

read

item doc
type func
brief read data from spi
param length: direction [in], read length, int type
return bytes data, Bytes type in C++, bytes type in MaixPy. You need to delete it manually after use in C++.
static False

C++ defination code:

Bytes *read(int length)

write_read

item doc
type func
brief write data to spi and read data from spi at the same time.
param data: direction [in], data to write, Bytes type in C++, bytes type in MaixPy
read_len: direction [in], read length, int type, should > 0.
return read data, Bytes type in C++, bytes type in MaixPy. You need to delete it manually after use in C++.
static False

C++ defination code:

Bytes *write_read(Bytes *data, int read_len)

is_busy

item doc
type func
brief get busy status of spi
return busy status, bool type
static False

C++ defination code:

bool is_busy()