2 * Author: Brendan Le Foll <brendan.le.foll@intel.com>
3 * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
4 * Copyright © 2014 Intel Corporation
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29 #define MRAA_PLATFORM_NAME_MAX_SIZE 64
33 * This file defines the basic shared values for libmraa
44 typedef unsigned int mraa_boolean_t;
49 * Detects running platform and attempts to use included pinmap, this is run on
50 * module/library init/load but is handy to rerun to check board initialised
51 * correctly. Anything but MRAA_SUCCESS should be considered a critical failure
53 * @return Result of operation
55 #if (defined SWIGPYTHON) || (defined SWIG)
56 mraa_result_t mraa_init();
58 // this sets a compiler attribute (supported by GCC & clang) to have mraa_init()
59 // be called as a constructor make sure your libc supports this! uclibc needs
60 // to be compiled with UCLIBC_CTOR_DTOR
61 mraa_result_t mraa_init() __attribute__((constructor));
67 * This is not a strict requirement but useful to test memory leaks and for
68 * people who like super clean code. If dynamically loading & unloading
69 * libmraa you need to call this before unloading the library.
74 * Checks if a pin is able to use the passed in mode.
76 * @param pin Physical Pin to be checked.
77 * @param mode the mode to be tested.
78 * @return boolean if the mode is supported, 0=false.
80 mraa_boolean_t mraa_pin_mode_test(int pin, mraa_pinmodes_t mode);
83 * Check the board's bit size when reading the value
85 * @return raw bits being read from kernel module. zero if no ADC
87 unsigned int mraa_adc_raw_bits();
90 * Return value that the raw value should be shifted to. Zero if no ADC
92 * @return return actual bit size the adc value should be understood as.
94 unsigned int mraa_adc_supported_bits();
97 * Sets the log level to use from 0-7 where 7 is very verbose. These are the
98 * syslog log levels, see syslog(3) for more information on the levels.
100 * @return Result of operation
102 mraa_result_t mraa_set_log_level(int level);
105 * Return the Platform's Name, If no platform detected return NULL
107 * @return platform name
109 char* mraa_get_platform_name();
112 * This function attempts to set the mraa process to a given priority and the
113 * scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
114 * This function * will set to MAX if * priority is > MAX. Function will return
117 * @param priority Value from typically 0 to 99
118 * @return The priority value set
120 int mraa_set_priority(const unsigned int priority);
122 /** Get the version string of mraa autogenerated from git tag
124 * The version returned may not be what is expected however it is a reliable
125 * number associated with the git tag closest to that version at build time
127 * @return version string from version.h
129 const char* mraa_get_version();
132 * Print a textual representation of the mraa_result_t
134 * @param result the result to print
136 void mraa_result_print(mraa_result_t result);
139 * Get platform type, board must be initialised.
141 * @return mraa_platform_t Platform type enum
143 mraa_platform_t mraa_get_platform_type();
146 * Get platform pincount, board must be initialised.
148 * @return uint of physical pin count on the in-use platform
150 unsigned int mraa_get_pin_count();