/* * Author: Brendan Le Foll * Author: Thomas Ingleby * Copyright © 2014 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #pragma once #include #include "types.h" #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< MAX. Function will return * -1 on failure. * * @param priority Value from typically 0 to 99 * @return The priority value set */ int mraa_set_priority(const unsigned int priority); /** 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 * * @return version string from version.h */ const char* mraa_get_version(); /** * Print a textual representation of the mraa_result_t * * @param result the result to print */ void mraa_result_print(mraa_result_t result); /** * Get platform type, board must be initialised. * * @return mraa_platform_t Platform type enum */ mraa_platform_t mraa_get_platform_type(); /** * Get combined platform type, board must be initialised. * The combined type is represented as * (sub_platform_type << 8) | main_platform_type * * @return int combined platform type */ int mraa_get_platform_combined_type(); /** * Get platform pincount, board must be initialised. * * @return uint of physical pin count on the in-use platform */ unsigned int mraa_get_pin_count(); /** * Get platform usable I2C bus count, board must be initialised. * * @return number f usable I2C bus count on the current platform. Function will * return -1 on failure */ int mraa_get_i2c_bus_count(); /** * Get I2C adapter number in sysfs. * * @param i2c_bus the logical I2C bus number * @return I2C adapter number in sysfs. Function will return -1 on failure */ int mraa_get_i2c_bus_id(unsigned int i2c_bus); /** * Get specified platform pincount, board must be initialised. * * @param specified platform offset; 0 for main platform, 1 foor sub platform * @return uint of physical pin count on the in-use platform */ unsigned int mraa_get_platform_pin_count(uint8_t platform_offset); /** * Get name of pin, board must be initialised. * * @param pin number * @return char* of pin name */ char* mraa_get_pin_name(int pin); /** * Get default i2c bus, board must be initialised. * * @return int default i2c bus index */ int mraa_get_default_i2c_bus(uint8_t platform_offset); /** * Detect presence of sub platform. * * @return mraa_boolean_t 1 if sub platform is present and initialized, 0 otherwise */ mraa_boolean_t mraa_has_sub_platform(); /** * Check if pin or bus id includes sub platform mask. * * @param int pin or bus number * * @return mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise */ mraa_boolean_t mraa_is_sub_platform_id(int pin_or_bus_id); /** * Convert pin or bus index to corresponding sub platform id. * * @param int pin or bus index * * @return int sub platform pin or bus number */ int mraa_get_sub_platform_id(int pin_or_bus_index); /** * Convert pin or bus sub platform id to index. * * @param int sub platform pin or bus id * * @return int pin or bus index */ int mraa_get_sub_platform_index(int pin_or_bus_id); #ifdef __cplusplus } #endif