mraa: rename from maa to mraa
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
82
api/mraa/aio.h
Normal file
82
api/mraa/aio.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Author: Nandkishor Sonar
|
||||
* 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
|
||||
/**
|
||||
* @file
|
||||
* @brief Analog input/output
|
||||
*
|
||||
* AIO is the anlog input & output interface to libmraa. It is used to read or
|
||||
* set the voltage applied to an AIO pin.
|
||||
*
|
||||
* @snippet analogin_a0.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define ADC_RAW_RESOLUTION_BITS (12)
|
||||
#define ADC_SUPPORTED_RESOLUTION_BITS (10)
|
||||
|
||||
/**
|
||||
* Opaque pointer definition to the internal struct _aio. This context refers
|
||||
* to one single AIO pin on the board.
|
||||
*/
|
||||
typedef struct _aio* mraa_aio_context;
|
||||
|
||||
/**
|
||||
* Initialise an Analog input device, connected to the specified pin
|
||||
*
|
||||
* @param pin Channel number to read ADC inputs
|
||||
* @returns aio context or NULL
|
||||
*/
|
||||
mraa_aio_context mraa_aio_init(unsigned int pin);
|
||||
|
||||
/**
|
||||
* Read the input voltage
|
||||
*
|
||||
* @param dev The AIO context
|
||||
* @returns The current input voltage, normalised to a 16-bit value
|
||||
*/
|
||||
uint16_t mraa_aio_read(mraa_aio_context dev);
|
||||
|
||||
/**
|
||||
* Close the analog input context, this will free the memory for the context
|
||||
*
|
||||
* @param dev The AIO context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_aio_close(mraa_aio_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
69
api/mraa/aio.hpp
Normal file
69
api/mraa/aio.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@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
|
||||
|
||||
#include "aio.h"
|
||||
|
||||
namespace mraa {
|
||||
|
||||
/**
|
||||
* @brief C++ API to Analog IO
|
||||
*
|
||||
* This file defines the aio C++ interface for libmraa
|
||||
*
|
||||
* @snippet examples/c++/AioA0.cpp Interesting
|
||||
*/
|
||||
class Aio {
|
||||
public:
|
||||
/**
|
||||
* Aio Constructor, takes a pin number which will map directly to the
|
||||
* board number
|
||||
*
|
||||
* @param pin channel number to read ADC inputs
|
||||
*/
|
||||
Aio(unsigned int pin) {
|
||||
m_aio = mraa_aio_init(pin);
|
||||
}
|
||||
/**
|
||||
* Aio destructor
|
||||
*/
|
||||
~Aio() {
|
||||
mraa_aio_close(m_aio);
|
||||
}
|
||||
/**
|
||||
* Read a value from the AIO pin. Note this value can never be outside
|
||||
* of the bounds of an unsigned short
|
||||
*
|
||||
* @returns The current input voltage, normalised to a 16-bit value
|
||||
*/
|
||||
int read() {
|
||||
// Use basic types to make swig code generation simpler
|
||||
return (int) mraa_aio_read(m_aio);
|
||||
}
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
};
|
||||
|
||||
}
|
||||
198
api/mraa/common.h
Normal file
198
api/mraa/common.h
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
/** @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;
|
||||
|
||||
/**
|
||||
* Enum representing different possible modes for a pin.
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_PIN_VALID = 0, /**< Pin Valid */
|
||||
MRAA_PIN_GPIO = 1, /**< General Purpose IO */
|
||||
MRAA_PIN_PWM = 2, /**< Pulse Width Modulation */
|
||||
MRAA_PIN_FAST_GPIO = 3, /**< Faster GPIO */
|
||||
MRAA_PIN_SPI = 4, /**< SPI */
|
||||
MRAA_PIN_I2C = 5, /**< I2C */
|
||||
MRAA_PIN_AIO = 6 /**< Analog in */
|
||||
} mraa_pinmodes_t;
|
||||
|
||||
/**
|
||||
* A bitfield representing the capabilities of a pin.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
mraa_boolean_t valid:1; /**< Is the pin valid at all */
|
||||
mraa_boolean_t gpio:1; /**< Is the pin gpio capable */
|
||||
mraa_boolean_t pwm:1; /**< Is the pin pwm capable */
|
||||
mraa_boolean_t fast_gpio:1; /**< Is the pin fast gpio capable */
|
||||
mraa_boolean_t spi:1; /**< Is the pin spi capable */
|
||||
mraa_boolean_t i2c:1; /**< Is the pin i2c capable */
|
||||
mraa_boolean_t aio:1; /**< Is the pin analog input capable */
|
||||
/*@}*/
|
||||
} mraa_pincapabilities_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a multiplexer and the required value
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int pin; /**< Raw GPIO pin id */
|
||||
unsigned int value; /**< Raw GPIO value */
|
||||
/*@}*/
|
||||
} mraa_mux_t;
|
||||
|
||||
typedef struct {
|
||||
mraa_boolean_t complex_pin:1;
|
||||
mraa_boolean_t output_en:1;
|
||||
mraa_boolean_t output_en_high:1;
|
||||
mraa_boolean_t pullup_en:1;
|
||||
mraa_boolean_t pullup_en_hiz:1;
|
||||
} mraa_pin_cap_complex_t;
|
||||
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int pinmap; /**< sysfs pin */
|
||||
unsigned int parent_id; /** parent chip id */
|
||||
unsigned int mux_total; /** Numfer of muxes needed for operation of pin */
|
||||
mraa_mux_t mux[6]; /** Array holding information about mux */
|
||||
unsigned int output_enable; /** Output Enable GPIO, for level shifting */
|
||||
unsigned int pullup_enable; /** Pull-Up enable GPIO, inputs */
|
||||
mraa_pin_cap_complex_t complex_cap;
|
||||
/*@}*/
|
||||
} mraa_pin_t;
|
||||
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
char mem_dev[32]; /**< Memory device to use /dev/uio0 etc */
|
||||
unsigned int mem_sz; /** Size of memory to map */
|
||||
unsigned int bit_pos; /** Position of value bit */
|
||||
mraa_pin_t gpio; /** GPio context containing none mmap info */
|
||||
/*@}*/
|
||||
} mraa_mmap_pin_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a physical Pin.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
char name[8]; /**< Pin's real world name */
|
||||
mraa_pincapabilities_t capabilites; /**< Pin Capabiliites */
|
||||
mraa_pin_t gpio; /**< GPIO structure */
|
||||
mraa_pin_t pwm; /**< PWM structure */
|
||||
mraa_pin_t aio; /**< Anaglog Pin */
|
||||
mraa_mmap_pin_t mmap; /**< GPIO through memory */
|
||||
mraa_pin_t i2c; /**< i2c bus/pin */
|
||||
mraa_pin_t spi; /**< spi bus/pin */
|
||||
/*@}*/
|
||||
} mraa_pininfo_t;
|
||||
|
||||
/**
|
||||
* A Structure representing the physical properties of a i2c bus.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int bus_id; /**< ID as exposed in the system */
|
||||
unsigned int scl; /**< i2c SCL */
|
||||
unsigned int sda; /**< i2c SDA */
|
||||
/*@}*/
|
||||
} mraa_i2c_bus_t;
|
||||
|
||||
/**
|
||||
* A Structure representing the physical properties of a spi bus.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int bus_id; /**< The Bus ID as exposed to the system. */
|
||||
unsigned int slave_s; /**< Slave select */
|
||||
mraa_boolean_t three_wire; /**< Is the bus only a three wire system */
|
||||
unsigned int sclk; /**< Serial Clock */
|
||||
unsigned int mosi; /**< Master Out, Slave In. */
|
||||
unsigned int miso; /**< Master In, Slave Out. */
|
||||
unsigned int cs; /**< Chip Select, used when the board is a spi slave */
|
||||
/*@}*/
|
||||
} mraa_spi_bus_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a platform/board.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int phy_pin_count; /**< The Total IO pins on board */
|
||||
unsigned int gpio_count; /**< GPIO Count */
|
||||
unsigned int aio_count; /**< Analog side Count */
|
||||
unsigned int i2c_bus_count; /**< Usable i2c Count */
|
||||
mraa_i2c_bus_t i2c_bus[6]; /**< Array of i2c */
|
||||
unsigned int def_i2c_bus; /**< Position in array of default i2c bus */
|
||||
unsigned int spi_bus_count; /**< Usable spi Count */
|
||||
mraa_spi_bus_t spi_bus[6]; /**< Array of spi */
|
||||
unsigned int def_spi_bus; /**< Position in array of defult spi bus */
|
||||
mraa_pininfo_t* pins; /**< Pointer to pin array */
|
||||
/*@}*/
|
||||
} mraa_board_t;
|
||||
|
||||
/**
|
||||
* Initialise MRAA
|
||||
*
|
||||
* Detects running platform and attempts to use included pinmap
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
#ifndef SWIG
|
||||
// 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));
|
||||
#else
|
||||
mraa_result_t mraa_init();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
196
api/mraa/gpio.h
Normal file
196
api/mraa/gpio.h
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief General Purpose IO
|
||||
*
|
||||
* Gpio is the General Purpose IO interface to libmraa. It's features depends on
|
||||
* the board type used, it can use gpiolibs (exported via a kernel module
|
||||
* through sysfs), or memory mapped IO via a /dev/uio device or /dev/mem
|
||||
* depending again on the board configuratio, or memory mapped IO via a
|
||||
* /dev/uio device or /dev/mem depending again on the board configuration
|
||||
*
|
||||
* @snippet gpio_read6.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
#include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* Opaque pointer definition to the internal struct _gpio
|
||||
*/
|
||||
typedef struct _gpio* mraa_gpio_context;
|
||||
|
||||
/**
|
||||
* Gpio Output modes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
|
||||
MRAA_GPIO_PULLUP = 1, /**< Resistive High */
|
||||
MRAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
|
||||
MRAA_GPIO_HIZ = 3 /**< High Z State */
|
||||
} gpio_mode_t;
|
||||
|
||||
/**
|
||||
* Gpio Direction options
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
|
||||
MRAA_GPIO_IN = 1 /**< Input */
|
||||
} gpio_dir_t;
|
||||
|
||||
/**
|
||||
* Gpio Edge types for interupts
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_EDGE_NONE = 0, /**< No interrupt on Gpio */
|
||||
MRAA_GPIO_EDGE_BOTH = 1, /**< Interupt on rising & falling */
|
||||
MRAA_GPIO_EDGE_RISING = 2, /**< Interupt on rising only */
|
||||
MRAA_GPIO_EDGE_FALLING = 3 /**< Interupt on falling only */
|
||||
} gpio_edge_t;
|
||||
|
||||
/**
|
||||
* Initialise gpio_context, based on board number
|
||||
*
|
||||
* @param pin Pin number read from the board, i.e IO3 is 3
|
||||
* @returns gpio context or NULL
|
||||
*/
|
||||
mraa_gpio_context mraa_gpio_init(int pin);
|
||||
|
||||
/**
|
||||
* Initialise gpio context without any mapping to a pin
|
||||
*
|
||||
* @param gpiopin gpio pin as listed in SYSFS
|
||||
* @return gpio context or NULL
|
||||
*/
|
||||
mraa_gpio_context mraa_gpio_init_raw(int gpiopin);
|
||||
|
||||
/**
|
||||
* Set the edge mode on the gpio
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param mode The edge mode to set the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode);
|
||||
|
||||
/**
|
||||
* Set an interupt on pin
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param edge The edge mode to set the gpio into
|
||||
* @param fptr Function pointer to function to be called when interupt is
|
||||
* triggered
|
||||
* @param args Arguments passed to the interrupt handler (fptr)
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, gpio_edge_t edge, void (*fptr)(void *), void * args);
|
||||
|
||||
/**
|
||||
* Stop the current interupt watcher on this Gpio, and set the Gpio edge mode
|
||||
* to MRAA_GPIO_EDGE_NONE
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev);
|
||||
|
||||
/**
|
||||
* Set Gpio Output Mode,
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param mode The Gpio Output Mode
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode);
|
||||
|
||||
/**
|
||||
* Set Gpio direction
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param dir The direction of the Gpio
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir);
|
||||
|
||||
/**
|
||||
* Close the Gpio context
|
||||
* - Will free the memory for the context and unexport the Gpio
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
|
||||
|
||||
/**
|
||||
* Read the Gpio value.
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @return Result of operation
|
||||
*/
|
||||
int mraa_gpio_read(mraa_gpio_context dev);
|
||||
|
||||
/**
|
||||
* Write to the Gpio Value.
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param value Integer value to write
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value);
|
||||
|
||||
/**
|
||||
* Change ownership of the context.
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param owner Does this context own the pin
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner);
|
||||
|
||||
/**
|
||||
* Enable using memory mapped io instead of sysfs
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param mmap Use mmap instead of sysfs
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
172
api/mraa/gpio.hpp
Normal file
172
api/mraa/gpio.hpp
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@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
|
||||
|
||||
#include "gpio.h"
|
||||
|
||||
namespace mraa {
|
||||
|
||||
// These enums must match the enums in gpio.h
|
||||
|
||||
/**
|
||||
* Gpio Output modes
|
||||
*/
|
||||
typedef enum {
|
||||
MODE_STRONG = 0, /**< No interrupt on Gpio */
|
||||
MODE_PULLUP = 1, /**< Interupt on rising & falling */
|
||||
MODE_PULLDOWN = 2, /**< Interupt on rising only */
|
||||
MODE_HIZ = 3 /**< Interupt on falling only */
|
||||
} Mode;
|
||||
|
||||
/**
|
||||
* Gpio Direction options
|
||||
*/
|
||||
typedef enum {
|
||||
DIR_OUT = 0, /**< Output. A Mode can also be set */
|
||||
DIR_IN = 1 /**< Input */
|
||||
} Dir;
|
||||
|
||||
/**
|
||||
* Gpio Edge types for interupts
|
||||
*/
|
||||
typedef enum {
|
||||
EDGE_NONE = 0, /**< No interrupt on Gpio */
|
||||
EDGE_BOTH = 1, /**< Interupt on rising & falling */
|
||||
EDGE_RISING = 2, /**< Interupt on rising only */
|
||||
EDGE_FALLING = 3 /**< Interupt on falling only */
|
||||
} Edge;
|
||||
|
||||
/**
|
||||
* @brief C++ API to General Purpose IO
|
||||
*
|
||||
* This file defines the gpio C++ interface for libmraa
|
||||
*
|
||||
* @snippet Blink-IO.cpp Interesting
|
||||
*/
|
||||
class Gpio {
|
||||
public:
|
||||
/**
|
||||
* Instanciates a Gpio object
|
||||
*
|
||||
* @param pin pin number to use
|
||||
* @param owner (optional) Set pin owner, default behaviour is to 'own'
|
||||
* the pin if we exported it. This means we will close it on destruct.
|
||||
* Otherwise it will get left open. This is only valid in sysfs use
|
||||
* cases
|
||||
* @param raw (optional) Raw pins will use gpiolibs pin numbering from
|
||||
* the kernel module. Note that you will not get any muxers set up for
|
||||
* you so this may not always work as expected.
|
||||
*/
|
||||
Gpio(int pin, bool owner=true, bool raw=false) {
|
||||
if (raw)
|
||||
m_gpio = mraa_gpio_init_raw(pin);
|
||||
else
|
||||
m_gpio = mraa_gpio_init(pin);
|
||||
if (!owner)
|
||||
mraa_gpio_owner(m_gpio, 0);
|
||||
}
|
||||
/**
|
||||
* Gpio object destructor, this will only unexport the gpio if we where
|
||||
* the owner
|
||||
*/
|
||||
~Gpio() {
|
||||
mraa_gpio_close(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Set the edge mode for ISR
|
||||
*
|
||||
* @param mode The edge mode to set
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t edge(Edge mode) {
|
||||
return mraa_gpio_edge_mode(m_gpio, (gpio_edge_t) mode);
|
||||
}
|
||||
#if defined(SWIGPYTHON)
|
||||
mraa_result_t isr(Edge mode, PyObject *pyfunc, PyObject* args) {
|
||||
return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, (void (*) (void *)) pyfunc, (void *) args);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* Sets a callback to be called when pin value changes
|
||||
*
|
||||
* @param mode The edge mode to set
|
||||
* @param fptr Function pointer to function to be called when interupt is
|
||||
* triggered
|
||||
* @param args Arguments passed to the interrupt handler (fptr)
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t isr(Edge mode, void (*fptr)(void *), void * args) {
|
||||
return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, fptr, args);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Exits callback - this call will not kill the isr thread imediatlu
|
||||
* but only when it is out of it's critical section
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t isrExit() {
|
||||
return mraa_gpio_isr_exit(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Change Gpio mode
|
||||
*
|
||||
* @param mode The mode to change the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mode(Mode mode) {
|
||||
return mraa_gpio_mode(m_gpio, (gpio_mode_t) mode);
|
||||
}
|
||||
/**
|
||||
* Change Gpio direction
|
||||
*
|
||||
* @param dir The direction to change the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t dir(Dir dir) {
|
||||
return mraa_gpio_dir(m_gpio, (gpio_dir_t) dir);
|
||||
}
|
||||
/**
|
||||
* Read value from Gpio
|
||||
*
|
||||
* @return Gpio value
|
||||
*/
|
||||
int read() {
|
||||
return mraa_gpio_read(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Write value to Gpio
|
||||
*
|
||||
* @param value Value to write to Gpio
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(int value) {
|
||||
return mraa_gpio_write(m_gpio, value);
|
||||
}
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
};
|
||||
|
||||
}
|
||||
140
api/mraa/i2c.h
Normal file
140
api/mraa/i2c.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@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
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Inter-Integrated Circuit
|
||||
*
|
||||
* This file defines the i2c/Iic interface for libmraa. A context represents a
|
||||
* bus and that bus may contain multiple addresses or i2c slaves. It is
|
||||
* considered best practice to make sure the address is correct before doing
|
||||
* any calls on i2c, in case another application or even thread changed the
|
||||
* addres on that bus. Multiple instances of the same bus can exist.
|
||||
*
|
||||
* @snippet i2c_HMC5883L.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "gpio.h"
|
||||
|
||||
/**
|
||||
* Opaque pointer definition to the internal struct _i2c
|
||||
*/
|
||||
typedef struct _i2c* mraa_i2c_context;
|
||||
|
||||
/**
|
||||
* Initialise i2c context, using board defintions
|
||||
*
|
||||
* @param bus i2c bus to use
|
||||
* @return i2c context or NULL
|
||||
*/
|
||||
mraa_i2c_context mraa_i2c_init(int bus);
|
||||
|
||||
/**
|
||||
* Initialise i2c context, passing in spi bus to use.
|
||||
*
|
||||
* @param bus The i2c bus to use i.e. /dev/i2c-2 would be "2"
|
||||
* @return i2c context or NULL
|
||||
*/
|
||||
mraa_i2c_context mraa_i2c_init_raw(unsigned int bus);
|
||||
|
||||
/**
|
||||
* Sets the frequency of the i2c context
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param hz The bus frequency in hertz
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, int hz);
|
||||
|
||||
/**
|
||||
* Read from an i2c context
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param data pointer to the byte array to read data in to
|
||||
* @param length max number of bytes to read
|
||||
* @return length of the read in bytes or 0
|
||||
*/
|
||||
int mraa_i2c_read(mraa_i2c_context dev, uint8_t *data, int length);
|
||||
|
||||
/**
|
||||
* Read a single byte from the i2c context
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @return The result of the read or -1 if failed
|
||||
*/
|
||||
uint8_t mraa_i2c_read_byte(mraa_i2c_context dev);
|
||||
|
||||
/**
|
||||
* Write to an i2c context
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param data pointer to the byte array to be written
|
||||
* @param length the number of bytes to transmit
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t *data, int length);
|
||||
|
||||
/**
|
||||
* Write a single byte to an i2c context
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param data The byte to write
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data);
|
||||
|
||||
/**
|
||||
* Sets the i2c context address.
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param address The address to set for the slave (ignoring the least
|
||||
* signifcant bit). If set to 0, the slave will only respond to the
|
||||
* general call address.
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_address(mraa_i2c_context dev, int address);
|
||||
|
||||
/**
|
||||
* De-inits an mraa_i2c_context device
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_stop(mraa_i2c_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
137
api/mraa/i2c.hpp
Normal file
137
api/mraa/i2c.hpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@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
|
||||
|
||||
#include "i2c.h"
|
||||
|
||||
namespace mraa {
|
||||
|
||||
/**
|
||||
* @brief C++ API to Inter-Integrated Circuit
|
||||
*
|
||||
* This file defines the I2c C++ interface for libmraa
|
||||
*
|
||||
* @snippet I2c-compass.cpp Interesting
|
||||
*/
|
||||
class I2c {
|
||||
public:
|
||||
/**
|
||||
* Instantiates an i2c bus. Multiple instances of the same bus can
|
||||
* exist and the bus is not guarranteed to be on the correct address
|
||||
* before read/write.
|
||||
*
|
||||
* @param bus The i2c bus to use
|
||||
* @param raw Whether to disable pinmapper for your board
|
||||
*/
|
||||
I2c(int bus, bool raw=false) {
|
||||
if (raw)
|
||||
m_i2c = mraa_i2c_init_raw(bus);
|
||||
else
|
||||
m_i2c = mraa_i2c_init(bus);
|
||||
}
|
||||
/**
|
||||
* Closes the I2c Bus used. This does not guarrantee the bus will not
|
||||
* be usable by anyone else or communicates this disconnect to any
|
||||
* slaves.
|
||||
*/
|
||||
~I2c() {
|
||||
mraa_i2c_stop(m_i2c);
|
||||
}
|
||||
/**
|
||||
* Sets the i2c Frequency for communication. Your board may not support
|
||||
* the set frequency. Anyone can change this at any time and this will
|
||||
* affect every slave on the bus
|
||||
*
|
||||
* @param hz Frequency to set the bus to in hz
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t frequency(int hz) {
|
||||
return mraa_i2c_frequency(m_i2c, hz);
|
||||
}
|
||||
/**
|
||||
* Set the slave to talk to, typically called before every read/write
|
||||
* operation
|
||||
*
|
||||
* @param address Communicate to the i2c slave on this address
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t address(int address) {
|
||||
return mraa_i2c_address(m_i2c, address);
|
||||
}
|
||||
/**
|
||||
* Read exactly one byte from the bus
|
||||
*
|
||||
* @return Char read from the bus
|
||||
*/
|
||||
unsigned char readByte() {
|
||||
return (unsigned char) mraa_i2c_read_byte(m_i2c);
|
||||
}
|
||||
/**
|
||||
* Read mutliple bytes from the bus
|
||||
*
|
||||
* @param data Buffer to write into
|
||||
* @param length Size of read
|
||||
* @return length of the read or 0 if failed
|
||||
*/
|
||||
int read(unsigned char * data, int length) {
|
||||
return mraa_i2c_read(m_i2c, data, length);
|
||||
}
|
||||
/**
|
||||
* Write one byte to the bus
|
||||
*
|
||||
* @param data Buffer to send on the bus
|
||||
* @param length Size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(const unsigned char* data, int length) {
|
||||
return mraa_i2c_write(m_i2c, data, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to an i2c register
|
||||
*
|
||||
* @param reg Register to write to
|
||||
* @param data Value to write to register
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t writeReg(const unsigned char reg, const unsigned char data) {
|
||||
const unsigned char buf[2] = {reg, data};
|
||||
return mraa_i2c_write(m_i2c, buf, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write multiple bytes to the bus
|
||||
*
|
||||
* @param data The byte to send on the bus
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(const unsigned char data) {
|
||||
return mraa_i2c_write_byte(m_i2c, data);
|
||||
}
|
||||
private:
|
||||
mraa_i2c_context m_i2c;
|
||||
};
|
||||
|
||||
}
|
||||
171
api/mraa/pwm.h
Normal file
171
api/mraa/pwm.h
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Pulse Width Modulation module
|
||||
*
|
||||
* PWM is the Pulse Width Modulation interface to libmraa. It allows the
|
||||
* generation of a signal on a pin. Some boards may have higher or lower levels
|
||||
* of resolution so make sure you check the board & pin you are using before
|
||||
* hand.
|
||||
*
|
||||
* @snippet cycle-pwm3.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct _pwm* mraa_pwm_context;
|
||||
|
||||
/**
|
||||
* Initialise pwm_context, uses board mapping
|
||||
*
|
||||
* @param pin The PWM PIN
|
||||
* @return pwm context or NULL
|
||||
*/
|
||||
mraa_pwm_context mraa_pwm_init(int pin);
|
||||
|
||||
/**
|
||||
* Initialise pwm_context, raw mode
|
||||
*
|
||||
* @param chipid The chip inwhich the PWM is under in SYSFS
|
||||
* @param pin The PWM PIN.
|
||||
* @return pwm context or NULL
|
||||
*/
|
||||
mraa_pwm_context mraa_pwm_init_raw(int chipid, int pin);
|
||||
|
||||
/**
|
||||
* Set the ouput duty-cycle percentage, as a float
|
||||
*
|
||||
* @param dev The Pwm context to use
|
||||
* @param percentage A floating-point value representing percentage of output.
|
||||
* The value should lie between 0.0f (representing on 0%) and 1.0f
|
||||
* Values above or below this range will be set at either 0.0f or 1.0f
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_write(mraa_pwm_context dev, float percentage);
|
||||
|
||||
/**
|
||||
* Read the ouput duty-cycle percentage, as a float
|
||||
*
|
||||
* @param dev The Pwm context to use
|
||||
* @return percentage A floating-point value representing percentage of output.
|
||||
* The value should lie between 0.0f (representing on 0%) and 1.0f
|
||||
* Values above or below this range will be set at either 0.0f or 1.0f
|
||||
*/
|
||||
float mraa_pwm_read(mraa_pwm_context dev);
|
||||
|
||||
/**
|
||||
* Set the PWM period as seconds represented in a float
|
||||
*
|
||||
* @param dev The Pwm context to use
|
||||
* @param seconds Period represented as a float in seconds
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_period(mraa_pwm_context dev, float seconds);
|
||||
|
||||
/**
|
||||
* Set period, milliseconds.
|
||||
*
|
||||
* @param dev The Pwm context to use
|
||||
* @param ms Milliseconds for period
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_period_ms(mraa_pwm_context dev, int ms);
|
||||
|
||||
/**
|
||||
* Set period, microseconds
|
||||
*
|
||||
* @param dev The Pwm context to use
|
||||
* @param us Microseconds as period
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_period_us(mraa_pwm_context dev, int us);
|
||||
|
||||
/**
|
||||
* Set pulsewidth, As represnted by seconds in a (float)
|
||||
*
|
||||
* @param dev The Pwm context to use
|
||||
* @param seconds The duration of a pulse
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_pulsewidth(mraa_pwm_context dev, float seconds);
|
||||
|
||||
/**
|
||||
* Set pulsewidth, milliseconds
|
||||
*
|
||||
* @param dev The Pwm context to use
|
||||
* @param ms Milliseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_pulsewidth_ms(mraa_pwm_context dev, int ms);
|
||||
|
||||
/**
|
||||
* Set pulsewidth, microseconds
|
||||
*
|
||||
* @param dev The Pwm context to use
|
||||
* @param us Microseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_pulsewidth_us(mraa_pwm_context dev, int us);
|
||||
|
||||
/**
|
||||
* Set the enable status of the PWM pin. None zero will assume on with output being driven.
|
||||
* and 0 will disable the output.
|
||||
*
|
||||
* @param dev The pwm context to use
|
||||
* @param enable Toggle status of pin
|
||||
* @return Result of operation.
|
||||
*/
|
||||
mraa_result_t mraa_pwm_enable(mraa_pwm_context dev, int enable);
|
||||
|
||||
/**
|
||||
* Change ownership of context
|
||||
*
|
||||
* @param dev the context
|
||||
* @param owner Ownership boolean
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_owner(mraa_pwm_context dev, mraa_boolean_t owner);
|
||||
|
||||
/**
|
||||
* Close and unexport the PWM pin
|
||||
*
|
||||
* @param dev The pwm context to use
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_pwm_close(mraa_pwm_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
157
api/mraa/pwm.hpp
Normal file
157
api/mraa/pwm.hpp
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@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
|
||||
|
||||
#include "pwm.h"
|
||||
|
||||
namespace mraa {
|
||||
|
||||
/**
|
||||
* @brief C++ API to Pulse Width Modulation
|
||||
*
|
||||
* This file defines the PWM C++ interface for libmraa
|
||||
*
|
||||
* @snippet Pwm3-cycle.cpp Interesting
|
||||
*/
|
||||
class Pwm {
|
||||
public:
|
||||
/**
|
||||
* instanciates a PWM object on a pin
|
||||
*
|
||||
* @param pin the pin number used on your board
|
||||
* @param chipid the pwmchip to use, use only in raw mode
|
||||
* @param owner if you are the owner of the pin the destructor will
|
||||
* unexport the pin from sysfs, default behaviour is you are the owner
|
||||
* if the pinmapper exported it
|
||||
*/
|
||||
Pwm(int pin, int chipid=-1, bool owner = true) {
|
||||
if (chipid == -1)
|
||||
m_pwm = mraa_pwm_init(pin);
|
||||
else
|
||||
m_pwm = mraa_pwm_init_raw(pin, chipid);
|
||||
if (!owner)
|
||||
mraa_pwm_owner(m_pwm, 0);
|
||||
}
|
||||
/**
|
||||
* Pwm destructor
|
||||
*/
|
||||
~Pwm() {
|
||||
mraa_pwm_close(m_pwm);
|
||||
}
|
||||
/**
|
||||
* Set the output duty-cycle percentage, as a float
|
||||
*
|
||||
* @param percentage A floating-point value representing percentage of
|
||||
* output. The value should lie between 0.0f (representing on 0%) and
|
||||
* 1.0f Values above or below this range will be set at either 0.0f or
|
||||
* 1.0f
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(float percentage) {
|
||||
return mraa_pwm_write(m_pwm, percentage);
|
||||
}
|
||||
/**
|
||||
* Read the ouput duty-cycle percentage, as a float
|
||||
*
|
||||
* @return A floating-point value representing percentage of
|
||||
* output. The value should lie between 0.0f (representing on 0%) and
|
||||
* 1.0f Values above or below this range will be set at either 0.0f or
|
||||
* 1.0f
|
||||
*/
|
||||
float read() {
|
||||
return mraa_pwm_read(m_pwm);
|
||||
}
|
||||
/**
|
||||
* Set the PWM period as seconds represented in a float
|
||||
*
|
||||
* @param period Period represented as a float in seconds
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t period(float period) {
|
||||
return mraa_pwm_period(m_pwm, period);
|
||||
}
|
||||
/**
|
||||
* Set period, milliseconds
|
||||
*
|
||||
* @param ms milliseconds for period
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t period_ms(int ms) {
|
||||
return mraa_pwm_period_ms(m_pwm, ms);
|
||||
}
|
||||
/**
|
||||
* Set period, microseconds
|
||||
*
|
||||
* @param us microseconds as period
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t period_us(int us) {
|
||||
return mraa_pwm_period_us(m_pwm, us);
|
||||
}
|
||||
/**
|
||||
* Set pulsewidth, As represnted by seconds in a (float)
|
||||
*
|
||||
* @param seconds The duration of a pulse
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t pulsewidth(float seconds) {
|
||||
return mraa_pwm_pulsewidth(m_pwm, seconds);
|
||||
}
|
||||
/**
|
||||
* Set pulsewidth, milliseconds
|
||||
*
|
||||
* @param ms milliseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t pulsewidth_ms(int ms) {
|
||||
return mraa_pwm_pulsewidth_ms(m_pwm, ms);
|
||||
}
|
||||
/**
|
||||
* The pulsewidth, microseconds
|
||||
*
|
||||
* @param us microseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t pulsewidth_us(int us) {
|
||||
return mraa_pwm_pulsewidth_us(m_pwm, us);
|
||||
}
|
||||
/**
|
||||
* Set the enable status of the PWM pin. None zero will assume on with
|
||||
* output being driven and 0 will disable the output
|
||||
*
|
||||
* @param enable enable status of pin
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t enable(bool enable) {
|
||||
if (enable)
|
||||
return mraa_pwm_enable(m_pwm, 1);
|
||||
else
|
||||
return mraa_pwm_enable(m_pwm, 0);
|
||||
}
|
||||
private:
|
||||
mraa_pwm_context m_pwm;
|
||||
};
|
||||
|
||||
}
|
||||
122
api/mraa/spi.h
Normal file
122
api/mraa/spi.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief System Packet Interface
|
||||
*
|
||||
* This file defines the spi interface for libmraa
|
||||
*
|
||||
* @snippet spi_mcp4261.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* Opaque pointer definition to the internal struct _spi
|
||||
*/
|
||||
typedef struct _spi* mraa_spi_context;
|
||||
|
||||
/**
|
||||
* Initialise SPI_context, uses board mapping. Sets the muxes
|
||||
*
|
||||
* @param bus Bus to use, as listed in platform definition, normally 0
|
||||
* @return Spi context or NULL
|
||||
*/
|
||||
mraa_spi_context mraa_spi_init(int bus);
|
||||
|
||||
/**
|
||||
* Set the SPI device mode. see spidev 0-3.
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param mode The SPI mode, See Linux spidev
|
||||
* @return Spi context or NULL
|
||||
*/
|
||||
mraa_result_t mraa_spi_mode(mraa_spi_context dev,unsigned short mode);
|
||||
|
||||
/** Set the SPI device operating clock frequency.
|
||||
*
|
||||
* @param dev the Spi context
|
||||
* @param hz the frequency in hz
|
||||
* @return mraa_spi_context The returned initialised SPI context
|
||||
*/
|
||||
mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz);
|
||||
|
||||
/** Write Single Byte to the SPI device.
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param data Data to send
|
||||
* @return Data received on the miso line
|
||||
*/
|
||||
uint8_t mraa_spi_write(mraa_spi_context dev, uint8_t data);
|
||||
|
||||
/** Write Buffer of bytes to the SPI device. The pointer return has to be
|
||||
* free'd by the caller.
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param data to send
|
||||
* @param length elements within buffer, Max 4096
|
||||
* @return Data received on the miso line, same length as passed in
|
||||
*/
|
||||
uint8_t* mraa_spi_write_buf(mraa_spi_context dev, uint8_t* data, int length);
|
||||
|
||||
/**
|
||||
* Change the SPI lsb mode
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param lsb Use least significant bit transmission. 0 for msbi
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_spi_lsbmode(mraa_spi_context dev, mraa_boolean_t lsb);
|
||||
|
||||
/**
|
||||
* Set bits per mode on transaction, defaults at 8
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param bits bits per word
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_spi_bit_per_word(mraa_spi_context dev, unsigned int bits);
|
||||
|
||||
/**
|
||||
* De-inits an mraa_spi_context device
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_spi_stop(mraa_spi_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
112
api/mraa/spi.hpp
Normal file
112
api/mraa/spi.hpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@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
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
namespace mraa {
|
||||
|
||||
/**
|
||||
* @brief C++ API to System Packet Interface
|
||||
*
|
||||
* This file defines the SPI C++ interface for libmraa
|
||||
*
|
||||
* @snippet Spi-pot.cpp Interesting
|
||||
*/
|
||||
class Spi {
|
||||
public:
|
||||
/**
|
||||
* Initialise SPI object using the board mapping to set muxes
|
||||
*
|
||||
* @param bus to use, as listed in the platform definition, normally 0
|
||||
*/
|
||||
Spi(int bus) {
|
||||
m_spi = mraa_spi_init(bus);
|
||||
}
|
||||
/**
|
||||
* Closes spi bus
|
||||
*/
|
||||
~Spi() {
|
||||
mraa_spi_stop(m_spi);
|
||||
}
|
||||
/**
|
||||
* Set the SPI device mode. see spidev0-3
|
||||
*
|
||||
* @param mode the mode. See Linux spidev doc
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mode(unsigned short mode) {
|
||||
return mraa_spi_mode(m_spi, mode);
|
||||
}
|
||||
/**
|
||||
* Set the SPI device operating clock frequency
|
||||
*
|
||||
* @param hz the frequency to set in hz
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t frequency(int hz) {
|
||||
return mraa_spi_frequency(m_spi, hz);
|
||||
}
|
||||
/**
|
||||
* Write single byte to the SPI device
|
||||
*
|
||||
* @param data the byte to send
|
||||
* @return data received on the miso line
|
||||
*/
|
||||
unsigned char write(uint8_t data) {
|
||||
return (unsigned char) mraa_spi_write(m_spi, data);
|
||||
}
|
||||
/**
|
||||
* Write buffer of bytes to SPI device
|
||||
*
|
||||
* @param data buffer to send
|
||||
* @param length size of buffer to send
|
||||
* @return char* data received on the miso line. Same length as passed in
|
||||
*/
|
||||
unsigned char* write(uint8_t* data, int length) {
|
||||
return (unsigned char*) mraa_spi_write_buf(m_spi, data, length);
|
||||
}
|
||||
/**
|
||||
* Change the SPI lsb mode
|
||||
*
|
||||
* @param lsb Use least significant bit transmission - 0 for msbi
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t lsbmode(bool lsb) {
|
||||
return mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb);
|
||||
}
|
||||
/**
|
||||
* Set bits per mode on transaction, default is 8
|
||||
*
|
||||
* @param bits bits per word
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t bitPerWord(unsigned int bits) {
|
||||
return mraa_spi_bit_per_word(m_spi, bits);
|
||||
}
|
||||
private:
|
||||
mraa_spi_context m_spi;
|
||||
};
|
||||
}
|
||||
103
api/mraa/types.h
Normal file
103
api/mraa/types.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@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
|
||||
|
||||
/** @file
|
||||
*
|
||||
* This file defines the basic shared types for libmraa
|
||||
* this file is different to common.h in that swig takes this as an input
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MRAA supported platform types
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
|
||||
MRAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
|
||||
|
||||
MRAA_UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
} mraa_platform_t;
|
||||
|
||||
/**
|
||||
* MRAA return codes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_SUCCESS = 0, /**< Expected response */
|
||||
MRAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
|
||||
MRAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
|
||||
MRAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
|
||||
MRAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
|
||||
MRAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
|
||||
MRAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
|
||||
MRAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
|
||||
MRAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
|
||||
MRAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
|
||||
MRAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
|
||||
MRAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
|
||||
MRAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
|
||||
|
||||
MRAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
} mraa_result_t;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user