mraa  0.8.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
Classes | Enumerations | Functions
mraa Namespace Reference

Classes

class  Aio
 API to Analog IO. More...
 
class  Gpio
 API to General Purpose IO. More...
 
class  I2c
 API to Inter-Integrated Circuit. More...
 
class  Pwm
 API to Pulse Width Modulation. More...
 
class  Spi
 API to Serial Peripheral Interface. More...
 
class  Uart
 API to UART (enabling only) 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  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,
  UNKNOWN_PLATFORM
}
 
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_PLATFORM_ALREADY_INITIALISED = 12, 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 unsigned int priority)
 
Platform getPlatformType ()
 
void printError (Result result)
 
bool pinModeTest (int pin, Pinmodes mode)
 
unsigned int adcRawBits ()
 
unsigned int adcSupportedBits ()
 
std::string getPlatformName ()
 
unsigned int getPinCount ()
 
int getI2cBusCount ()
 
int getI2cBusId (unsigned int i2c_bus)
 
std::string getPinName (int pin)
 
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)
 

Detailed Description

namespace

Enumeration Type Documentation

enum Mode

Gpio Output modes

Enumerator
MODE_STRONG 

Default. Strong High and Low

MODE_PULLUP 

Interupt on rising & falling

MODE_PULLDOWN 

Interupt on rising only

MODE_HIZ 

Interupt on falling only

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 interupts

Enumerator
EDGE_NONE 

No interrupt on Gpio

EDGE_BOTH 

Interupt on rising & falling

EDGE_RISING 

Interupt on rising only

EDGE_FALLING 

Interupt on falling only

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

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_PLATFORM_ALREADY_INITIALISED 

Board is already initialised

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 reprensenting different i2c speeds/modes

Enumerator
I2C_STD 

up to 100Khz

I2C_FAST 

up to 400Khz

I2C_HIGH 

up to 3.4Mhz

Function Documentation

Result mraa::init ( )

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 (first time) initialisation whilst MRAA_ERROR_PLATFORM_ALREADY_INITIALISED indicates the board is already initialised correctly

Returns
Result of operation

Here is the call graph for this function:

std::string mraa::getVersion ( )

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 unsigned int  priority)

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 ( )

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)

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 
)

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 ( )

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 ( )

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 ( )

Return Platform Name. Returns NULL if no platform inited.

Returns
platform name

Here is the call graph for this function:

unsigned int mraa::getPinCount ( )

Return count of physical pins on the running platform

Returns
uint of physical pins.

Here is the call graph for this function:

int mraa::getI2cBusCount ( )

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 ( unsigned int  i2c_bus)

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)

Get name of pin, board must be initialised.

Parameters
pinnumber
Returns
char* of pin name

Here is the call graph for this function:

Result mraa::setLogLevel ( int  level)

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 ( )

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)

Check if pin or bus id includes sub platform mask.

Parameters
intpin 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)

Convert pin or bus index to corresponding sub platform id.

Parameters
intpin 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)

Convert pin or bus sub platform id to index.

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

Here is the call graph for this function: