MRAA

MRAA is a low level skeleton library for communication on GNU/Linux platforms. See examples here.

Spi Class

Module: mraa

This file defines the SPI interface for libmraa

Methods

Spi

(
  • bus
)
Number

Initialise SPI object using the board mapping to set muxes

Parameters:

  • bus Number

    to use, as listed in the platform definition, normally 0

Returns:

Number:

Spi

(
  • bus
  • cs
)
Number

Initialise SPI object using 'raw' mode. Mraa will go and grab the spidev device lablled /dev/spidev[bus].[cs]

Parameters:

  • bus Number

    to use

  • cs Number

    to use

Returns:

Number:

mode

(
  • mode
)
Enum Result

Set the SPI device mode. see spidev0-3

Parameters:

  • mode Enum Spi_Mode

    the mode. See Linux spidev doc

Returns:

Enum Result:

Result of operation

frequency

(
  • hz
)
Enum Result

Set the SPI device operating clock frequency

Parameters:

  • hz Number

    the frequency to set in hz

Returns:

Enum Result:

Result of operation

writeByte

(
  • data
)
Number

Write single byte to the SPI device

Parameters:

  • data Number

    the byte to send

Returns:

Number:

data received on the miso line or -1 in case of error

writeWord

(
  • data
)
Number

Write single byte to the SPI device

Parameters:

  • data Number

    the byte to send

Returns:

Number:

data received on the miso line or -1 in case of error

lsbmode

(
  • lsb
)
Enum Result

Change the SPI lsb mode

Parameters:

  • lsb Boolean

    Use least significant bit transmission - 0 for msbi

Returns:

Enum Result:

Result of operation

bitPerWord

(
  • bits
)
Enum Result

Set bits per mode on transaction, default is 8

Parameters:

  • bits Number

    bits per word

Returns:

Enum Result:

Result of operation