mraa
2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
|
This file defines the basic shared values for libmraa
Go to the source code of this file.
Macros | |
#define | MRAA_PLATFORM_NAME_MAX_SIZE 64 |
#define | MRAA_PIN_NAME_SIZE 12 |
#define | MRAA_SUB_PLATFORM_BIT_SHIFT 9 |
#define | MRAA_SUB_PLATFORM_MASK (1<<MRAA_SUB_PLATFORM_BIT_SHIFT) |
#define | MRAA_MAIN_PLATFORM_OFFSET 0 |
#define | MRAA_SUB_PLATFORM_OFFSET 1 |
#define | MRAA_RETURN_FOR_ERROR(func) |
#define | DEPRECATED |
Typedefs | |
typedef unsigned int | mraa_boolean_t |
mraa_result_t mraa_init | ( | ) | const |
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.
void mraa_deinit | ( | ) |
De-Initilise MRAA
This is not a strict requirement but useful to test memory leaks and for people who like super clean code. If dynamically loading & unloading libmraa you need to call this before unloading the library.
mraa_boolean_t mraa_pin_mode_test | ( | int | pin, |
mraa_pinmodes_t | mode | ||
) |
Checks if a pin is able to use the passed in mode.
pin | Physical Pin to be checked. |
mode | the mode to be tested. |
unsigned int mraa_adc_raw_bits | ( | ) |
Check the board's bit size when reading the value
unsigned int mraa_get_platform_adc_raw_bits | ( | uint8_t | platform_offset | ) |
Check the specified board's bit size when reading the value
platform_offset | specified platform offset; 0 for main platform, 1 for sub platform |
unsigned int mraa_adc_supported_bits | ( | ) |
Return value that the raw value should be shifted to. Zero if no ADC
unsigned int mraa_get_platform_adc_supported_bits | ( | int | platform_offset | ) |
Return value that the raw value should be shifted to. Zero if no ADC
platform_offset | specified platform offset; 0 for main platform, 1 for sub platform |
mraa_result_t mraa_set_log_level | ( | 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.
const char* mraa_get_platform_name | ( | ) |
Return the Platform's Name, If no platform detected return NULL
const char* mraa_get_platform_version | ( | int | platform_offset | ) |
Return the platform's versioning info, the information given depends per platform and can be NULL. platform_offset has to be given. Do not modify this pointer
platform_offset | specified platform offset; 0 for main platform, 1 for sub platform |
int mraa_set_priority | ( | const 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.
priority | Value from typically 0 to 99 |
const char* mraa_get_version | ( | ) |
Get the version string of mraa autogenerated from git tag
The version returned may not be what is expected however it is a reliable number associated with the git tag closest to that version at build time
void mraa_result_print | ( | mraa_result_t | result | ) |
Print a textual representation of the mraa_result_t
result | the result to print |
mraa_platform_t mraa_get_platform_type | ( | ) |
Get platform type, board must be initialised.
int mraa_get_platform_combined_type | ( | ) |
Get combined platform type, board must be initialised. The combined type is represented as (sub_platform_type << 8) | main_platform_type
unsigned int mraa_get_pin_count | ( | ) |
Get platform pincount, board must be initialised.
int mraa_get_uart_count | ( | ) |
Get the number of usable UARTs, board must be initialised.
int mraa_get_spi_bus_count | ( | ) |
Get the number of usable SPI buses, board must be initialised.
int mraa_get_pwm_count | ( | ) |
Get the number of usable PWM pins, board must be initialised.
int mraa_get_gpio_count | ( | ) |
Get the number of usable GPIOs, board must be initialised.
int mraa_get_aio_count | ( | ) |
Get the number of usable analog pins, board must be initialised.
int mraa_get_i2c_bus_count | ( | ) |
Get platform usable I2C bus count, board must be initialised.
int mraa_get_i2c_bus_id | ( | int | i2c_bus | ) |
Get I2C adapter number in sysfs.
i2c_bus | the logical I2C bus number |
unsigned int mraa_get_platform_pin_count | ( | uint8_t | platform_offset | ) |
Get specified platform pincount, board must be initialised.
platform_offset | specified platform offset; 0 for main platform, 1 for sub platform |
char* mraa_get_pin_name | ( | int | pin | ) |
Get name of pin, board must be initialised.
pin | number |
int mraa_gpio_lookup | ( | const char * | pin_name | ) |
Get GPIO index by pin name, board must be initialised.
pin_name | GPIO pin name. Eg: IO0 |
int mraa_i2c_lookup | ( | const char * | i2c_name | ) |
Get I2C bus index by bus name, board must be initialised.
i2c_name | I2C bus name. Eg: I2C6 |
int mraa_spi_lookup | ( | const char * | spi_name | ) |
Get SPI bus index by bus name, board must be initialised.
spi_name | Name of SPI bus. Eg: SPI2 |
int mraa_pwm_lookup | ( | const char * | pwm_name | ) |
Get PWM index by PWM name, board must be initialised.
pwm_name | Name of PWM. Eg:PWM0 |
int mraa_uart_lookup | ( | const char * | uart_name | ) |
Get UART index by name, board must be initialised.
uart_name | Name of UART. Eg:UART1 |
int mraa_get_default_i2c_bus | ( | uint8_t | platform_offset | ) |
Get default i2c bus, board must be initialised.
mraa_boolean_t mraa_has_sub_platform | ( | ) |
Detect presence of sub platform.
mraa_boolean_t mraa_is_sub_platform_id | ( | int | pin_or_bus_id | ) |
Check if pin or bus id includes sub platform mask.
pin_or_bus_id | pin or bus number |
int mraa_get_sub_platform_id | ( | int | pin_or_bus_index | ) |
Convert pin or bus index to corresponding sub platform id.
pin_or_bus_index | pin or bus index |
int mraa_get_sub_platform_index | ( | int | pin_or_bus_id | ) |
Convert pin or bus sub platform id to index.
pin_or_bus_id | sub platform pin or bus id |
mraa_result_t mraa_add_subplatform | ( | mraa_platform_t | subplatformtype, |
const char * | dev | ||
) |
Add mraa subplatform
subplatformtype | subplatform type |
dev | uart device or i2c bus subplatform is on |
mraa_result_t mraa_remove_subplatform | ( | mraa_platform_t | subplatformtype | ) |
Remove a mraa subplatform
subplatformtype | subplatform type |
void* mraa_init_io | ( | const char * | desc | ) |
Create IO using a description in the format: [io]-[pin] [io]-[raw]-[pin] [io]-[raw]-[id]-[pin] [io]-[raw]-[path]
desc | IO description |
mraa_result_t mraa_init_json_platform | ( | const char * | path | ) |
Instantiate an unknown board using a json file
path | Path to the json file, relative to the folder the program was initially run in or a direct path |
#define MRAA_PLATFORM_NAME_MAX_SIZE 64 |
Max size off Mraa Platform name
#define MRAA_PIN_NAME_SIZE 12 |
Size off Mraa pin name
#define MRAA_SUB_PLATFORM_BIT_SHIFT 9 |
Bit Shift for Mraa sub platform
#define MRAA_SUB_PLATFORM_MASK (1<<MRAA_SUB_PLATFORM_BIT_SHIFT) |
Mask for Mraa sub platform
#define MRAA_MAIN_PLATFORM_OFFSET 0 |
Mraa main platform offset
#define MRAA_SUB_PLATFORM_OFFSET 1 |
Mraa sub platform offset
#define MRAA_RETURN_FOR_ERROR | ( | func | ) |
Executes function func and returns its result in case of error
#define DEPRECATED |
Simple deprecated macro
typedef unsigned int mraa_boolean_t |
MRAA boolean type 1 For TRUE