Bases: object
API to Analog IO.
This file defines the aio interface for libmraa
C++ includes: aio.hpp
self: mraa::Aio *
Gets the bit value mraa is shifting the analog read to.
bit value mraa is set return from the read function
self: mraa::Aio *
Read a value from the AIO pin. By default mraa will shift the raw value up or down to a 10 bit value.
std::invalid_argument: in case of error
The current input voltage. By default, a 10bit value
Bases: object
API to Inter-Integrated Circuit.
An I2c object represents an i2c master and can talk multiple i2c slaves by selecting the correct addressIt is considered best practice to make sure the address is correct before doing any calls on i2c, in case another application or even thread changed the addres on that bus. Multiple instances of the same bus can exist.
C++ includes: i2c.hpp
address: uint8_t
Set the slave to talk to, typically called before every read/write operation
address: Communicate to the i2c slave on this address
Result of operation
mode: enum mraa::I2cMode
Sets the i2c Frequency for communication. Your board may not support the set frequency. Anyone can change this at any time and this will affect every slave on the bus
mode: Frequency to set the bus to
Result of operation
data: uint8_t *
Read length bytes from the bus into *data pointer
data: Data to read into
length: Size of read in bytes to make
length of read, should match length
self: mraa::I2c *
Read exactly one byte from the bus
std::invalid_argument: in case of error
char read from the bus
reg: uint8_t data: uint8_t *
Read length bytes from the bus into *data pointer starting from an i2c register
reg: Register to read from
data: pointer to the byte array to read data in to
length: max number of bytes to read
length passed to the function or -1
reg: uint8_t
Read byte from an i2c register
reg: Register to read from
std::invalid_argument: in case of error
char read from register
reg: uint8_t
Read word from an i2c register
reg: Register to read from
std::invalid_argument: in case of error
char read from register
data: uint8_t const *
Write length bytes to the bus, the first byte in the array is the command/register to write
data: Buffer to send on the bus, first byte is i2c command
length: Size of buffer to send
Result of operation
data: uint8_t
Write a byte on the bus
data: The byte to send on the bus
Result of operation
Bases: object
API to General Purpose IO.
This file defines the gpio interface for libmraa
C++ includes: gpio.hpp
dir: enum mraa::Dir
Change Gpio direction
dir: The direction to change the gpio into
Result of operation
mode: enum mraa::Edge
Set the edge mode for ISR
mode: The edge mode to set
Result of operation
raw: bool
getPin(Gpio self) -> int
self: mraa::Gpio *
Get pin number of Gpio. If raw param is True will return the number as used within sysfs. Invalid will return -1.
raw: (optional) get the raw gpio number.
Pin number
mode: enum mraa::Edge pyfunc: PyObject * args: PyObject *
Sets a callback to be called when pin value changes
mode: The edge mode to set
fptr: Function pointer to function to be called when interrupt is triggered
args: Arguments passed to the interrupt handler (fptr)
Result of operation
self: mraa::Gpio *
Exits callback - this call will not kill the isr thread immediately but only when it is out of it’s critical section
Result of operation
mode: enum mraa::Mode
Change Gpio mode
mode: The mode to change the gpio into
Result of operation
self: mraa::Gpio *
Read Gpio direction
std::runtime_error: in case of failure
Result of operation
Bases: object
API to Pulse Width Modulation.
This file defines the PWM interface for libmraa
C++ includes: pwm.hpp
enable: bool
Set the enable status of the PWM pin. None zero will assume on with output being driven and 0 will disable the output
enable: enable status of pin
Result of operation
self: mraa::Pwm *
Get the maximum pwm period in us
max pwm in us
self: mraa::Pwm *
Get the minimum pwm period in us
min pwm in us
period: float
Set the PWM period as seconds represented in a float
period: Period represented as a float in seconds
Result of operation
ms: int
Set period, milliseconds
ms: milliseconds for period
Result of operation
us: int
Set period, microseconds
us: microseconds as period
Result of operation
seconds: float
Set pulsewidth, As represnted by seconds in a (float)
seconds: The duration of a pulse
Result of operation
ms: int
Set pulsewidth, milliseconds
ms: milliseconds for pulsewidth
Result of operation
us: int
The pulsewidth, microseconds
us: microseconds for pulsewidth
Result of operation
self: mraa::Pwm *
Read the output duty-cycle percentage, as a float
A floating-point value representing percentage of output. The value should lie between 0.0f (representing on 0%) and 1.0f Values above or below this range will be set at either 0.0f or 1.0f
percentage: float
Set the output duty-cycle percentage, as a float
percentage: A floating-point value representing percentage of output. The value should lie between 0.0f (representing on 0%) and 1.0f Values above or below this range will be set at either 0.0f or 1.0f
Result of operation
Bases: object
API to Serial Peripheral Interface.
This file defines the SPI interface for libmraa
C++ includes: spi.hpp
bits: unsigned int
Set bits per mode on transaction, default is 8
bits: bits per word
Result of operation
hz: int
Set the SPI device operating clock frequency
hz: the frequency to set in hz
Result of operation
lsb: bool
Change the SPI lsb mode
lsb: Use least significant bit transmission - 0 for msbi
Result of operation
mode: enum mraa::Spi_Mode
Set the SPI device mode. see spidev0-3
mode: the mode. See Linux spidev doc
Result of operation
txBuf: uint8_t *
Write buffer of bytes to SPI device The pointer return has to be free’d by the caller. It will return a NULL pointer in cases of error
txBuf: buffer to send
length: size of buffer to send
uint8_t* data received on the miso line. Same length as passed in
data: uint8_t
Write single byte to the SPI device
data: the byte to send
data received on the miso line or -1 in case of error
data: uint16_t
Write buffer of bytes to SPI device The pointer return has to be free’d by the caller. It will return a NULL pointer in cases of error
txBuf: buffer to send
length: size of buffer (in bytes) to send
uint8_t* data received on the miso line. Same length as passed in
Bases: object
API to UART (enabling only)
This file defines the UART interface for libmraa
C++ includes: uart.hpp
nonblock: bool
Set the blocking state for write operations
dev: The UART context
nonblock: new nonblocking state
Result of operation
millis: unsigned int
dataAvailable(Uart self) -> bool
self: mraa::Uart *
Check to see if data is available on the device for reading
millis: number of milliseconds to wait, or 0 to return immediately
true if there is data available to read, false otherwise
self: mraa::Uart *
Flush the outbound data. Blocks until complete.
Result of operation
self: mraa::Uart *
Get string with tty device path within Linux For example. Could point to “/dev/ttyS0”
char pointer of device path
data: char *
Read bytes from the device into char* buffer
data: buffer pointer
length: maximum size of buffer
numbers of bytes read
length: int
Read bytes from the device into a String object
length: to read
std::bad_alloc: If there is no space left for read.
string of data
baud: unsigned int
Set the baudrate. Takes an int and will attempt to decide what baudrate is to be used on the UART hardware.
baud: unsigned int of baudrate i.e. 9600
Result of operation
xonxoff: bool rtscts: bool
Set the flowcontrol
xonxoff: XON/XOFF Software flow control.
rtscts: RTS/CTS out of band hardware flow control
Result of operation
bytesize: int parity: enum mraa::UartParity stopbits: int
Set the transfer mode For example setting the mode to 8N1 would be “dev.setMode(8,UART_PARITY_NONE , 1)”
bytesize: data bits
parity: Parity bit setting
stopbits: stop bits
Result of operation
read: int write: int interchar: int
Set the timeout for read and write operations <= 0 will disable that timeout
read: read timeout
write: write timeout
interchar: inbetween char timeout
Result of operation
Python interface to libmraa
subplatformtype: enum mraa::Platform uart_dev: std::string
platform_offset: int
getDefaultI2cBus() -> int
platform_offset: int
getPlatformVersion() -> std::string