SPI

SPI(etp)

Methods:

Name Description
get_info

Query SPI information, bus counts and supported speeds.

init

Initialize SPI bus.

transfer

Transfer data over SPI bus.

get_info

get_info() -> dict

Query SPI information, bus counts and supported speeds.

Returns:
  • dict( dict ) –

    Dictionary containing SPI bus count, supported speeds and pin information

    Key Value Type Description
    bus_count int Number of SPI buses
    bus_speeds list List of supported SPI bus speeds
    info list List of SPI pins and their corresponding pins

init

init(bus, mode, speed, bit_order=MSB_FIRST, cs=255) -> int

Initialize SPI bus.

Parameters:
  • bus (int) –

    SPI bus number.

  • mode (int) –

    SPI mode (0, 1, 2, 3).

  • speed (int) –

    SPI bus speed in KHz.

  • bit_order (int, default: MSB_FIRST ) –

    Bit order (MSB_FIRST, LSB_FIRST).

  • cs (int, default: 255 ) –

    Chip select pin number.

Returns:
  • int( int ) –

    Status of the operation.

transfer

transfer(
    bus: int, tx_data: list[int], cs: int = 255
) -> list[int]

Transfer data over SPI bus.

Parameters:
  • bus (int) –

    SPI bus number.

  • tx_data (list[int]) –

    List of bytes to be transmitted.

  • cs (int, default: 255 ) –

    Chip select pin number.

Returns:
  • list[int]

    List of bytes received over SPI bus.