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
51 * @return Result of operation
53 #if (defined SWIGPYTHON) || (defined SWIG)
54 mraa_result_t mraa_init();
56 // this sets a compiler attribute (supported by GCC & clang) to have mraa_init()
57 // be called as a constructor make sure your libc supports this! uclibc needs
58 // to be compiled with UCLIBC_CTOR_DTOR
59 mraa_result_t mraa_init() __attribute__((constructor));
65 * This is not a strict requirement but useful to test memory leaks and for
66 * people who like super clean code. If dynamically loading & unloading
67 * libmraa you need to call this before unloading the library.
72 * Checks if a pin is able to use the passed in mode.
74 * @param pin Physical Pin to be checked.
75 * @param mode the mode to be tested.
76 * @return boolean if the mode is supported, 0=false.
78 mraa_boolean_t mraa_pin_mode_test(int pin, mraa_pinmodes_t mode);
81 * Check the board's bit size when reading the value
83 * @return raw bits being read from kernel module. zero if no ADC
85 unsigned int mraa_adc_raw_bits();
88 * Return value that the raw value should be shifted to. Zero if no ADC
90 * @return return actual bit size the adc value should be understood as.
92 unsigned int mraa_adc_supported_bits();
95 * Sets the log level to use from 0-7 where 7 is very verbose. These are the
96 * syslog log levels, see syslog(3) for more information on the levels.
98 * @return Result of operation
100 mraa_result_t mraa_set_log_level(int level);
103 * Return the Platform's Name, If no platform detected return NULL
105 * @return platform name
107 char* mraa_get_platform_name();
110 * This function attempts to set the mraa process to a given priority and the
111 * scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
112 * This function * will set to MAX if * priority is > MAX. Function will return
115 * @param priority Value from typically 0 to 99
116 * @return The priority value set
118 int mraa_set_priority(const unsigned int priority);
120 /** Get the version string of mraa autogenerated from git tag
122 * The version returned may not be what is expected however it is a reliable
123 * number associated with the git tag closest to that version at build time
125 * @return version string from version.h
127 const char* mraa_get_version();
130 * Print a textual representation of the mraa_result_t
132 * @param result the result to print
134 void mraa_result_print(mraa_result_t result);
137 * Get platform type, board must be initialised.
139 * @return mraa_platform_t Platform type enum
141 mraa_platform_t mraa_get_platform_type();
144 * Get platform pincount, board must be initialised.
146 * @return uint of physical pin count on the in-use platform
148 unsigned int mraa_get_pin_count();