mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
Data Structures | Enumerations | Functions
mraa Namespace Reference

Data Structures

class  Aio
 API to Analog IO. More...
 
class  Gpio
 API to General Purpose IO. More...
 
class  I2c
 API to Inter-Integrated Circuit. More...
 
class  Iio
 API to Industrial IO. More...
 
struct  IioEventData
 
class  IioHandler
 
class  Led
 API to Light Emitting Diode. More...
 
class  MraaIo
 
class  Pwm
 API to Pulse Width Modulation. More...
 
class  Spi
 API to Serial Peripheral Interface. More...
 
class  Uart
 API to UART (enabling only) More...
 
class  UartOW
 API for UART One Wire. More...
 

Enumerations

enum  Mode { MODE_STRONG = 0, MODE_PULLUP = 1, MODE_PULLDOWN = 2, MODE_HIZ = 3 }
 
enum  Dir { DIR_OUT = 0, DIR_IN = 1, DIR_OUT_HIGH = 2, DIR_OUT_LOW = 3 }
 
enum  Edge { EDGE_NONE = 0, EDGE_BOTH = 1, EDGE_RISING = 2, EDGE_FALLING = 3 }
 
enum  InputMode { MODE_IN_ACTIVE_HIGH = 0, MODE_IN_ACTIVE_LOW = 1 }
 
enum  OutputMode { MODE_OUT_OPEN_DRAIN = 0, MODE_OUT_PUSH_PULL = 1 }
 
enum  Spi_Mode { SPI_MODE0 = 0, SPI_MODE1 = 1, SPI_MODE2 = 2, SPI_MODE3 = 3 }
 
enum  Platform {
  INTEL_GALILEO_GEN1 = 0, INTEL_GALILEO_GEN2 = 1, INTEL_EDISON_FAB_C = 2, INTEL_DE3815 = 3,
  INTEL_MINNOWBOARD_MAX = 4, RASPBERRY_PI = 5, BEAGLEBONE = 6, BANANA = 7,
  INTEL_NUC5 = 8, A96BOARDS = 9, INTEL_SOFIA_3GR = 10, INTEL_CHERRYHILLS = 11,
  INTEL_UP = 12, INTEL_JOULE_EXPANSION = 13, PHYBOARD_WEGA = 14, DE_NANO_SOC = 15,
  INTEL_UP2 = 16, MTK_LINKIT = 17, MTK_OMEGA2 = 18, IEI_TANK = 19,
  FTDI_FT4222 = 256, GROVEPI = 1024, GENERIC_FIRMATA = 1280, ANDROID_PERIPHERALMANAGER = 95,
  MOCK_PLATFORM = 96, NULL_PLATFORM = 98, UNKNOWN_PLATFORM = 99
}
 
enum  IntelEdisonMiniboard {
  INTEL_EDISON_MINIBOARD_J17_1 = 0, INTEL_EDISON_MINIBOARD_J17_5 = 4, INTEL_EDISON_MINIBOARD_J17_7 = 6, INTEL_EDISON_MINIBOARD_J17_8 = 7,
  INTEL_EDISON_MINIBOARD_J17_9 = 8, INTEL_EDISON_MINIBOARD_J17_10 = 9, INTEL_EDISON_MINIBOARD_J17_11 = 10, INTEL_EDISON_MINIBOARD_J17_12 = 11,
  INTEL_EDISON_MINIBOARD_J17_14 = 13, INTEL_EDISON_MINIBOARD_J18_1 = 14, INTEL_EDISON_MINIBOARD_J18_2 = 15, INTEL_EDISON_MINIBOARD_J18_6 = 19,
  INTEL_EDISON_MINIBOARD_J18_7 = 20, INTEL_EDISON_MINIBOARD_J18_8 = 21, INTEL_EDISON_MINIBOARD_J18_10 = 23, INTEL_EDISON_MINIBOARD_J18_11 = 24,
  INTEL_EDISON_MINIBOARD_J18_12 = 25, INTEL_EDISON_MINIBOARD_J18_13 = 26, INTEL_EDISON_MINIBOARD_J19_4 = 31, INTEL_EDISON_MINIBOARD_J19_5 = 32,
  INTEL_EDISON_MINIBOARD_J19_6 = 33, INTEL_EDISON_MINIBOARD_J19_8 = 35, INTEL_EDISON_MINIBOARD_J19_9 = 36, INTEL_EDISON_MINIBOARD_J19_10 = 37,
  INTEL_EDISON_MINIBOARD_J19_11 = 38, INTEL_EDISON_MINIBOARD_J19_12 = 39, INTEL_EDISON_MINIBOARD_J19_13 = 40, INTEL_EDISON_MINIBOARD_J19_14 = 41,
  INTEL_EDISON_MINIBOARD_J20_3 = 44, INTEL_EDISON_MINIBOARD_J20_4 = 45, INTEL_EDISON_MINIBOARD_J20_5 = 46, INTEL_EDISON_MINIBOARD_J20_6 = 47,
  INTEL_EDISON_MINIBOARD_J20_7 = 48, INTEL_EDISON_MINIBOARD_J20_8 = 49, INTEL_EDISON_MINIBOARD_J20_9 = 50, INTEL_EDISON_MINIBOARD_J20_10 = 51,
  INTEL_EDISON_MINIBOARD_J20_11 = 52, INTEL_EDISON_MINIBOARD_J20_12 = 53, INTEL_EDISON_MINIBOARD_J20_13 = 54, INTEL_EDISON_MINIBOARD_J20_14 = 55
}
 
enum  IntelEdison {
  INTEL_EDISON_GP182 = 0, INTEL_EDISON_GP135 = 4, INTEL_EDISON_GP27 = 6, INTEL_EDISON_GP20 = 7,
  INTEL_EDISON_GP28 = 8, INTEL_EDISON_GP111 = 0, INTEL_EDISON_GP109 = 10, INTEL_EDISON_GP115 = 11,
  INTEL_EDISON_GP128 = 13, INTEL_EDISON_GP13 = 14, INTEL_EDISON_GP165 = 15, INTEL_EDISON_GP19 = 19,
  INTEL_EDISON_GP12 = 20, INTEL_EDISON_GP183 = 21, INTEL_EDISON_GP110 = 23, INTEL_EDISON_GP114 = 24,
  INTEL_EDISON_GP129 = 25, INTEL_EDISON_GP130 = 26, INTEL_EDISON_GP44 = 31, INTEL_EDISON_GP46 = 32,
  INTEL_EDISON_GP48 = 33, INTEL_EDISON_GP131 = 35, INTEL_EDISON_GP14 = 36, INTEL_EDISON_GP40 = 37,
  INTEL_EDISON_GP43 = 38, INTEL_EDISON_GP77 = 39, INTEL_EDISON_GP82 = 40, INTEL_EDISON_GP83 = 41,
  INTEL_EDISON_GP134 = 44, INTEL_EDISON_GP45 = 45, INTEL_EDISON_GP47 = 46, INTEL_EDISON_GP49 = 47,
  INTEL_EDISON_GP15 = 48, INTEL_EDISON_GP84 = 49, INTEL_EDISON_GP42 = 50, INTEL_EDISON_GP41 = 51,
  INTEL_EDISON_GP78 = 52, INTEL_EDISON_GP79 = 53, INTEL_EDISON_GP80 = 54, INTEL_EDISON_GP81 = 55
}
 
enum  RaspberryWiring {
  RASPBERRY_WIRING_PIN8 = 3, RASPBERRY_WIRING_PIN9 = 5, RASPBERRY_WIRING_PIN7 = 7, RASPBERRY_WIRING_PIN15 = 8,
  RASPBERRY_WIRING_PIN16 = 10, RASPBERRY_WIRING_PIN0 = 11, RASPBERRY_WIRING_PIN1 = 12, RASPBERRY_WIRING_PIN2 = 13,
  RASPBERRY_WIRING_PIN3 = 15, RASPBERRY_WIRING_PIN4 = 16, RASPBERRY_WIRING_PIN5 = 18, RASPBERRY_WIRING_PIN12 = 19,
  RASPBERRY_WIRING_PIN13 = 21, RASPBERRY_WIRING_PIN6 = 22, RASPBERRY_WIRING_PIN14 = 23, RASPBERRY_WIRING_PIN10 = 24,
  RASPBERRY_WIRING_PIN11 = 26, RASPBERRY_WIRING_PIN17 = 29, RASPBERRY_WIRING_PIN21 = 29, RASPBERRY_WIRING_PIN18 = 30,
  RASPBERRY_WIRING_PIN19 = 31, RASPBERRY_WIRING_PIN22 = 31, RASPBERRY_WIRING_PIN20 = 32, RASPBERRY_WIRING_PIN26 = 32,
  RASPBERRY_WIRING_PIN23 = 33, RASPBERRY_WIRING_PIN24 = 35, RASPBERRY_WIRING_PIN27 = 36, RASPBERRY_WIRING_PIN25 = 37,
  RASPBERRY_WIRING_PIN28 = 38, RASPBERRY_WIRING_PIN29 = 40
}
 
enum  Result {
  SUCCESS = 0, ERROR_FEATURE_NOT_IMPLEMENTED = 1, ERROR_FEATURE_NOT_SUPPORTED = 2, ERROR_INVALID_VERBOSITY_LEVEL = 3,
  ERROR_INVALID_PARAMETER = 4, ERROR_INVALID_HANDLE = 5, ERROR_NO_RESOURCES = 6, ERROR_INVALID_RESOURCE = 7,
  ERROR_INVALID_QUEUE_TYPE = 8, ERROR_NO_DATA_AVAILABLE = 9, ERROR_INVALID_PLATFORM = 10, ERROR_PLATFORM_NOT_INITIALISED = 11,
  ERROR_UART_OW_SHORTED = 12, ERROR_UART_OW_NO_DEVICES = 13, ERROR_UART_OW_DATA_ERROR = 14, ERROR_UNSPECIFIED = 99
}
 
enum  Pinmodes {
  PIN_VALID = 0, PIN_GPIO = 1, PIN_PWM = 2, PIN_FAST_GPIO = 3,
  PIN_SPI = 4, PIN_I2C = 5, PIN_AIO = 6, PIN_UART = 7
}
 
enum  I2cMode { I2C_STD = 0, I2C_FAST = 1, I2C_HIGH = 2 }
 
enum  UartParity {
  UART_PARITY_NONE = 0, UART_PARITY_EVEN = 1, UART_PARITY_ODD = 2, UART_PARITY_MARK = 3,
  UART_PARITY_SPACE = 4
}
 

Functions

Result init ()
 
std::string getVersion ()
 
int setPriority (const int priority)
 
Platform getPlatformType ()
 
void printError (Result result)
 
bool pinModeTest (int pin, Pinmodes mode)
 
unsigned int adcRawBits ()
 
unsigned int adcSupportedBits ()
 
std::string getPlatformName ()
 
std::string getPlatformVersion (int platform_offset=MRAA_MAIN_PLATFORM_OFFSET)
 
unsigned int getPinCount ()
 
int getUartCount ()
 
int getI2cBusCount ()
 
int getI2cBusId (int i2c_bus)
 
std::string getPinName (int pin)
 
int getGpioLookup (std::string pin_name)
 
int getI2cLookup (std::string i2c_name)
 
int getSpiLookup (std::string spi_name)
 
int getPwmLookup (std::string pwm_name)
 
int getUartLookup (std::string uart_name)
 
Result setLogLevel (int level)
 
bool hasSubPlatform ()
 
bool isSubPlatformId (int pin_or_bus_id)
 
int getSubPlatformId (int pin_or_bus_index)
 
int getSubPlatformIndex (int pin_or_bus_id)
 
int getDefaultI2cBus (int platform_offset=MRAA_MAIN_PLATFORM_OFFSET)
 
Result addSubplatform (Platform subplatformtype, std::string dev)
 
Result removeSubplatform (Platform subplatformtype)
 
template<class T >
T * initIo (std::string desc)
 
Result initJsonPlatform (std::string path)
 

Detailed Description

namespace

Enumeration Type Documentation

enum Mode

Gpio Output modes

Enumerator
MODE_STRONG 

Default. Strong High and Low

MODE_PULLUP 

Resistive High

MODE_PULLDOWN 

Resistive Low

MODE_HIZ 

High Z State

enum Dir

Gpio Direction options

Enumerator
DIR_OUT 

Output. A Mode can also be set

DIR_IN 

Input

DIR_OUT_HIGH 

Output. Init High

DIR_OUT_LOW 

