Private
Public Access
2
0
Files
mraa/api/mraa/common.h
Thomas Ingleby 52c53760b2 api: introduce define for pin name size
MRAA_PIN_NAME_SIZE currently set at 12.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2015-03-23 17:25:27 +00:00

167 lines
4.8 KiB
C

/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
* 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 "types.h"
#define MRAA_PLATFORM_NAME_MAX_SIZE 64
#define MRAA_PIN_NAME_SIZE 12
/** @file
*
* This file defines the basic shared values for libmraa
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* MRAA boolean type
* 1 For TRUE
*/
typedef unsigned int mraa_boolean_t;
/**
* Initialise MRAA
*
* Detects running platform and attempts to use included pinmap, this is run on
* module/library init/load but is handy to rerun to check board initialised
* correctly. MRAA_SUCCESS inidicates correct (first time) initialisation
* whilst MRAA_ERROR_PLATFORM_ALREADY_INITIALISED indicates the board is
* already initialised correctly
*
* @return Result of operation
*/
#if (defined SWIGPYTHON) || (defined SWIG)
mraa_result_t mraa_init();
#else
// this sets a compiler attribute (supported by GCC & clang) to have mraa_init()
// be called as a constructor make sure your libc supports this! uclibc needs
// to be compiled with UCLIBC_CTOR_DTOR
mraa_result_t mraa_init() __attribute__((constructor));
#endif
/**
* De-Initilise MRAA
*
* This is not a strict requirement but useful to test memory leaks and for
* people who like super clean code. If dynamically loading & unloading
* libmraa you need to call this before unloading the library.
*/
void mraa_deinit();
/**
* Checks if a pin is able to use the passed in mode.
*
* @param pin Physical Pin to be checked.
* @param mode the mode to be tested.
* @return boolean if the mode is supported, 0=false.
*/
mraa_boolean_t mraa_pin_mode_test(int pin, mraa_pinmodes_t mode);
/**
* Check the board's bit size when reading the value
*
* @return raw bits being read from kernel module. zero if no ADC
*/
unsigned int mraa_adc_raw_bits();
/**
* Return value that the raw value should be shifted to. Zero if no ADC
*
* @return return actual bit size the adc value should be understood as.
*/
unsigned int mraa_adc_supported_bits();
/**
* Sets the log level to use from 0-7 where 7 is very verbose. These are the
* syslog log levels, see syslog(3) for more information on the levels.
*
* @return Result of operation
*/
mraa_result_t mraa_set_log_level(int level);
/**
* Return the Platform's Name, If no platform detected return NULL
*
* @return platform name
*/
char* mraa_get_platform_name();
/**
* This function attempts to set the mraa process to a given priority and the
* scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
* This function * will set to MAX if * priority is > 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 platform pincount, board must be initialised.
*
* @return uint of physical pin count on the in-use platform
*/
unsigned int mraa_get_pin_count();
/**
* Get name of pin, board must be initialised.
*
* @param pin number
*
* @return char* of pin name
*/
char* mraa_get_pin_name(int pin);
#ifdef __cplusplus
}
#endif