common Class
Item Index
Methods
- init
- getVersion
- setPriority
- getPlatformType
- printError
- pinModeTest
- adcRawBits
- adcSupportedBits
- getPlatformName
- getPlatformVersion
- getPinCount
- getUartCount
- getI2cBusCount
- getI2cBusId
- getPinName
- getGpioLookup
- getI2cLookup
- getSpiLookup
- getPwmLookup
- getUartLookup
- setLogLevel
- hasSubPlatform
- isSubPlatformId
- getSubPlatformId
- getSubPlatformIndex
- getDefaultI2cBus
- addSubplatform
- removeSubplatform
- initJsonPlatform
Methods
init
()
Enum Result
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
getVersion
()
String
Get libmraa version.
Returns:
libmraa version (e.g. v0.4.0-20-gb408207)
setPriority
-
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:
-
priority
NumberValue from typically 0 to 99
Returns:
The priority value set
getPlatformType
()
Enum Platform
Get platform type, board must be initialised.
Returns:
mraa::platform Platform type enum
printError
-
result
Print a textual representation of the mraa::Result
Parameters:
-
result
Enum Resultthe Result to print
pinModeTest
-
pin
-
mode
Checks if a pin is able to use the passed in mode.
Parameters:
-
pin
NumberPhysical Pin to be checked.
-
mode
Enum Pinmodesthe mode to be tested.
Returns:
boolean if the mode is supported, 0=false.
adcRawBits
()
Number
Check the board's bit size when reading the value
Returns:
raw bits being read from kernel module. Zero if no ADC
adcSupportedBits
()
Number
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.
getPlatformName
()
String
Return platform name.
Returns:
platform name or empty string if not initialised
getPlatformVersion
-
platform_offset
Return platform versioning info.
Parameters:
-
platform_offset
Numberoptional subplatform identifier
Returns:
platform versioning info or empty string if no info is present
getPinCount
()
Number
Return count of physical pins on the running platform
Returns:
uint of physical pins.
getUartCount
()
Number
Get platform usable UART count, board must be initialised.
Returns:
number of usable UARTs on the current platform. Function will return -1 on failure
getI2cBusCount
()
Number
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
getI2cBusId
-
i2c_bus
Get I2C adapter number in sysfs.
Parameters:
-
i2c_bus
Numberthe logical I2C bus number
Returns:
I2C adapter number in sysfs. Function will return -1 on failure
getPinName
-
pin
Get name of pin, board must be initialised.
Parameters:
-
pin
Numbernumber
Returns:
Pin name or empty string on failure
getGpioLookup
-
pin_name
Get GPIO index by pin name, board must be initialised.
Parameters:
-
pin_name
StringGPIO pin name. Eg: IO0
Returns:
int of MRAA index for GPIO
getI2cLookup
-
i2c_name
Get I2C bus index by bus name, board must be initialised.
Parameters:
-
i2c_name
StringI2C bus name. Eg: I2C6
Returns:
int of MRAA index for I2C bus
getSpiLookup
-
spi_name
Get SPI bus index by bus name, board must be initialised.
Parameters:
-
spi_name
StringName of SPI bus. Eg: SPI2
Returns:
int of MRAA index for SPI bus
getPwmLookup
-
pwm_name
Get PWM index by PWM name, board must be initialised.
Parameters:
-
pwm_name
StringName of PWM. Eg:PWM0
Returns:
int of MRAA index for PWM
getUartLookup
-
uart_name
Get UART index by UART name, board must be initialised.
Parameters:
-
uart_name
StringName of the UART. Eg: UART2
Returns:
MRAA index for the UART
setLogLevel
-
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
Number
Returns:
Result of operation
hasSubPlatform
()
Boolean
Detect presence of sub platform.
Returns:
bool true if sub platform is present and initialized, false otherwise
isSubPlatformId
-
pin_or_bus_id
Check if pin or bus id includes sub platform mask.
Parameters:
-
pin_or_bus_id
Numberpin or bus number
Returns:
mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise
getSubPlatformId
-
pin_or_bus_index
Convert pin or bus index to corresponding sub platform id.
Parameters:
-
pin_or_bus_index
Numberpin or bus index
Returns:
int sub platform pin or bus number
getSubPlatformIndex
-
pin_or_bus_id
Convert pin or bus sub platform id to index.
Parameters:
-
pin_or_bus_id
Numbersub platform pin or bus id
Returns:
int pin or bus index
getDefaultI2cBus
-
platform_offset
Get default i2c bus, board must be initialised.
Parameters:
-
platform_offset
Numberoptional subplatform identifier
Returns:
default i2c bus for paltform
addSubplatform
-
subplatformtype
-
dev
Add mraa subplatform
Parameters:
-
subplatformtype
Enum Platformthe type of subplatform to add (e.g. MRAA_GENERIC_FIRMATA or MRAA_GROVEPI)
-
dev
Stringsubplatform uart device string or i2c bus number (e.g. "/dev/ttyACM0" or "0")
Returns:
Result of operation
removeSubplatform
-
subplatformtype
Remove mraa subplatform
Parameters:
-
subplatformtype
Enum Platformthe type of subplatform to remove (e.g. MRAA_GENERIC_FIRMATA)
Returns:
Result of operation
initJsonPlatform
-
path
Instantiate an unknown board using a json file
Parameters:
-
path
StringPath to the json file, relative to the folder the program was initially run in or a direct path
Returns:
Result indicating success
Enums
Enum | Description |
---|---|
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 |
INTEL_SOFIA_3GR | The Intel SoFIA 3GR |
INTEL_CHERRYHILLS | The Intel Braswell Cherryhills |
INTEL_JOULE_EXPANSION | The Intel Joule Expansion Board |
PHYBOARD_WEGA | The phyBOARD-Wega |
DE_NANO_SOC | Terasic DE-Nano-SoC 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 |
NULL_PLATFORM | |
UNKNOWN_PLATFORM | An unknown platform type, typically will load INTEL_GALILEO_GEN1 |
A96BOARDS | Linaro 96boards, A prefix for 'ARM' since not allowed numerical |
INTEL_UP | The UP Board |
INTEL_UP2 | The UP^2 Board |
Enum | Description |
---|---|
96BOARDS | Linaro 96boards |
UP | The UP Board |
UP2 | The UP^2 Board |
JSON_PLATFORM | User initialised platform from json |
Enum | Description |
---|---|
INTEL_EDISON_MINIBOARD_J17_1 | |
INTEL_EDISON_MINIBOARD_J17_5 | |
INTEL_EDISON_MINIBOARD_J17_7 | |
INTEL_EDISON_MINIBOARD_J17_8 | |
INTEL_EDISON_MINIBOARD_J17_9 | |
INTEL_EDISON_MINIBOARD_J17_10 | |
INTEL_EDISON_MINIBOARD_J17_11 | |
INTEL_EDISON_MINIBOARD_J17_12 | |
INTEL_EDISON_MINIBOARD_J17_14 | |
INTEL_EDISON_MINIBOARD_J18_1 | |
INTEL_EDISON_MINIBOARD_J18_2 | |
INTEL_EDISON_MINIBOARD_J18_6 | |
INTEL_EDISON_MINIBOARD_J18_7 | |
INTEL_EDISON_MINIBOARD_J18_8 | |
INTEL_EDISON_MINIBOARD_J18_10 | |
INTEL_EDISON_MINIBOARD_J18_11 | |
INTEL_EDISON_MINIBOARD_J18_12 | |
INTEL_EDISON_MINIBOARD_J18_13 | |
INTEL_EDISON_MINIBOARD_J19_4 | |
INTEL_EDISON_MINIBOARD_J19_5 | |
INTEL_EDISON_MINIBOARD_J19_6 | |
INTEL_EDISON_MINIBOARD_J19_8 | |
INTEL_EDISON_MINIBOARD_J19_9 | |
INTEL_EDISON_MINIBOARD_J19_10 | |
INTEL_EDISON_MINIBOARD_J19_11 | |
INTEL_EDISON_MINIBOARD_J19_12 | |
INTEL_EDISON_MINIBOARD_J19_13 | |
INTEL_EDISON_MINIBOARD_J19_14 | |
INTEL_EDISON_MINIBOARD_J20_3 | |
INTEL_EDISON_MINIBOARD_J20_4 | |
INTEL_EDISON_MINIBOARD_J20_5 | |
INTEL_EDISON_MINIBOARD_J20_6 | |
INTEL_EDISON_MINIBOARD_J20_7 | |
INTEL_EDISON_MINIBOARD_J20_8 | |
INTEL_EDISON_MINIBOARD_J20_9 | |
INTEL_EDISON_MINIBOARD_J20_10 | |
INTEL_EDISON_MINIBOARD_J20_11 | |
INTEL_EDISON_MINIBOARD_J20_12 | |
INTEL_EDISON_MINIBOARD_J20_13 | |
INTEL_EDISON_MINIBOARD_J20_14 |
Enum | Description |
---|---|
INTEL_EDISON_GP182 | |
INTEL_EDISON_GP135 | |
INTEL_EDISON_GP27 | |
INTEL_EDISON_GP20 | |
INTEL_EDISON_GP28 | |
INTEL_EDISON_GP111 | |
INTEL_EDISON_GP109 | |
INTEL_EDISON_GP115 | |
INTEL_EDISON_GP128 | |
INTEL_EDISON_GP13 | |
INTEL_EDISON_GP165 | |
INTEL_EDISON_GP19 | |
INTEL_EDISON_GP12 | |
INTEL_EDISON_GP183 | |
INTEL_EDISON_GP110 | |
INTEL_EDISON_GP114 | |
INTEL_EDISON_GP129 | |
INTEL_EDISON_GP130 | |
INTEL_EDISON_GP44 | |
INTEL_EDISON_GP46 | |
INTEL_EDISON_GP48 | |
INTEL_EDISON_GP131 | |
INTEL_EDISON_GP14 | |
INTEL_EDISON_GP40 | |
INTEL_EDISON_GP43 | |
INTEL_EDISON_GP77 | |
INTEL_EDISON_GP82 | |
INTEL_EDISON_GP83 | |
INTEL_EDISON_GP134 | |
INTEL_EDISON_GP45 | |
INTEL_EDISON_GP47 | |
INTEL_EDISON_GP49 | |
INTEL_EDISON_GP15 | |
INTEL_EDISON_GP84 | |
INTEL_EDISON_GP42 | |
INTEL_EDISON_GP41 | |
INTEL_EDISON_GP78 | |
INTEL_EDISON_GP79 | |
INTEL_EDISON_GP80 | |
INTEL_EDISON_GP81 |
Enum | Description |
---|---|
RASPBERRY_WIRING_PIN8 | |
RASPBERRY_WIRING_PIN9 | |
RASPBERRY_WIRING_PIN7 | |
RASPBERRY_WIRING_PIN15 | |
RASPBERRY_WIRING_PIN16 | |
RASPBERRY_WIRING_PIN0 | |
RASPBERRY_WIRING_PIN1 | |
RASPBERRY_WIRING_PIN2 | |
RASPBERRY_WIRING_PIN3 | |
RASPBERRY_WIRING_PIN4 | |
RASPBERRY_WIRING_PIN5 | |
RASPBERRY_WIRING_PIN12 | |
RASPBERRY_WIRING_PIN13 | |
RASPBERRY_WIRING_PIN6 | |
RASPBERRY_WIRING_PIN14 | |
RASPBERRY_WIRING_PIN10 | |
RASPBERRY_WIRING_PIN11 | |
RASPBERRY_WIRING_PIN17 | |
RASPBERRY_WIRING_PIN21 | |
RASPBERRY_WIRING_PIN18 | |
RASPBERRY_WIRING_PIN19 | |
RASPBERRY_WIRING_PIN22 | |
RASPBERRY_WIRING_PIN20 | |
RASPBERRY_WIRING_PIN26 | |
RASPBERRY_WIRING_PIN23 | |
RASPBERRY_WIRING_PIN24 | |
RASPBERRY_WIRING_PIN27 | |
RASPBERRY_WIRING_PIN25 | |
RASPBERRY_WIRING_PIN28 | |
RASPBERRY_WIRING_PIN29 |
Enum | Description |
---|---|
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 | Description |
---|---|
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 | Description |
---|---|
I2C_STD | up to 100Khz |
I2C_FAST | up to 400Khz |
I2C_HIGH | up to 3.4Mhz |
Enum | Description |
---|---|
UART_PARITY_NONE | |
UART_PARITY_EVEN | |
UART_PARITY_ODD | |
UART_PARITY_MARK | |
UART_PARITY_SPACE |
Enum | Description |
---|---|
MODE_STRONG | Default. Strong High and Low |
MODE_PULLUP | Resistive High |
MODE_PULLDOWN | Resistive Low |
MODE_HIZ | High Z State |
Enum | Description |
---|---|
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 | Description |
---|---|
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 | Description |
---|---|
MODE_IN_ACTIVE_HIGH | Resistive High |
MODE_IN_ACTIVE_LOW | Resistive Low |
Enum | Description |
---|---|
MODE_OUT_OPEN_DRAIN | Open Drain Configuration |
MODE_OUT_PUSH_PULL | Push Pull Configuration |
Enum | Description |
---|---|
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 |