Output. Init Low

enum Edge

Gpio Edge types for interrupts

Enumerator
EDGE_NONE 

No interrupt on Gpio

EDGE_BOTH 

Interrupt on rising & falling

EDGE_RISING 

Interrupt on rising only

EDGE_FALLING 

Interrupt on falling only

enum InputMode

Gpio Input modes

Enumerator
MODE_IN_ACTIVE_HIGH 

Resistive High

MODE_IN_ACTIVE_LOW 

Resistive Low

enum OutputMode

Gpio output driver modes

Enumerator
MODE_OUT_OPEN_DRAIN 

Open Drain Configuration

MODE_OUT_PUSH_PULL 

Push Pull Configuration

enum Spi_Mode

MRAA SPI Modes

Enumerator
SPI_MODE0 

CPOL = 0, CPHA = 0, Clock idle low, data is clocked in on rising edge, output data (change) on falling edge

SPI_MODE1 

CPOL = 0, CPHA = 1, Clock idle low, data is clocked in on falling edge, output data (change) on rising edge

SPI_MODE2 

CPOL = 1, CPHA = 0, Clock idle low, data is clocked in on falling edge, output data (change) on rising edge

SPI_MODE3 

CPOL = 1, CPHA = 1, Clock idle low, data is clocked in on rising, edge output data (change) on falling edge

enum Platform

MRAA supported platform types

Enumerator
INTEL_GALILEO_GEN1 

The Generation 1 Galileo platform (RevD)

INTEL_GALILEO_GEN2 

The Generation 2 Galileo platform (RevG/H)

INTEL_EDISON_FAB_C 

The Intel Edison (FAB C)

INTEL_DE3815 

The Intel DE3815 Baytrail NUC

INTEL_MINNOWBOARD_MAX 

The Intel Minnow Board Max

RASPBERRY_PI 

The different Raspberry PI Models -like A,B,A+,B+

BEAGLEBONE 

The different BeagleBone Black Modes B/C

BANANA 

Allwinner A20 based Banana Pi and Banana Pro

INTEL_NUC5 

The Intel 5th generations Broadwell NUCs

A96BOARDS 

Linaro 96boards, A prefix for 'ARM' since not allowed numerical

INTEL_SOFIA_3GR 

The Intel SoFIA 3GR

INTEL_CHERRYHILLS 

The Intel Braswell Cherryhills

INTEL_UP 

The UP Board

INTEL_JOULE_EXPANSION 

The Intel Joule Expansion Board

PHYBOARD_WEGA 

The phyBOARD-Wega

DE_NANO_SOC 

Terasic DE-Nano-SoC Board

INTEL_UP2 

The UP^2 Board

MTK_LINKIT 

Mediatek MT7688 based Linkit boards

MTK_OMEGA2 

MT7688 based Onion Omega2 board

IEI_TANK 

IEI Tank System

FTDI_FT4222 

FTDI FT4222 USB to i2c bridge

GROVEPI 

GrovePi shield i2c bridge

GENERIC_FIRMATA 

Firmata uart platform/bridge

ANDROID_PERIPHERALMANAGER 

Android Things peripheral manager platform

MOCK_PLATFORM 

Mock platform, which requires no real hardware

UNKNOWN_PLATFORM 

An unknown platform type, typically will load INTEL_GALILEO_GEN1

Intel edison miniboard numbering enum

Intel Edison raw GPIO numbering enum

Raspberry PI Wiring compatible numbering enum

enum Result

MRAA return codes

Enumerator
SUCCESS 

Expected response

ERROR_FEATURE_NOT_IMPLEMENTED 

Feature TODO

ERROR_FEATURE_NOT_SUPPORTED 

Feature not supported by HW

ERROR_INVALID_VERBOSITY_LEVEL 

Verbosity level wrong

ERROR_INVALID_PARAMETER 

Parameter invalid

ERROR_INVALID_HANDLE 

Handle invalid

ERROR_NO_RESOURCES 

No resource of that type avail

ERROR_INVALID_RESOURCE 

Resource invalid

ERROR_INVALID_QUEUE_TYPE 

Queue type incorrect

ERROR_NO_DATA_AVAILABLE 

No data available

ERROR_INVALID_PLATFORM 

Platform not recognised

ERROR_PLATFORM_NOT_INITIALISED 

Board information not initialised

ERROR_UART_OW_SHORTED 

UART OW Short Circuit Detected

ERROR_UART_OW_NO_DEVICES 

UART OW No devices detected

ERROR_UART_OW_DATA_ERROR 

UART OW Data/Bus error detected

ERROR_UNSPECIFIED 

Unknown Error

enum Pinmodes

Enum representing different possible modes for a pin.

Enumerator
PIN_VALID 

Pin Valid

PIN_GPIO 

General Purpose IO

PIN_PWM 

Pulse Width Modulation

PIN_FAST_GPIO 

Faster GPIO

PIN_SPI 

SPI

PIN_I2C 

I2C

PIN_AIO 

Analog in

PIN_UART 

UART

enum I2cMode

Enum representing different i2c speeds/modes

Enumerator
I2C_STD 

up to 100Khz

I2C_FAST 

up to 400Khz

I2C_HIGH 

up to 3.4Mhz

enum UartParity

Enum representing different uart parity states

Function Documentation

Result mraa::init ( )
inline

Initialise MRAA

Detects running platform and attempts to use included pinmap, this is run on module/library init/load but is handy to rerun to check board initialised correctly. mraa::SUCCESS inidicates correct initialisation.

Returns
Result of operation

Here is the call graph for this function:

std::string mraa::getVersion ( )
inline

Get libmraa version.

Returns
libmraa version (e.g. v0.4.0-20-gb408207)

Here is the call graph for this function:

int mraa::setPriority ( const int  priority)
inline

This function attempts to set the mraa process to a given priority and the scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0. This function * will set to MAX if * priority is > MAX. Function will return -1 on failure.

Parameters
priorityValue from typically 0 to 99
Returns
The priority value set

Here is the call graph for this function:

Platform mraa::getPlatformType ( )
inline

Get platform type, board must be initialised.

Returns
mraa::platform Platform type enum

Here is the call graph for this function:

void mraa::printError ( Result  result)
inline

Print a textual representation of the mraa::Result

Parameters
resultthe Result to print

Here is the call graph for this function:

bool mraa::pinModeTest ( int  pin,
Pinmodes  mode 
)
inline

Checks if a pin is able to use the passed in mode.

Parameters
pinPhysical Pin to be checked.
modethe mode to be tested.
Returns
boolean if the mode is supported, 0=false.

Here is the call graph for this function:

unsigned int mraa::adcRawBits ( )
inline

Check the board's bit size when reading the value

Returns
raw bits being read from kernel module. Zero if no ADC

Here is the call graph for this function:

unsigned int mraa::adcSupportedBits ( )
inline

Return value that the raw value should be shifted to. Zero if no ADC

Returns
return actual bit size the adc value should be understood as.

Here is the call graph for this function:

std::string mraa::getPlatformName ( )
inline

Return platform name.

Returns
platform name or empty string if not initialised

Here is the call graph for this function:

std::string mraa::getPlatformVersion ( int  platform_offset = MRAA_MAIN_PLATFORM_OFFSET)
inline

Return platform versioning info.

Parameters
platform_offsetoptional subplatform identifier
Returns
platform versioning info or empty string if no info is present

Here is the call graph for this function:

unsigned int mraa::getPinCount ( )
inline

Return count of physical pins on the running platform

Returns
uint of physical pins.

Here is the call graph for this function:

int mraa::getUartCount ( )
inline

Get platform usable UART count, board must be initialised.

Returns
number of usable UARTs on the current platform. Function will return -1 on failure

Here is the call graph for this function:

int mraa::getI2cBusCount ( )
inline

Get platform usable I2C bus count, board must be initialised.

Returns
number f usable I2C bus count on the current platform. Function will return -1 on failure

Here is the call graph for this function:

int mraa::getI2cBusId ( int  i2c_bus)
inline

Get I2C adapter number in sysfs.

Parameters
i2c_busthe logical I2C bus number
Returns
I2C adapter number in sysfs. Function will return -1 on failure

Here is the call graph for this function:

std::string mraa::getPinName ( int  pin)
inline

Get name of pin, board must be initialised.

Parameters
pinnumber
Returns
Pin name or empty string on failure

Here is the call graph for this function:

