2014-05-21 12:52:38 +01:00
|
|
|
/*
|
|
|
|
|
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
|
|
|
|
* Copyright (c) 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
|
|
|
|
|
|
2014-07-10 22:08:05 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-09-25 14:28:08 +01:00
|
|
|
#include <syslog.h>
|
2015-10-28 11:04:18 +00:00
|
|
|
#include <fnmatch.h>
|
2014-09-25 14:28:08 +01:00
|
|
|
|
2014-06-11 14:17:34 +01:00
|
|
|
#include "common.h"
|
2014-06-27 15:37:48 +01:00
|
|
|
#include "mraa_internal_types.h"
|
2014-07-11 12:02:40 +01:00
|
|
|
#include "mraa_adv_func.h"
|
2016-02-26 13:50:07 -08:00
|
|
|
#include "mraa_lang_func.h"
|
2014-05-21 12:52:38 +01:00
|
|
|
|
2014-07-14 16:56:12 +01:00
|
|
|
extern mraa_board_t* plat;
|
2015-10-06 11:51:56 +01:00
|
|
|
extern mraa_iio_info_t* plat_iio;
|
2016-02-26 13:50:07 -08:00
|
|
|
extern mraa_lang_func_t* lang_func;
|
2014-07-10 22:19:00 +01:00
|
|
|
|
2014-10-30 18:09:27 +00:00
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
|
2014-11-21 00:01:08 +00:00
|
|
|
/**
|
2014-11-21 00:35:57 +00:00
|
|
|
* runtime detect running x86 platform
|
2014-11-21 00:01:08 +00:00
|
|
|
*
|
|
|
|
|
* @return mraa_platform_t of the init'ed platform
|
|
|
|
|
*/
|
|
|
|
|
mraa_platform_t mraa_x86_platform();
|
|
|
|
|
|
2014-11-21 00:35:57 +00:00
|
|
|
/**
|
|
|
|
|
* runtime detect running arm platforms
|
|
|
|
|
*
|
|
|
|
|
* @return mraa_platform_t of the init'ed platform
|
|
|
|
|
*/
|
|
|
|
|
mraa_platform_t mraa_arm_platform();
|
|
|
|
|
|
2016-06-26 17:55:14 +02:00
|
|
|
/**
|
|
|
|
|
* setup a mock platform
|
|
|
|
|
*
|
|
|
|
|
* @return mraa_platform_t of the init'ed platform
|
|
|
|
|
*/
|
|
|
|
|
mraa_platform_t mraa_mock_platform();
|
|
|
|
|
|
2015-05-27 15:36:46 -07:00
|
|
|
/**
|
|
|
|
|
* runtime detect running usb platform extender
|
|
|
|
|
*
|
|
|
|
|
* @return mraa_platform_t of the detected platform extender
|
|
|
|
|
*/
|
|
|
|
|
mraa_platform_t mraa_usb_platform_extender(mraa_board_t* board);
|
|
|
|
|
|
2015-12-02 14:38:41 -08:00
|
|
|
/**
|
|
|
|
|
* runtime detect iio subsystem
|
|
|
|
|
*
|
|
|
|
|
* @return mraa_result_t indicating success of iio detection
|
|
|
|
|
*/
|
|
|
|
|
mraa_result_t mraa_iio_detect();
|
|
|
|
|
|
2015-02-15 12:47:11 +01:00
|
|
|
/**
|
2015-04-04 18:50:23 +01:00
|
|
|
* helper function to check if file exists
|
|
|
|
|
*
|
|
|
|
|
* @param filename to check
|
|
|
|
|
* @return mraa_boolean_t boolean result.
|
|
|
|
|
*/
|
2015-04-04 18:41:13 +01:00
|
|
|
mraa_boolean_t mraa_file_exist(const char* filename);
|
2015-02-15 12:47:11 +01:00
|
|
|
|
|
|
|
|
/**
|
2015-04-04 18:50:23 +01:00
|
|
|
* helper function to unglob filenames
|
|
|
|
|
*
|
|
|
|
|
* @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
|
|
|
|
|
*/
|
2015-04-04 18:41:13 +01:00
|
|
|
char* mraa_file_unglob(const char* filename);
|
2015-02-15 12:47:11 +01:00
|
|
|
|
2015-04-04 18:52:35 +01:00
|
|
|
/**
|
|
|
|
|
* helper function to check if file contains a given text
|
|
|
|
|
*
|
|
|
|
|
* @param filename to check
|
|
|
|
|
* @param content to check in file
|
|
|
|
|
* @return mraa_boolean_t boolean result.
|
|
|
|
|
*/
|
|
|
|
|
mraa_boolean_t mraa_file_contains(const char* filename, const char* content);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* helper function to check if file contains a given text
|
|
|
|
|
*
|
|
|
|
|
* @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_boolean_t mraa_file_contains_both(const char* filename, const char* content, const char* content2);
|
|
|
|
|
|
2015-02-15 12:47:11 +01:00
|
|
|
/**
|
2015-04-04 18:50:23 +01:00
|
|
|
* helper function to find out if file that is targeted by a softlink
|
|
|
|
|
* (partially) matches the given name
|
|
|
|
|
*
|
|
|
|
|
* @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
|
|
|
|
|
*/
|
2015-04-04 18:41:13 +01:00
|
|
|
mraa_boolean_t mraa_link_targets(const char* filename, const char* targetname);
|
2015-02-15 12:47:11 +01:00
|
|
|
|
2015-07-10 17:52:50 +01:00
|
|
|
/**
|
|
|
|
|
* helper function to find the first i2c bus containing devname starting from
|
|
|
|
|
* i2c-n where n is startfrom
|
|
|
|
|
*
|
|
|
|
|
* @param device name to match
|
|
|
|
|
* @param i2c-dev number to start search from
|
|
|
|
|
* @return the matching i2c-dev bus id or -1
|
|
|
|
|
*/
|
|
|
|
|
int mraa_find_i2c_bus(const char* devname, int startfrom);
|
|
|
|
|
|
2016-03-15 17:32:18 -04:00
|
|
|
#if defined(IMRAA)
|
|
|
|
|
/**
|
|
|
|
|
* read Imraa subplatform lock file, caller is responsible to free return
|
|
|
|
|
* struct array
|
|
|
|
|
*
|
|
|
|
|
* @param imraa lockfile location
|
|
|
|
|
* @return the number of subplatforms added
|
|
|
|
|
*/
|
|
|
|
|
uint32_t mraa_add_from_lockfile(const char* imraa_lock_file);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Internal imraa init function
|
|
|
|
|
*
|
|
|
|
|
* @return mraa_result_t indicating success
|
|
|
|
|
*/
|
|
|
|
|
mraa_result_t imraa_init();
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-10 22:08:05 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|