X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fmraa_internal.h;h=428876da55b1ddd433cf7f9be7b09764bf9aaec5;hb=HEAD;hp=4d71aa19d5da840ef81d42728d3edecb102368f5;hpb=fb030b5e9f39551697d67f64ca0df52a5bd161e8;p=contrib%2Fmraa.git diff --git a/include/mraa_internal.h b/include/mraa_internal.h index 4d71aa1..428876d 100644 --- a/include/mraa_internal.h +++ b/include/mraa_internal.h @@ -28,69 +28,107 @@ extern "C" { #endif +#include +#include + #include "common.h" #include "mraa_internal_types.h" #include "mraa_adv_func.h" -extern mraa_adv_func_t* advance_func; +extern mraa_board_t* plat; +extern mraa_iio_info_t* plat_iio; + +/** + * Takes in pin information and sets up the multiplexors. + * + * @param meta + * @return mraa result type indicating success of actions. + */ +mraa_result_t mraa_setup_mux_mapped(mraa_pin_t meta); + +/** + * runtime detect running x86 platform + * + * @return mraa_platform_t of the init'ed platform + */ +mraa_platform_t mraa_x86_platform(); + +/** + * runtime detect running arm platforms + * + * @return mraa_platform_t of the init'ed platform + */ +mraa_platform_t mraa_arm_platform(); -/** Setup gpio +/** + * runtime detect running usb platform extender * - * Will check input is valid for gpio and will also setup required multiplexers. - * @param pin the pin as read from the board surface. i.e IO3 would be 3/ - * @return the pin as found in the pinmap + * @return mraa_platform_t of the detected platform extender */ -unsigned int mraa_setup_gpio(int pin); +mraa_platform_t mraa_usb_platform_extender(mraa_board_t* board); -/** Setup Analog interface +/** + * runtime detect iio subsystem * - * Will check input is valid for aio and will also setup required multiplexers. - * @param pin the pin as read from the board surface. i.e A3 would be 3/ - * @return the pin as found in the pinmap + * @return mraa_result_t indicating success of iio detection */ -unsigned int mraa_setup_aio(int pin); +mraa_result_t mraa_iio_detect(); -/** Setup i2c interface, sets up multiplexer on device. +/** + * helper function to check if file exists * - * @return unsigned int if using /dev/i2c-2 returned would be 2 + * @param filename to check + * @return mraa_boolean_t boolean result. */ -unsigned int mraa_setup_i2c(int bus); +mraa_boolean_t mraa_file_exist(const char* filename); -/** Setup spi interface, sets up multiplexer on device. +/** + * helper function to unglob filenames * - * @return spi bus type + * @param filename to unglob + * @return char * with the existing filename matching the pattern of input. NULL if there is no + *match. Caller must free result */ -mraa_spi_bus_t* mraa_setup_spi(int bus); +char* mraa_file_unglob(const char* filename); -/** Setup PWM +/** + * helper function to check if file contains a given text * - * Will check input is valid for pwm and will also setup required multiplexers. - * IF the pin also does gpio (strong chance), DO NOTHING, REV D quirk - * @param pin the pin as read from the board surface. - * @return the pwm pin_info_t of that IO pin + * @param filename to check + * @param content to check in file + * @return mraa_boolean_t boolean result. */ -mraa_pin_t* mraa_setup_pwm(int pin); +mraa_boolean_t mraa_file_contains(const char* filename, const char* content); -/** Setup gpio mux to go straight to SoC, galileo. +/** + * helper function to check if file contains a given text * - * @param pin physical pin to use - * @return mraa_mmap_pin_t + * @param filename to check + * @param content to check in file + * @param content2 to check in same line of file + * @return mraa_boolean_t boolean result. */ -mraa_mmap_pin_t* mraa_setup_mmap_gpio(int pin); +mraa_boolean_t mraa_file_contains_both(const char* filename, const char* content, const char* content2); -/** Swap Directional mode. +/** + * helper function to find out if file that is targeted by a softlink + * (partially) matches the given name * - * @param pin physical pin to operate on - * @return out direction to setup. 1 for output 0 for input + * @param filename of the softlink + * @param (partial) filename that is matched with the filename of the link-targeted file + * @return mraa_boolean_t true when targetname (partially) matches */ -mraa_result_t mraa_swap_complex_gpio(int pin, int out); +mraa_boolean_t mraa_link_targets(const char* filename, const char* targetname); -/** Setup uart muxes to exposes the pins physically. +/** + * helper function to find the first i2c bus containing devname starting from + * i2c-n where n is startfrom * - * @param index of the uart in the board definition to expose physically - * @return mraa_result_t of operation + * @param device name to match + * @param i2c-dev number to start search from + * @return the matching i2c-dev bus id or -1 */ -mraa_result_t mraa_setup_uart(int index); +int mraa_find_i2c_bus(const char* devname, int startfrom); #ifdef __cplusplus }