int mraa::getGpioLookup ( std::string  pin_name)
inline

Get GPIO index by pin name, board must be initialised.

Parameters
pin_nameGPIO pin name. Eg: IO0
Exceptions
std::invalid_argumentif name is not found
Returns
int of MRAA index for GPIO

Here is the call graph for this function:

int mraa::getI2cLookup ( std::string  i2c_name)
inline

Get I2C bus index by bus name, board must be initialised.

Parameters
i2c_nameI2C bus name. Eg: I2C6
Exceptions
std::invalid_argumentif name is not found
Returns
int of MRAA index for I2C bus

Here is the call graph for this function:

int mraa::getSpiLookup ( std::string  spi_name)
inline

Get SPI bus index by bus name, board must be initialised.

Parameters
spi_nameName of SPI bus. Eg: SPI2
Exceptions
std::invalid_argumentif name is not found
Returns
int of MRAA index for SPI bus

Here is the call graph for this function:

int mraa::getPwmLookup ( std::string  pwm_name)
inline

Get PWM index by PWM name, board must be initialised.

Parameters
pwm_nameName of PWM. Eg:PWM0
Exceptions
std::invalid_argumentif name is not found
Returns
int of MRAA index for PWM

Here is the call graph for this function:

int mraa::getUartLookup ( std::string  uart_name)
inline

Get UART index by UART name, board must be initialised.

Parameters
uart_nameName of the UART. Eg: UART2
Exceptions
std::invalid_argumentif name is not found
Returns
MRAA index for the UART

Here is the call graph for this function:

Result mraa::setLogLevel ( int  level)
inline

Sets the log level to use from 0-7 where 7 is very verbose. These are the syslog log levels, see syslog(3) for more information on the levels.

Parameters
level
Returns
Result of operation

Here is the call graph for this function:

bool mraa::hasSubPlatform ( )
inline

Detect presence of sub platform.

Returns
bool true if sub platform is present and initialized, false otherwise

Here is the call graph for this function:

bool mraa::isSubPlatformId ( int  pin_or_bus_id)
inline

Check if pin or bus id includes sub platform mask.

Parameters
pin_or_bus_idpin or bus number
Returns
mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise

Here is the call graph for this function:

int mraa::getSubPlatformId ( int  pin_or_bus_index)
inline

Convert pin or bus index to corresponding sub platform id.

Parameters
pin_or_bus_indexpin or bus index
Returns
int sub platform pin or bus number

Here is the call graph for this function:

int mraa::getSubPlatformIndex ( int  pin_or_bus_id)
inline

Convert pin or bus sub platform id to index.

Parameters
pin_or_bus_idsub platform pin or bus id
Returns
int pin or bus index

Here is the call graph for this function:

int mraa::getDefaultI2cBus ( int  platform_offset = MRAA_MAIN_PLATFORM_OFFSET)
inline

Get default i2c bus, board must be initialised.

Parameters
platform_offsetoptional subplatform identifier
Returns
default i2c bus for paltform

Here is the call graph for this function:

Result mraa::addSubplatform ( Platform  subplatformtype,
std::string  dev 
)
inline

Add mraa subplatform

Parameters
subplatformtypethe type of subplatform to add (e.g. MRAA_GENERIC_FIRMATA or MRAA_GROVEPI)
devsubplatform uart device string or i2c bus number (e.g. "/dev/ttyACM0" or "0")
Returns
Result of operation

Here is the call graph for this function:

Result mraa::removeSubplatform ( Platform  subplatformtype)
inline

Remove mraa subplatform

Parameters
subplatformtypethe type of subplatform to remove (e.g. MRAA_GENERIC_FIRMATA)
Returns
Result of operation

Here is the call graph for this function:

T* mraa::initIo ( std::string  desc)
inline

Create IO using a description in the format: [io]-[pin] [io]-[raw]-[pin] [io]-[raw]-[id]-[pin] [io]-[raw]-[path]

Parameters
descdescription
Returns
class T initialised using pointer to IO or NULL

Here is the call graph for this function:

Result mraa::initJsonPlatform ( std::string  path)
inline

Instantiate an unknown board using a json file

Parameters
pathPath to the json file, relative to the folder the program was initially run in or a direct path
Returns
Result indicating success

Here is the call graph for this function: