cmake_minimum_required (VERSION 2.8)
-project (maa)
+project (mraa)
FIND_PACKAGE (Threads)
include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
- message (WARNING " - Install git to compile a production libmaa!")
+ message (WARNING " - Install git to compile a production libmraa!")
set (VERSION "v0.3.1-dirty")
endif ()
-message (INFO " - MAA Version ${VERSION}")
+message (INFO " - MRAA Version ${VERSION}")
#parse the version information into pieces.
string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
${CMAKE_CURRENT_BINARY_DIR}/src/version.c)
# this is the library version, independant of git revision
-set (maa_VERSION_MAJOR ${VERSION_MAJOR})
-set (maa_VERSION_MINOR ${VERSION_MINOR})
-set (maa_VERSION_PATCH ${VERSION_PATCH})
-set (maa_VERSION_STRING ${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH})
+set (mraa_VERSION_MAJOR ${VERSION_MAJOR})
+set (mraa_VERSION_MINOR ${VERSION_MINOR})
+set (mraa_VERSION_PATCH ${VERSION_PATCH})
+set (mraa_VERSION_STRING ${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH})
set (CMAKE_SWIG_FLAGS "")
set(OPKG_ARCH ${DETECTED_ARCH})
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
- set(maa_PACKAGE_ON_TAG ".")
+ set(mraa_PACKAGE_ON_TAG ".")
if ("${VERSION_COMMIT}" STREQUAL "")
- set(maa_PACKAGE_ON_TAG "")
+ set(mraa_PACKAGE_ON_TAG "")
endif()
set(CPACK_PACKAGE_VERSION
- "${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH}${maa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
- set(CPACK_PACKAGE_NAME "libmaa${maa_VERSION_MAJOR}")
+ "${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH}${mraa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
+ set(CPACK_PACKAGE_NAME "libmraa${mraa_VERSION_MAJOR}")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
- set(CPACK_DEBIAN_PACKAGE_PROVIDES "libmaa-dev, libmaa-dbg, libmaa-doc")
+ set(CPACK_DEBIAN_PACKAGE_PROVIDES "libmraa-dev, libmraa-dbg, libmraa-doc")
set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
# title of most generated pages and in a few other places.
# The default value is: My Project.
-PROJECT_NAME = maa
+PROJECT_NAME = mraa
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = @maa_VERSION_STRING@
+PROJECT_NUMBER = @mraa_VERSION_STRING@
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# Note: If this tag is empty the current directory is searched.
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/api/ \
- @CMAKE_CURRENT_SOURCE_DIR@/api/maa/ \
+ @CMAKE_CURRENT_SOURCE_DIR@/api/mraa/ \
@CMAKE_CURRENT_SOURCE_DIR@/docs/
# This tag can be used to specify the character encoding of the source files
-MAA - Low Level Skeleton Library for Communication on Intel platforms
+MRAA - Low Level Skeleton Library for Communication on Intel platforms
==============
Library in C/C++ to interface with Galileo & other Intel platforms, in a
extern "C" {
#endif
-#include "maa/pwm.h"
-#include "maa/aio.h"
-#include "maa/gpio.h"
-#include "maa/spi.h"
-#include "maa/i2c.h"
+#include "mraa/pwm.h"
+#include "mraa/aio.h"
+#include "mraa/gpio.h"
+#include "mraa/spi.h"
+#include "mraa/i2c.h"
#ifdef __cplusplus
}
#pragma once
-#include "maa/common.h"
-#include "maa/pwm.hpp"
-#include "maa/aio.hpp"
-#include "maa/gpio.hpp"
-#include "maa/i2c.hpp"
-#include "maa/spi.hpp"
+#include "mraa/common.h"
+#include "mraa/pwm.hpp"
+#include "mraa/aio.hpp"
+#include "mraa/gpio.hpp"
+#include "mraa/i2c.hpp"
+#include "mraa/spi.hpp"
* @file
* @brief Analog input/output
*
- * AIO is the anlog input & output interface to libmaa. It is used to read or
+ * 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
* Opaque pointer definition to the internal struct _aio. This context refers
* to one single AIO pin on the board.
*/
-typedef struct _aio* maa_aio_context;
+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
*/
-maa_aio_context maa_aio_init(unsigned int pin);
+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 maa_aio_read(maa_aio_context dev);
+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
*/
-maa_result_t maa_aio_close(maa_aio_context dev);
+mraa_result_t mraa_aio_close(mraa_aio_context dev);
#ifdef __cplusplus
}
#include "aio.h"
-namespace maa {
+namespace mraa {
/**
* @brief C++ API to Analog IO
*
- * This file defines the aio C++ interface for libmaa
+ * This file defines the aio C++ interface for libmraa
*
* @snippet examples/c++/AioA0.cpp Interesting
*/
* @param pin channel number to read ADC inputs
*/
Aio(unsigned int pin) {
- m_aio = maa_aio_init(pin);
+ m_aio = mraa_aio_init(pin);
}
/**
* Aio destructor
*/
~Aio() {
- maa_aio_close(m_aio);
+ mraa_aio_close(m_aio);
}
/**
* Read a value from the AIO pin. Note this value can never be outside
*/
int read() {
// Use basic types to make swig code generation simpler
- return (int) maa_aio_read(m_aio);
+ return (int) mraa_aio_read(m_aio);
}
private:
- maa_aio_context m_aio;
+ mraa_aio_context m_aio;
};
}
/** @file
*
- * This file defines the basic shared values for libmaa
+ * This file defines the basic shared values for libmraa
*/
#ifdef __cplusplus
#endif
/**
- * MAA boolean type
+ * MRAA boolean type
* 1 For TRUE
*/
-typedef unsigned int maa_boolean_t;
+typedef unsigned int mraa_boolean_t;
/**
* Enum representing different possible modes for a pin.
*/
typedef enum {
- MAA_PIN_VALID = 0, /**< Pin Valid */
- MAA_PIN_GPIO = 1, /**< General Purpose IO */
- MAA_PIN_PWM = 2, /**< Pulse Width Modulation */
- MAA_PIN_FAST_GPIO = 3, /**< Faster GPIO */
- MAA_PIN_SPI = 4, /**< SPI */
- MAA_PIN_I2C = 5, /**< I2C */
- MAA_PIN_AIO = 6 /**< Analog in */
-} maa_pinmodes_t;
+ 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 {
/*@{*/
- maa_boolean_t valid:1; /**< Is the pin valid at all */
- maa_boolean_t gpio:1; /**< Is the pin gpio capable */
- maa_boolean_t pwm:1; /**< Is the pin pwm capable */
- maa_boolean_t fast_gpio:1; /**< Is the pin fast gpio capable */
- maa_boolean_t spi:1; /**< Is the pin spi capable */
- maa_boolean_t i2c:1; /**< Is the pin i2c capable */
- maa_boolean_t aio:1; /**< Is the pin analog input capable */
+ 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 */
/*@}*/
-} maa_pincapabilities_t;
+} mraa_pincapabilities_t;
/**
* A Structure representing a multiplexer and the required value
unsigned int pin; /**< Raw GPIO pin id */
unsigned int value; /**< Raw GPIO value */
/*@}*/
-} maa_mux_t;
+} mraa_mux_t;
typedef struct {
- maa_boolean_t complex_pin:1;
- maa_boolean_t output_en:1;
- maa_boolean_t output_en_high:1;
- maa_boolean_t pullup_en:1;
- maa_boolean_t pullup_en_hiz:1;
-} maa_pin_cap_complex_t;
+ 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 */
- maa_mux_t mux[6]; /** Array holding information about mux */
+ 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 */
- maa_pin_cap_complex_t complex_cap;
+ mraa_pin_cap_complex_t complex_cap;
/*@}*/
-} maa_pin_t;
+} 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 */
- maa_pin_t gpio; /** GPio context containing none mmap info */
+ mraa_pin_t gpio; /** GPio context containing none mmap info */
/*@}*/
-} maa_mmap_pin_t;
+} mraa_mmap_pin_t;
/**
* A Structure representing a physical Pin.
typedef struct {
/*@{*/
char name[8]; /**< Pin's real world name */
- maa_pincapabilities_t capabilites; /**< Pin Capabiliites */
- maa_pin_t gpio; /**< GPIO structure */
- maa_pin_t pwm; /**< PWM structure */
- maa_pin_t aio; /**< Anaglog Pin */
- maa_mmap_pin_t mmap; /**< GPIO through memory */
- maa_pin_t i2c; /**< i2c bus/pin */
- maa_pin_t spi; /**< spi bus/pin */
+ 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 */
/*@}*/
-} maa_pininfo_t;
+} mraa_pininfo_t;
/**
* A Structure representing the physical properties of a i2c bus.
unsigned int scl; /**< i2c SCL */
unsigned int sda; /**< i2c SDA */
/*@}*/
-} maa_i2c_bus_t;
+} mraa_i2c_bus_t;
/**
* A Structure representing the physical properties of a spi bus.
/*@{*/
unsigned int bus_id; /**< The Bus ID as exposed to the system. */
unsigned int slave_s; /**< Slave select */
- maa_boolean_t three_wire; /**< Is the bus only a three wire system */
+ 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 */
/*@}*/
-} maa_spi_bus_t;
+} mraa_spi_bus_t;
/**
* A Structure representing a platform/board.
unsigned int gpio_count; /**< GPIO Count */
unsigned int aio_count; /**< Analog side Count */
unsigned int i2c_bus_count; /**< Usable i2c Count */
- maa_i2c_bus_t i2c_bus[6]; /**< Array of i2c */
+ 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 */
- maa_spi_bus_t spi_bus[6]; /**< Array of spi */
+ mraa_spi_bus_t spi_bus[6]; /**< Array of spi */
unsigned int def_spi_bus; /**< Position in array of defult spi bus */
- maa_pininfo_t* pins; /**< Pointer to pin array */
+ mraa_pininfo_t* pins; /**< Pointer to pin array */
/*@}*/
-} maa_board_t;
+} mraa_board_t;
/**
- * Initialise MAA
+ * 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 maa_init()
+// 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
-maa_result_t maa_init() __attribute__((constructor));
+mraa_result_t mraa_init() __attribute__((constructor));
#else
-maa_result_t maa_init();
+mraa_result_t mraa_init();
#endif
/**
* @param mode the mode to be tested.
* @return boolean if the mode is supported, 0=false.
*/
-maa_boolean_t maa_pin_mode_test(int pin, maa_pinmodes_t mode);
+mraa_boolean_t mraa_pin_mode_test(int pin, mraa_pinmodes_t mode);
#ifdef __cplusplus
}
* @file
* @brief General Purpose IO
*
- * Gpio is the General Purpose IO interface to libmaa. It's features depends on
+ * 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
/**
* Opaque pointer definition to the internal struct _gpio
*/
-typedef struct _gpio* maa_gpio_context;
+typedef struct _gpio* mraa_gpio_context;
/**
* Gpio Output modes
*/
typedef enum {
- MAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
- MAA_GPIO_PULLUP = 1, /**< Resistive High */
- MAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
- MAA_GPIO_HIZ = 3 /**< High Z State */
+ 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 {
- MAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
- MAA_GPIO_IN = 1 /**< Input */
+ 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 {
- MAA_GPIO_EDGE_NONE = 0, /**< No interrupt on Gpio */
- MAA_GPIO_EDGE_BOTH = 1, /**< Interupt on rising & falling */
- MAA_GPIO_EDGE_RISING = 2, /**< Interupt on rising only */
- MAA_GPIO_EDGE_FALLING = 3 /**< Interupt on falling only */
+ 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;
/**
* @param pin Pin number read from the board, i.e IO3 is 3
* @returns gpio context or NULL
*/
-maa_gpio_context maa_gpio_init(int pin);
+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
*/
-maa_gpio_context maa_gpio_init_raw(int gpiopin);
+mraa_gpio_context mraa_gpio_init_raw(int gpiopin);
/**
* Set the edge mode on the gpio
* @param mode The edge mode to set the gpio into
* @return Result of operation
*/
-maa_result_t maa_gpio_edge_mode(maa_gpio_context dev, gpio_edge_t mode);
+mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode);
/**
* Set an interupt on pin
* @param args Arguments passed to the interrupt handler (fptr)
* @return Result of operation
*/
-maa_result_t maa_gpio_isr(maa_gpio_context dev, gpio_edge_t edge, void (*fptr)(void *), void * args);
+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 MAA_GPIO_EDGE_NONE
+ * to MRAA_GPIO_EDGE_NONE
*
* @param dev The Gpio context
* @return Result of operation
*/
-maa_result_t maa_gpio_isr_exit(maa_gpio_context dev);
+mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev);
/**
* Set Gpio Output Mode,
* @param mode The Gpio Output Mode
* @return Result of operation
*/
-maa_result_t maa_gpio_mode(maa_gpio_context dev, gpio_mode_t mode);
+mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode);
/**
* Set Gpio direction
* @param dir The direction of the Gpio
* @return Result of operation
*/
-maa_result_t maa_gpio_dir(maa_gpio_context dev, gpio_dir_t dir);
+mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir);
/**
* Close the Gpio context
* @param dev The Gpio context
* @return Result of operation
*/
-maa_result_t maa_gpio_close(maa_gpio_context dev);
+mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
/**
* Read the Gpio value.
* @param dev The Gpio context
* @return Result of operation
*/
-int maa_gpio_read(maa_gpio_context dev);
+int mraa_gpio_read(mraa_gpio_context dev);
/**
* Write to the Gpio Value.
* @param value Integer value to write
* @return Result of operation
*/
-maa_result_t maa_gpio_write(maa_gpio_context dev, int value);
+mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value);
/**
* Change ownership of the context.
* @param owner Does this context own the pin
* @return Result of operation
*/
-maa_result_t maa_gpio_owner(maa_gpio_context dev, maa_boolean_t owner);
+mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner);
/**
* Enable using memory mapped io instead of sysfs
* @param mmap Use mmap instead of sysfs
* @return Result of operation
*/
-maa_result_t maa_gpio_use_mmaped(maa_gpio_context dev, maa_boolean_t mmap);
+mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
#ifdef __cplusplus
}
#include "gpio.h"
-namespace maa {
+namespace mraa {
// These enums must match the enums in gpio.h
/**
* @brief C++ API to General Purpose IO
*
- * This file defines the gpio C++ interface for libmaa
+ * This file defines the gpio C++ interface for libmraa
*
* @snippet Blink-IO.cpp Interesting
*/
*/
Gpio(int pin, bool owner=true, bool raw=false) {
if (raw)
- m_gpio = maa_gpio_init_raw(pin);
+ m_gpio = mraa_gpio_init_raw(pin);
else
- m_gpio = maa_gpio_init(pin);
+ m_gpio = mraa_gpio_init(pin);
if (!owner)
- maa_gpio_owner(m_gpio, 0);
+ mraa_gpio_owner(m_gpio, 0);
}
/**
* Gpio object destructor, this will only unexport the gpio if we where
* the owner
*/
~Gpio() {
- maa_gpio_close(m_gpio);
+ mraa_gpio_close(m_gpio);
}
/**
* Set the edge mode for ISR
* @param mode The edge mode to set
* @return Result of operation
*/
- maa_result_t edge(Edge mode) {
- return maa_gpio_edge_mode(m_gpio, (gpio_edge_t) mode);
+ mraa_result_t edge(Edge mode) {
+ return mraa_gpio_edge_mode(m_gpio, (gpio_edge_t) mode);
}
#if defined(SWIGPYTHON)
- maa_result_t isr(Edge mode, PyObject *pyfunc, PyObject* args) {
- return maa_gpio_isr(m_gpio, (gpio_edge_t) mode, (void (*) (void *)) pyfunc, (void *) args);
+ 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
/**
* @param args Arguments passed to the interrupt handler (fptr)
* @return Result of operation
*/
- maa_result_t isr(Edge mode, void (*fptr)(void *), void * args) {
- return maa_gpio_isr(m_gpio, (gpio_edge_t) mode, fptr, args);
+ mraa_result_t isr(Edge mode, void (*fptr)(void *), void * args) {
+ return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, fptr, args);
}
#endif
/**
*
* @return Result of operation
*/
- maa_result_t isrExit() {
- return maa_gpio_isr_exit(m_gpio);
+ 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
*/
- maa_result_t mode(Mode mode) {
- return maa_gpio_mode(m_gpio, (gpio_mode_t) mode);
+ 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
*/
- maa_result_t dir(Dir dir) {
- return maa_gpio_dir(m_gpio, (gpio_dir_t) dir);
+ 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 maa_gpio_read(m_gpio);
+ return mraa_gpio_read(m_gpio);
}
/**
* Write value to Gpio
* @param value Value to write to Gpio
* @return Result of operation
*/
- maa_result_t write(int value) {
- return maa_gpio_write(m_gpio, value);
+ mraa_result_t write(int value) {
+ return mraa_gpio_write(m_gpio, value);
}
private:
- maa_gpio_context m_gpio;
+ mraa_gpio_context m_gpio;
};
}
* @file
* @brief Inter-Integrated Circuit
*
- * This file defines the i2c/Iic interface for libmaa. A context represents a
+ * 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
/**
* Opaque pointer definition to the internal struct _i2c
*/
-typedef struct _i2c* maa_i2c_context;
+typedef struct _i2c* mraa_i2c_context;
/**
* Initialise i2c context, using board defintions
* @param bus i2c bus to use
* @return i2c context or NULL
*/
-maa_i2c_context maa_i2c_init(int bus);
+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
*/
-maa_i2c_context maa_i2c_init_raw(unsigned int bus);
+mraa_i2c_context mraa_i2c_init_raw(unsigned int bus);
/**
* Sets the frequency of the i2c context
* @param hz The bus frequency in hertz
* @return Result of operation
*/
-maa_result_t maa_i2c_frequency(maa_i2c_context dev, int hz);
+mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, int hz);
/**
* Read from an i2c context
* @param length max number of bytes to read
* @return length of the read in bytes or 0
*/
-int maa_i2c_read(maa_i2c_context dev, uint8_t *data, int length);
+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 maa_i2c_read_byte(maa_i2c_context dev);
+uint8_t mraa_i2c_read_byte(mraa_i2c_context dev);
/**
* Write to an i2c context
* @param length the number of bytes to transmit
* @return Result of operation
*/
-maa_result_t maa_i2c_write(maa_i2c_context dev, const uint8_t *data, int length);
+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 data The byte to write
* @return Result of operation
*/
-maa_result_t maa_i2c_write_byte(maa_i2c_context dev, const uint8_t data);
+mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data);
/**
* Sets the i2c context address.
* general call address.
* @return Result of operation
*/
-maa_result_t maa_i2c_address(maa_i2c_context dev, int address);
+mraa_result_t mraa_i2c_address(mraa_i2c_context dev, int address);
/**
- * De-inits an maa_i2c_context device
+ * De-inits an mraa_i2c_context device
*
* @param dev The i2c context
* @return Result of operation
*/
-maa_result_t maa_i2c_stop(maa_i2c_context dev);
+mraa_result_t mraa_i2c_stop(mraa_i2c_context dev);
#ifdef __cplusplus
}
#include "i2c.h"
-namespace maa {
+namespace mraa {
/**
* @brief C++ API to Inter-Integrated Circuit
*
- * This file defines the I2c C++ interface for libmaa
+ * This file defines the I2c C++ interface for libmraa
*
* @snippet I2c-compass.cpp Interesting
*/
*/
I2c(int bus, bool raw=false) {
if (raw)
- m_i2c = maa_i2c_init_raw(bus);
+ m_i2c = mraa_i2c_init_raw(bus);
else
- m_i2c = maa_i2c_init(bus);
+ m_i2c = mraa_i2c_init(bus);
}
/**
* Closes the I2c Bus used. This does not guarrantee the bus will not
* slaves.
*/
~I2c() {
- maa_i2c_stop(m_i2c);
+ mraa_i2c_stop(m_i2c);
}
/**
* Sets the i2c Frequency for communication. Your board may not support
* @param hz Frequency to set the bus to in hz
* @return Result of operation
*/
- maa_result_t frequency(int hz) {
- return maa_i2c_frequency(m_i2c, hz);
+ 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
* @param address Communicate to the i2c slave on this address
* @return Result of operation
*/
- maa_result_t address(int address) {
- return maa_i2c_address(m_i2c, address);
+ 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) maa_i2c_read_byte(m_i2c);
+ return (unsigned char) mraa_i2c_read_byte(m_i2c);
}
/**
* Read mutliple bytes from the bus
* @return length of the read or 0 if failed
*/
int read(unsigned char * data, int length) {
- return maa_i2c_read(m_i2c, data, length);
+ return mraa_i2c_read(m_i2c, data, length);
}
/**
* Write one byte to the bus
* @param length Size of buffer to send
* @return Result of operation
*/
- maa_result_t write(const unsigned char* data, int length) {
- return maa_i2c_write(m_i2c, data, length);
+ mraa_result_t write(const unsigned char* data, int length) {
+ return mraa_i2c_write(m_i2c, data, length);
}
/**
* @param data Value to write to register
* @return Result of operation
*/
- maa_result_t writeReg(const unsigned char reg, const unsigned char data) {
+ mraa_result_t writeReg(const unsigned char reg, const unsigned char data) {
const unsigned char buf[2] = {reg, data};
- return maa_i2c_write(m_i2c, buf, 2);
+ return mraa_i2c_write(m_i2c, buf, 2);
}
/**
* @param data The byte to send on the bus
* @return Result of operation
*/
- maa_result_t write(const unsigned char data) {
- return maa_i2c_write_byte(m_i2c, data);
+ mraa_result_t write(const unsigned char data) {
+ return mraa_i2c_write_byte(m_i2c, data);
}
private:
- maa_i2c_context m_i2c;
+ mraa_i2c_context m_i2c;
};
}
* @file
* @brief Pulse Width Modulation module
*
- * PWM is the Pulse Width Modulation interface to libmaa. It allows the
+ * 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.
#include "common.h"
-typedef struct _pwm* maa_pwm_context;
+typedef struct _pwm* mraa_pwm_context;
/**
* Initialise pwm_context, uses board mapping
* @param pin The PWM PIN
* @return pwm context or NULL
*/
-maa_pwm_context maa_pwm_init(int pin);
+mraa_pwm_context mraa_pwm_init(int pin);
/**
* Initialise pwm_context, raw mode
* @param pin The PWM PIN.
* @return pwm context or NULL
*/
-maa_pwm_context maa_pwm_init_raw(int chipid, int pin);
+mraa_pwm_context mraa_pwm_init_raw(int chipid, int pin);
/**
* Set the ouput duty-cycle percentage, as a float
* Values above or below this range will be set at either 0.0f or 1.0f
* @return Result of operation
*/
-maa_result_t maa_pwm_write(maa_pwm_context dev, float percentage);
+mraa_result_t mraa_pwm_write(mraa_pwm_context dev, float percentage);
/**
* Read the ouput duty-cycle percentage, as a float
* 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 maa_pwm_read(maa_pwm_context dev);
+float mraa_pwm_read(mraa_pwm_context dev);
/**
* Set the PWM period as seconds represented in a float
* @param seconds Period represented as a float in seconds
* @return Result of operation
*/
-maa_result_t maa_pwm_period(maa_pwm_context dev, float seconds);
+mraa_result_t mraa_pwm_period(mraa_pwm_context dev, float seconds);
/**
* Set period, milliseconds.
* @param ms Milliseconds for period
* @return Result of operation
*/
-maa_result_t maa_pwm_period_ms(maa_pwm_context dev, int ms);
+mraa_result_t mraa_pwm_period_ms(mraa_pwm_context dev, int ms);
/**
* Set period, microseconds
* @param us Microseconds as period
* @return Result of operation
*/
-maa_result_t maa_pwm_period_us(maa_pwm_context dev, int us);
+mraa_result_t mraa_pwm_period_us(mraa_pwm_context dev, int us);
/**
* Set pulsewidth, As represnted by seconds in a (float)
* @param seconds The duration of a pulse
* @return Result of operation
*/
-maa_result_t maa_pwm_pulsewidth(maa_pwm_context dev, float seconds);
+mraa_result_t mraa_pwm_pulsewidth(mraa_pwm_context dev, float seconds);
/**
* Set pulsewidth, milliseconds
* @param ms Milliseconds for pulsewidth
* @return Result of operation
*/
-maa_result_t maa_pwm_pulsewidth_ms(maa_pwm_context dev, int ms);
+mraa_result_t mraa_pwm_pulsewidth_ms(mraa_pwm_context dev, int ms);
/**
* Set pulsewidth, microseconds
* @param us Microseconds for pulsewidth
* @return Result of operation
*/
-maa_result_t maa_pwm_pulsewidth_us(maa_pwm_context dev, int us);
+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.
* @param enable Toggle status of pin
* @return Result of operation.
*/
-maa_result_t maa_pwm_enable(maa_pwm_context dev, int enable);
+mraa_result_t mraa_pwm_enable(mraa_pwm_context dev, int enable);
/**
* Change ownership of context
* @param owner Ownership boolean
* @return Result of operation
*/
-maa_result_t maa_pwm_owner(maa_pwm_context dev, maa_boolean_t owner);
+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
*/
-maa_result_t maa_pwm_close(maa_pwm_context dev);
+mraa_result_t mraa_pwm_close(mraa_pwm_context dev);
#ifdef __cplusplus
}
#include "pwm.h"
-namespace maa {
+namespace mraa {
/**
* @brief C++ API to Pulse Width Modulation
*
- * This file defines the PWM C++ interface for libmaa
+ * This file defines the PWM C++ interface for libmraa
*
* @snippet Pwm3-cycle.cpp Interesting
*/
*/
Pwm(int pin, int chipid=-1, bool owner = true) {
if (chipid == -1)
- m_pwm = maa_pwm_init(pin);
+ m_pwm = mraa_pwm_init(pin);
else
- m_pwm = maa_pwm_init_raw(pin, chipid);
+ m_pwm = mraa_pwm_init_raw(pin, chipid);
if (!owner)
- maa_pwm_owner(m_pwm, 0);
+ mraa_pwm_owner(m_pwm, 0);
}
/**
* Pwm destructor
*/
~Pwm() {
- maa_pwm_close(m_pwm);
+ mraa_pwm_close(m_pwm);
}
/**
* Set the output duty-cycle percentage, as a float
* 1.0f
* @return Result of operation
*/
- maa_result_t write(float percentage) {
- return maa_pwm_write(m_pwm, percentage);
+ mraa_result_t write(float percentage) {
+ return mraa_pwm_write(m_pwm, percentage);
}
/**
* Read the ouput duty-cycle percentage, as a float
* 1.0f
*/
float read() {
- return maa_pwm_read(m_pwm);
+ 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
*/
- maa_result_t period(float period) {
- return maa_pwm_period(m_pwm, period);
+ 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
*/
- maa_result_t period_ms(int ms) {
- return maa_pwm_period_ms(m_pwm, ms);
+ 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
*/
- maa_result_t period_us(int us) {
- return maa_pwm_period_us(m_pwm, us);
+ 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
*/
- maa_result_t pulsewidth(float seconds) {
- return maa_pwm_pulsewidth(m_pwm, seconds);
+ 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
*/
- maa_result_t pulsewidth_ms(int ms) {
- return maa_pwm_pulsewidth_ms(m_pwm, ms);
+ 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
*/
- maa_result_t pulsewidth_us(int us) {
- return maa_pwm_pulsewidth_us(m_pwm, us);
+ 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
* @param enable enable status of pin
* @return Result of operation
*/
- maa_result_t enable(bool enable) {
+ mraa_result_t enable(bool enable) {
if (enable)
- return maa_pwm_enable(m_pwm, 1);
+ return mraa_pwm_enable(m_pwm, 1);
else
- return maa_pwm_enable(m_pwm, 0);
+ return mraa_pwm_enable(m_pwm, 0);
}
private:
- maa_pwm_context m_pwm;
+ mraa_pwm_context m_pwm;
};
}
* @file
* @brief System Packet Interface
*
- * This file defines the spi interface for libmaa
+ * This file defines the spi interface for libmraa
*
* @snippet spi_mcp4261.c Interesting
*/
/**
* Opaque pointer definition to the internal struct _spi
*/
-typedef struct _spi* maa_spi_context;
+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
*/
-maa_spi_context maa_spi_init(int bus);
+mraa_spi_context mraa_spi_init(int bus);
/**
* Set the SPI device mode. see spidev 0-3.
* @param mode The SPI mode, See Linux spidev
* @return Spi context or NULL
*/
-maa_result_t maa_spi_mode(maa_spi_context dev,unsigned short mode);
+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 maa_spi_context The returned initialised SPI context
+ * @return mraa_spi_context The returned initialised SPI context
*/
-maa_result_t maa_spi_frequency(maa_spi_context dev, int hz);
+mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz);
/** Write Single Byte to the SPI device.
*
* @param data Data to send
* @return Data received on the miso line
*/
-uint8_t maa_spi_write(maa_spi_context dev, uint8_t data);
+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 length elements within buffer, Max 4096
* @return Data received on the miso line, same length as passed in
*/
-uint8_t* maa_spi_write_buf(maa_spi_context dev, uint8_t* data, int length);
+uint8_t* mraa_spi_write_buf(mraa_spi_context dev, uint8_t* data, int length);
/**
* Change the SPI lsb mode
* @param lsb Use least significant bit transmission. 0 for msbi
* @return Result of operation
*/
-maa_result_t maa_spi_lsbmode(maa_spi_context dev, maa_boolean_t lsb);
+mraa_result_t mraa_spi_lsbmode(mraa_spi_context dev, mraa_boolean_t lsb);
/**
* Set bits per mode on transaction, defaults at 8
* @param bits bits per word
* @return Result of operation
*/
-maa_result_t maa_spi_bit_per_word(maa_spi_context dev, unsigned int bits);
+mraa_result_t mraa_spi_bit_per_word(mraa_spi_context dev, unsigned int bits);
/**
- * De-inits an maa_spi_context device
+ * De-inits an mraa_spi_context device
*
* @param dev The Spi context
* @return Result of operation
*/
-maa_result_t maa_spi_stop(maa_spi_context dev);
+mraa_result_t mraa_spi_stop(mraa_spi_context dev);
#ifdef __cplusplus
}
#include "spi.h"
-namespace maa {
+namespace mraa {
/**
* @brief C++ API to System Packet Interface
*
- * This file defines the SPI C++ interface for libmaa
+ * This file defines the SPI C++ interface for libmraa
*
* @snippet Spi-pot.cpp Interesting
*/
* @param bus to use, as listed in the platform definition, normally 0
*/
Spi(int bus) {
- m_spi = maa_spi_init(bus);
+ m_spi = mraa_spi_init(bus);
}
/**
* Closes spi bus
*/
~Spi() {
- maa_spi_stop(m_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
*/
- maa_result_t mode(unsigned short mode) {
- return maa_spi_mode(m_spi, mode);
+ 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
*/
- maa_result_t frequency(int hz) {
- return maa_spi_frequency(m_spi, hz);
+ mraa_result_t frequency(int hz) {
+ return mraa_spi_frequency(m_spi, hz);
}
/**
* Write single byte to the SPI device
* @return data received on the miso line
*/
unsigned char write(uint8_t data) {
- return (unsigned char) maa_spi_write(m_spi, data);
+ return (unsigned char) mraa_spi_write(m_spi, data);
}
/**
* Write buffer of bytes to SPI device
* @return char* data received on the miso line. Same length as passed in
*/
unsigned char* write(uint8_t* data, int length) {
- return (unsigned char*) maa_spi_write_buf(m_spi, data, 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
*/
- maa_result_t lsbmode(bool lsb) {
- return maa_spi_lsbmode(m_spi, (maa_boolean_t) lsb);
+ 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
*/
- maa_result_t bitPerWord(unsigned int bits) {
- return maa_spi_bit_per_word(m_spi, bits);
+ mraa_result_t bitPerWord(unsigned int bits) {
+ return mraa_spi_bit_per_word(m_spi, bits);
}
private:
- maa_spi_context m_spi;
+ mraa_spi_context m_spi;
};
}
/** @file
*
- * This file defines the basic shared types for libmaa
+ * This file defines the basic shared types for libmraa
* this file is different to common.h in that swig takes this as an input
*/
#endif
/**
- * MAA supported platform types
+ * MRAA supported platform types
*/
typedef enum {
- MAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
- MAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
+ MRAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
+ MRAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
- MAA_UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
-} maa_platform_t;
+ MRAA_UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
+} mraa_platform_t;
/**
- * MAA return codes
+ * MRAA return codes
*/
typedef enum {
- MAA_SUCCESS = 0, /**< Expected response */
- MAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
- MAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
- MAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
- MAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
- MAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
- MAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
- MAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
- MAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
- MAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
- MAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
- MAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
- MAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
+ 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 */
- MAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
-} maa_result_t;
+ MRAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
+} mraa_result_t;
/**
- * This function attempts to set the maa process to a given priority and the
+ * 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 maa_set_priority(const unsigned int priority);
+int mraa_set_priority(const unsigned int priority);
-/** Get the version string of maa autogenerated from git tag
+/** 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* maa_get_version();
+const char* mraa_get_version();
/**
- * Print a textual representation of the maa_result_t
+ * Print a textual representation of the mraa_result_t
*
* @param result the result to print
*/
-void maa_result_print(maa_result_t result);
+void mraa_result_print(mraa_result_t result);
/**
* Get platform type, board must be initialised.
*
- * @return maa_platform_t Platform type enum
+ * @return mraa_platform_t Platform type enum
*/
-maa_platform_t maa_get_platform_type();
+mraa_platform_t mraa_get_platform_type();
#ifdef __cplusplus
}
Provides: ${CPACK_DEBIAN_PACKAGE_PROVIDES}
Replaces: ${CPACK_DEBIAN_PACKAGE_REPLACES}
Conflicts: ${CPACK_DEBIAN_PACKAGE_CONFLICTS}
-Source: https://github.com/intel-iot-devkit/maa
+Source: https://github.com/intel-iot-devkit/mraa
#Essential: no
")
-Building libmaa {#building}
+Building libmraa {#building}
===============
-libmaa uses cmake in order to make compilation relatively painless. Cmake runs
+libmraa uses cmake in order to make compilation relatively painless. Cmake runs
build out of tree so the recommended way is to clone from git and make a build/ directory.
~~~~~~~~~~~~~{.sh}
-Contributing to libmaa {#contributing}
+Contributing to libmraa {#contributing}
======================
-libmaa is an opensource project and we are actively looking for people to help
+libmraa is an opensource project and we are actively looking for people to help
with:
- Writing platform supports for all types of embedded boards running linux
Galileo is a microcontroller board based on the Intel® Quark SoC X1000
Application Processor, a 32-bit Intel Pentium-class system on a chip.
-The rev D board has the following limitations in libmaa:
+The rev D board has the following limitations in libmraa:
- gpio register access via /dev/uio is limited to pin2 and 3
- gpio interupts will only work on GPIO_EDGE_BOTH
-MAA - Low Level Skeleton Library for Communication on Intel platforms
+MRAA - Low Level Skeleton Library for Communication on Intel platforms
==============
Library in C/C++ to interface with Galileo & other Intel platforms, in a
## API
-These interfaces allow you to interact with all libmaa functionality. The C++
+These interfaces allow you to interact with all libmraa functionality. The C++
classes directly wrap the C API and provide a near 1:1 mapping of
functionality.
<center>
| C API Modules | C++ API Classes |
|:----------------------:|:---------------------------:|
-| @ref gpio.h "gpio" | @ref maa::Gpio "Gpio class" |
-| @ref i2c.h "i2c" | @ref maa::I2c "I2c class" |
-| @ref aio.h "aio" | @ref maa::Aio "Aio class" |
-| @ref pwm.h "pwm" | @ref maa::Pwm "Pwm class" |
-| @ref spi.h "spi" | @ref maa::Spi "Spi class" |
+| @ref gpio.h "gpio" | @ref mraa::Gpio "Gpio class" |
+| @ref i2c.h "i2c" | @ref mraa::I2c "I2c class" |
+| @ref aio.h "aio" | @ref mraa::Aio "Aio class" |
+| @ref pwm.h "pwm" | @ref mraa::Pwm "Pwm class" |
+| @ref spi.h "spi" | @ref mraa::Spi "Spi class" |
| @ref common.h "common" | @ref common.h "common" |
</center>
-### Hello Maa
-@snippet hellomaa.c Interesting
+### Hello Mraa
+@snippet hellomraa.c Interesting
## Supported platforms
**0.3.1**
* Initial Intel Galileo Gen 2 support
- * maa_gpio_isr parameters added.
+ * mraa_gpio_isr parameters added.
* Detection of different supported platforms added.
**0.3.0**
- * maa_i2c_read now returns length of read
+ * mraa_i2c_read now returns length of read
**0.2.9**
- * Add global maa.h & maa.hpp headers
- * usage of "gpio.h" is not legal you need to use "maa/gpio.h" unless adding
- -L/usr/include/maa
+ * Add global mraa.h & mraa.hpp headers
+ * usage of "gpio.h" is not legal you need to use "mraa/gpio.h" unless adding
+ -L/usr/include/mraa
**0.2.8**
- * Added maa_set_priority call
- * Added mmap gpio call maa_gpio_use_mmaped
+ * Added mraa_set_priority call
+ * Added mmap gpio call mraa_gpio_use_mmaped
**0.2.7**
* C++ API now uses basic types and not unistd types as C
**0.2.6**
* C++ examples added, using c++ headers/api.
* moved to open instead of fopen in all modules
- * rename maa_check functions and made them internal to maa only.
+ * rename mraa_check functions and made them internal to mraa only.
* removed "export" functions from api
* Intel Galileo Gen 1 (rev d) fixes, incorrect definition of some items
* SPI, implementation completed.
* GPIO/PWM ownership guard prevents closing on existing pins, still can be forced.
**0.2.5**
- * C++/Python/Node Enums/const names now do not contain MAA_GPIO
+ * C++/Python/Node Enums/const names now do not contain MRAA_GPIO
* Enum type declaration for C++ changed
* Python/Node get_version() -> GetVersion()
* i2c read calls don't use const char* and i2c write calls do
**0.2.4**
- * All maa_ contexts now are pointers to the actual struct which is not
+ * All mraa_ contexts now are pointers to the actual struct which is not
delcared in the header. The only end user change is that instead of
- returning a type maa_gpio_context pointer maa_gpio_init() now returns a
- maa_gpio_context (which is actually a pointer to struct _gpio internally).
+ returning a type mraa_gpio_context pointer mraa_gpio_init() now returns a
+ mraa_gpio_context (which is actually a pointer to struct _gpio internally).
* C++ API is available, use the .hpp headers and add stdc++ to the linker
flags.
* Initial SPI implementation is provided
**0.2.3**
- * maa_aio_read_u16() -> maa_aio_read()
- * maa_aio_read() now returns a uint16_t instead of an unsigned int
+ * mraa_aio_read_u16() -> mraa_aio_read()
+ * mraa_aio_read() now returns a uint16_t instead of an unsigned int
**0.2.2**
* First version with API considered 'stable'
add_executable (i2c_HMC5883L i2c_HMC5883L.c)
-add_executable (hellomaa hellomaa.c)
+add_executable (hellomraa hellomraa.c)
add_executable (cycle-pwm3 cycle-pwm3.c)
add_executable (blink-io blink-io.c)
add_executable (analogin_a0 analogin_a0.c)
include_directories(${PROJECT_SOURCE_DIR}/api)
-target_link_libraries (hellomaa maa)
-target_link_libraries (i2c_HMC5883L maa m)
-target_link_libraries (cycle-pwm3 maa)
-target_link_libraries (blink-io maa)
-target_link_libraries (analogin_a0 maa)
-target_link_libraries (isr_pin6 maa)
-target_link_libraries (gpio_read6 maa)
-target_link_libraries (spi_mcp4261 maa)
-target_link_libraries (mmap-io2 maa)
-target_link_libraries (blink_onboard maa)
+target_link_libraries (hellomraa mraa)
+target_link_libraries (i2c_HMC5883L mraa m)
+target_link_libraries (cycle-pwm3 mraa)
+target_link_libraries (blink-io mraa)
+target_link_libraries (analogin_a0 mraa)
+target_link_libraries (isr_pin6 mraa)
+target_link_libraries (gpio_read6 mraa)
+target_link_libraries (spi_mcp4261 mraa)
+target_link_libraries (mmap-io2 mraa)
+target_link_libraries (blink_onboard mraa)
add_subdirectory (c++)
-install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples/ DESTINATION share/maa/examples)
+install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples/ DESTINATION share/mraa/examples)
#include <unistd.h>
//! [Interesting]
-#include "maa/aio.h"
+#include "mraa/aio.h"
int main ()
{
- maa_aio_context adc_a0;
+ mraa_aio_context adc_a0;
uint16_t adc_value = 0;
- adc_a0 = maa_aio_init(0);
+ adc_a0 = mraa_aio_init(0);
if (adc_a0 == NULL) {
return 1;
}
for(;;) {
- adc_value = maa_aio_read(adc_a0);
+ adc_value = mraa_aio_read(adc_a0);
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
}
- maa_aio_close(adc_a0);
+ mraa_aio_close(adc_a0);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
//! [Interesting]
#include <signal.h>
#include <stdlib.h>
-#include "maa.h"
+#include "mraa.h"
#define DEFAULT_IOPIN 8
int
main(int argc, char **argv)
{
- maa_result_t r = MAA_SUCCESS;
+ mraa_result_t r = MRAA_SUCCESS;
iopin = DEFAULT_IOPIN;
if (argc < 2) {
iopin = strtol(argv[1], NULL, 10);
}
- maa_init();
- fprintf(stdout, "MAA Version: %s\nStarting Blinking on IO%d\n",
- maa_get_version(), iopin);
+ mraa_init();
+ fprintf(stdout, "MRAA Version: %s\nStarting Blinking on IO%d\n",
+ mraa_get_version(), iopin);
- maa_gpio_context gpio;
- gpio = maa_gpio_init(iopin);
+ mraa_gpio_context gpio;
+ gpio = mraa_gpio_init(iopin);
if (gpio == NULL) {
fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", iopin);
exit(1);
printf("Initialised pin%d\n", iopin);
// set direction to OUT
- r = maa_gpio_dir(gpio, MAA_GPIO_OUT);
- if (r != MAA_SUCCESS) {
- maa_result_print(r);
+ r = mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
+ if (r != MRAA_SUCCESS) {
+ mraa_result_print(r);
}
signal(SIGINT, sig_handler);
while (running == 0) {
- r = maa_gpio_write(gpio, 0);
- if (r != MAA_SUCCESS) {
- maa_result_print(r);
+ r = mraa_gpio_write(gpio, 0);
+ if (r != MRAA_SUCCESS) {
+ mraa_result_print(r);
} else {
printf("off\n");
}
sleep(1);
- r = maa_gpio_write(gpio, 1);
- if (r != MAA_SUCCESS) {
- maa_result_print(r);
+ r = mraa_gpio_write(gpio, 1);
+ if (r != MRAA_SUCCESS) {
+ mraa_result_print(r);
} else {
printf("on\n");
}
sleep(1);
}
- r = maa_gpio_close(gpio);
- if (r != MAA_SUCCESS) {
- maa_result_print(r);
+ r = mraa_gpio_close(gpio);
+ if (r != MRAA_SUCCESS) {
+ mraa_result_print(r);
}
return r;
#include "stdio.h"
#include <string.h>
-#include "maa/gpio.h"
+#include "mraa/gpio.h"
int
main(int argc, char **argv)
{
- maa_platform_t platform = maa_get_platform_type();
- maa_gpio_context gpio;
+ mraa_platform_t platform = mraa_get_platform_type();
+ mraa_gpio_context gpio;
char board_name[] = "Some weird devboard that isn't recognised...";
int ledstate = 0;
switch (platform) {
- case MAA_INTEL_GALILEO_GEN1:
+ case MRAA_INTEL_GALILEO_GEN1:
strcpy(board_name, "Intel Galileo Gen1");
- gpio = maa_gpio_init_raw(3);
+ gpio = mraa_gpio_init_raw(3);
break;
- case MAA_INTEL_GALILEO_GEN2:
+ case MRAA_INTEL_GALILEO_GEN2:
strcpy(board_name, "Intel Galileo Gen2");
default:
- gpio = maa_gpio_init(13);
+ gpio = mraa_gpio_init(13);
}
- fprintf(stdout, "Welcome to libmaa\n Version: %s\n Running on %d",
- maa_get_version(), board_name);
+ fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %d",
+ mraa_get_version(), board_name);
- maa_gpio_dir(gpio, MAA_GPIO_OUT);
+ mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
for (;;) {
ledstate = !ledstate;
- maa_gpio_write(gpio, !ledstate);
+ mraa_gpio_write(gpio, !ledstate);
sleep(1);
}
*/
//! [Interesting]
-#include "maa.hpp"
+#include "mraa.hpp"
int main ()
{
uint16_t adc_value;
- maa::Aio* a0;
+ mraa::Aio* a0;
- a0 = new maa::Aio(0);
+ a0 = new mraa::Aio(0);
if (a0 == NULL) {
- return MAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_UNSPECIFIED;
}
for(;;) {
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
//! [Interesting]
#include <stdlib.h>
#include <unistd.h>
-#include "maa.hpp"
+#include "mraa.hpp"
#define DEFAULT_IOPIN 8
static int iopin;
signal(SIGINT, sig_handler);
//! [Interesting]
- maa::Gpio* gpio = new maa::Gpio(iopin);
+ mraa::Gpio* gpio = new mraa::Gpio(iopin);
if (gpio == NULL) {
- return MAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_UNSPECIFIED;
}
- int response = gpio->dir(maa::DIR_OUT);
- if (response != MAA_SUCCESS)
- maa_result_print((maa_result_t) MAA_SUCCESS);
+ int response = gpio->dir(mraa::DIR_OUT);
+ if (response != MRAA_SUCCESS)
+ mraa_result_print((mraa_result_t) MRAA_SUCCESS);
while (running == 0) {
response = gpio->write(1);
include_directories(${PROJECT_SOURCE_DIR}/api)
-target_link_libraries (AioA0 maa stdc++)
-target_link_libraries (blink-io-cpp maa stdc++)
-target_link_libraries (Pwm3-cycle maa stdc++)
-target_link_libraries (I2c-compass maa stdc++ m)
-target_link_libraries (Spi-pot maa stdc++)
+target_link_libraries (AioA0 mraa stdc++)
+target_link_libraries (blink-io-cpp mraa stdc++)
+target_link_libraries (Pwm3-cycle mraa stdc++)
+target_link_libraries (I2c-compass mraa stdc++ m)
+target_link_libraries (Spi-pot mraa stdc++)
#include <unistd.h>
#include <signal.h>
-#include "maa.hpp"
+#include "mraa.hpp"
#include "math.h"
#define MAX_BUFFER_LENGTH 6
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
//! [Interesting]
- maa::I2c* i2c;
- i2c = new maa::I2c(0);
+ mraa::I2c* i2c;
+ i2c = new mraa::I2c(0);
i2c->address(HMC5883L_I2C_ADDR);
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
}
delete i2c;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
#include <unistd.h>
#include <signal.h>
-#include "maa.hpp"
+#include "mraa.hpp"
int running = 0;
{
signal(SIGINT, sig_handler);
//! [Interesting]
- maa::Pwm* pwm;
+ mraa::Pwm* pwm;
- pwm = new maa::Pwm(3);
+ pwm = new mraa::Pwm(3);
if (pwm == NULL) {
- return MAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_UNSPECIFIED;
}
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
delete pwm;
//! [Interesting]
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
#include <signal.h>
#include <stdint.h>
-#include "maa.hpp"
+#include "mraa.hpp"
int running = 0;
signal(SIGINT, sig_handler);
//! [Interesting]
- maa::Spi* spi;
+ mraa::Spi* spi;
- spi = new maa::Spi(0);
+ spi = new mraa::Spi(0);
uint8_t data[] = {0x00, 100};
uint8_t *recv;
delete spi;
//! [Interesting]
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
#include <unistd.h>
-#include "maa.h"
+#include "mraa.h"
int
main ()
{
- maa_init();
+ mraa_init();
//! [Interesting]
- maa_pwm_context pwm;
- pwm = maa_pwm_init(3);
+ mraa_pwm_context pwm;
+ pwm = mraa_pwm_init(3);
if (pwm == NULL) {
return 1;
}
- maa_pwm_period_us(pwm, 200);
- maa_pwm_enable(pwm, 1);
+ mraa_pwm_period_us(pwm, 200);
+ mraa_pwm_enable(pwm, 1);
float value = 0.0f;
while (1) {
value = value + 0.01f;
- maa_pwm_write(pwm, value);
+ mraa_pwm_write(pwm, value);
usleep(50000);
if (value >= 1.0f) {
value = 0.0f;
}
- float output = maa_pwm_read(pwm);
+ float output = mraa_pwm_read(pwm);
}
//! [Interesting]
return 0;
#include "stdio.h"
#include "unistd.h"
-#include "maa.h"
+#include "mraa.h"
int
main(int argc, char **argv)
{
- maa_init();
- fprintf(stdout, "MAA Version: %s\nStarting Read on IO6\n",
- maa_get_version());
+ mraa_init();
+ fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6\n",
+ mraa_get_version());
//! [Interesting]
- maa_gpio_context gpio;
+ mraa_gpio_context gpio;
- gpio = maa_gpio_init(6);
+ gpio = mraa_gpio_init(6);
- maa_gpio_dir(gpio, MAA_GPIO_IN);
+ mraa_gpio_dir(gpio, MRAA_GPIO_IN);
for (;;) {
- fprintf(stdout, "Gpio is %d\n", maa_gpio_read(gpio));
+ fprintf(stdout, "Gpio is %d\n", mraa_gpio_read(gpio));
sleep(1);
}
- maa_gpio_close(gpio);
+ mraa_gpio_close(gpio);
//! [Interesting]
return 0;
#include "stdio.h"
//! [Interesting]
-#include "maa.h"
+#include "mraa.h"
int
main(int argc, char **argv)
{
- fprintf(stdout, "hello maa\n Version: %s\n", maa_get_version());
+ fprintf(stdout, "hello mraa\n Version: %s\n", mraa_get_version());
return 0;
}
//! [Interesting]
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "maa.h"
+#include "mraa.h"
#include "math.h"
#define MAX_BUFFER_LENGTH 6
int
main(int argc, char **argv)
{
- maa_init();
+ mraa_init();
float direction = 0;
int16_t x = 0, y = 0, z = 0;
char rx_tx_buf[MAX_BUFFER_LENGTH];
//! [Interesting]
- maa_i2c_context i2c;
- i2c = maa_i2c_init(0);
+ mraa_i2c_context i2c;
+ i2c = mraa_i2c_init(0);
- maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
+ mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
rx_tx_buf[1] = GA_1_3_REG;
- maa_i2c_write(i2c, rx_tx_buf, 2);
+ mraa_i2c_write(i2c, rx_tx_buf, 2);
//! [Interesting]
- maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
+ mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
rx_tx_buf[0] = HMC5883L_MODE_REG;
rx_tx_buf[1] = HMC5883L_CONT_MODE;
- maa_i2c_write(i2c, rx_tx_buf, 2);
+ mraa_i2c_write(i2c, rx_tx_buf, 2);
for(;;) {
- maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
- maa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
+ mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
+ mraa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
- maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
- maa_i2c_read(i2c, rx_tx_buf, DATA_REG_SIZE);
+ mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
+ mraa_i2c_read(i2c, rx_tx_buf, DATA_REG_SIZE);
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_X_LSB_REG] ;
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Z_LSB_REG] ;
#include <unistd.h>
-#include "maa.h"
+#include "mraa.h"
static volatile int counter = 0;
static volatile int oldcounter = 0;
int main ()
{
- maa_init();
- maa_gpio_context x;
+ mraa_init();
+ mraa_gpio_context x;
- x = maa_gpio_init(6);
+ x = mraa_gpio_init(6);
if (x == NULL) {
return 1;
}
- maa_gpio_dir(x, MAA_GPIO_IN);
+ mraa_gpio_dir(x, MRAA_GPIO_IN);
- gpio_edge_t edge = MAA_GPIO_EDGE_BOTH;
+ gpio_edge_t edge = MRAA_GPIO_EDGE_BOTH;
- maa_gpio_isr(x, edge, &interrupt, NULL);
+ mraa_gpio_isr(x, edge, &interrupt, NULL);
for(;;) {
if(counter != oldcounter) {
sleep(1);
}
- maa_gpio_close(x);
+ mraa_gpio_close(x);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-var m = require("maajs")
-console.log("maa version: " + m.getVersion());
+var m = require("mraajs")
+console.log("mraa version: " + m.getVersion());
var x = new m.Gpio(8)
x.dir(m.DIR_OUT)
#include "stdio.h"
#include <unistd.h>
-#include "maa.h"
+#include "mraa.h"
int
main(int argc, char **argv)
{
//! [Interesting]
- fprintf(stdout, "hello maa\n Version: %s\n", maa_get_version());
- maa_gpio_context gpio;
- gpio = maa_gpio_init(2);
+ fprintf(stdout, "hello mraa\n Version: %s\n", mraa_get_version());
+ mraa_gpio_context gpio;
+ gpio = mraa_gpio_init(2);
- maa_gpio_use_mmaped(gpio, 1);
+ mraa_gpio_use_mmaped(gpio, 1);
for (;;) {
- maa_gpio_write(gpio , 1);
+ mraa_gpio_write(gpio , 1);
usleep(50000);
- maa_gpio_write(gpio, 0);
+ mraa_gpio_write(gpio, 0);
usleep(50000);
}
//! [Interesting]
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-import pymaa as maa
+import pymraa as mraa
-print (maa.getVersion())
-x = maa.Aio(0)
+print (mraa.getVersion())
+x = mraa.Aio(0)
print (x.read())
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-import pymaa as maa
+import pymraa as mraa
import time
-x = maa.Gpio(8)
-x.dir(maa.DIR_OUT)
+x = mraa.Gpio(8)
+x.dir(mraa.DIR_OUT)
while True:
x.write(1)
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-import pymaa as maa
+import pymraa as mraa
import time
-x = maa.PWM(0,3)
+x = mraa.PWM(0,3)
x.enable(1);
x.period_us(20)
value= 0.0
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-import pymaa
+import pymraa
-print (pymaa.getVersion())
-x = pymaa.Gpio(13)
-x.dir(pymaa.DIR_OUT)
+print (pymraa.getVersion())
+x = pymraa.Gpio(13)
+x.dir(pymraa.DIR_OUT)
x.write(1)
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
-import pymaa as maa
+import pymraa as mraa
def test(args):
print("wooo")
-x = maa.Gpio(6)
-x.dir(maa.DIR_IN)
-x.isr(maa.EDGE_BOTH, test, test)
+x = mraa.Gpio(6)
+x.dir(mraa.DIR_IN)
+x.isr(mraa.EDGE_BOTH, test, test)
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
-import pymaa as maa
+import pymraa as mraa
# This example will change the LCD backlight on the Grove-LCD RGB backlight
# to a nice shade of purple
-x = maa.I2c(0)
+x = mraa.I2c(0)
x.address(0x62)
x.writeReg(0,0)
x.writeReg(1,0)
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "maa.h"
+#include "mraa.h"
#include <unistd.h>
#include <stdint.h>
int
main(int argc, char **argv)
{
- maa_init();
+ mraa_init();
//! [Interesting]
- maa_spi_context spi;
- spi = maa_spi_init(0);
+ mraa_spi_context spi;
+ spi = mraa_spi_init(0);
unsigned int response = 0;
printf("Hello, SPI initialised\n");
uint8_t data[] = {0x00, 100};
int i;
for (i = 90; i < 130; i++) {
data[1] = i;
- recv = maa_spi_write_buf(spi, data, 2);
+ recv = mraa_spi_write_buf(spi, data, 2);
printf("Writing -%i",i);
printf("RECIVED-%i-%i\n",recv[0],recv[1]);
usleep(100000);
}
for (i = 130; i > 90; i--) {
data[1] = i;
- recv = maa_spi_write_buf(spi, data, 2);
+ recv = mraa_spi_write_buf(spi, data, 2);
printf("Writing -%i",i);
printf("RECIVED-%i-%i\n",recv[0],recv[1]);
usleep(100000);
#pragma once
-#include "maa.h"
+#include "mraa.h"
-#define MAA_INTEL_GALILEO_REV_D_PINCOUNT 25
+#define MRAA_INTEL_GALILEO_REV_D_PINCOUNT 25
-maa_board_t*
-maa_intel_galileo_rev_d();
+mraa_board_t*
+mraa_intel_galileo_rev_d();
#pragma once
-#define MAA_INTEL_GALILEO_GEN_2_PINCOUNT 25
+#define MRAA_INTEL_GALILEO_GEN_2_PINCOUNT 25
-maa_board_t*
-maa_intel_galileo_gen2();
+mraa_board_t*
+mraa_intel_galileo_gen2();
* @param pin the pin as read from the board surface. i.e IO3 would be 3/
* @return the pin as found in the pinmap
*/
-unsigned int maa_setup_gpio(int pin);
+unsigned int mraa_setup_gpio(int pin);
/** Setup Analog interface
*
* @param pin the pin as read from the board surface. i.e A3 would be 3/
* @return the pin as found in the pinmap
*/
-unsigned int maa_setup_aio(int pin);
+unsigned int mraa_setup_aio(int pin);
/** Setup i2c interface, sets up multiplexer on device.
*
* @return unsigned int if using /dev/i2c-2 returned would be 2
*/
-unsigned int maa_setup_i2c(int bus);
+unsigned int mraa_setup_i2c(int bus);
/** Setup spi interface, sets up multiplexer on device.
*
* @return spi bus type
*/
-maa_spi_bus_t* maa_setup_spi(int bus);
+mraa_spi_bus_t* mraa_setup_spi(int bus);
/** Setup PWM
*
* @param pin the pin as read from the board surface.
* @return the pwm pin_info_t of that IO pin
*/
-maa_pin_t* maa_setup_pwm(int pin);
+mraa_pin_t* mraa_setup_pwm(int pin);
/** Setup gpio mux to go straight to SoC, galileo.
*
* @param pin physical pin to use
- * @return maa_mmap_pin_t
+ * @return mraa_mmap_pin_t
*/
-maa_mmap_pin_t* maa_setup_mmap_gpio(int pin);
+mraa_mmap_pin_t* mraa_setup_mmap_gpio(int pin);
/** Swap Directional mode.
*
* @param pin physical pin to operate on
* @return out direction to setup. 1 for output 0 for input
*/
-maa_result_t maa_swap_complex_gpio(int pin, int out);
+mraa_result_t mraa_swap_complex_gpio(int pin, int out);
include_directories(
${PROJECT_SOURCE_DIR}/api
- ${PROJECT_SOURCE_DIR}/api/maa
+ ${PROJECT_SOURCE_DIR}/api/mraa
${PROJECT_SOURCE_DIR}/include
)
-set (maa_LIB_SRCS
- ${PROJECT_SOURCE_DIR}/src/maa.c
+set (mraa_LIB_SRCS
+ ${PROJECT_SOURCE_DIR}/src/mraa.c
${PROJECT_SOURCE_DIR}/src/gpio/gpio.c
${PROJECT_SOURCE_DIR}/src/i2c/i2c.c
${PROJECT_SOURCE_DIR}/src/i2c/smbus.c
${CMAKE_CURRENT_BINARY_DIR}/version.c
)
-set (maa_LIB_GLOB_HEADERS
- ${PROJECT_SOURCE_DIR}/api/maa.h
- ${PROJECT_SOURCE_DIR}/api/maa.hpp
+set (mraa_LIB_GLOB_HEADERS
+ ${PROJECT_SOURCE_DIR}/api/mraa.h
+ ${PROJECT_SOURCE_DIR}/api/mraa.hpp
)
-add_library (maa SHARED ${maa_LIB_SRCS})
-target_link_libraries (maa ${CMAKE_THREAD_LIBS_INIT})
+add_library (mraa SHARED ${mraa_LIB_SRCS})
+target_link_libraries (mraa ${CMAKE_THREAD_LIBS_INIT})
set_target_properties(
- maa
+ mraa
PROPERTIES
- SOVERSION ${maa_VERSION_MAJOR}
- VERSION ${maa_VERSION_STRING}
+ SOVERSION ${mraa_VERSION_MAJOR}
+ VERSION ${mraa_VERSION_STRING}
)
-install (FILES ${maa_LIB_GLOB_HEADERS} DESTINATION include/)
-install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/maa/ DESTINATION include/maa)
+install (FILES ${mraa_LIB_GLOB_HEADERS} DESTINATION include/)
+install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/mraa/ DESTINATION include/mraa)
-macro (maa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
+macro (mraa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
-endmacro (maa_CREATE_INSTALL_PKGCONFIG)
-maa_create_install_pkgconfig (maa.pc lib${LIB_SUFFIX}/pkgconfig)
+endmacro (mraa_CREATE_INSTALL_PKGCONFIG)
+mraa_create_install_pkgconfig (mraa.pc lib${LIB_SUFFIX}/pkgconfig)
-install (TARGETS maa DESTINATION lib)
+install (TARGETS mraa DESTINATION lib)
if (DOXYGEN_FOUND)
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
foreach (_file ${DOCCLASSES})
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
- ${CMAKE_BINARY_DIR}/xml/classmaa_1_1_${_file}.xml
+ ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
- DEPENDS ${CMAKE_BINARY_DIR}/xml/classmaa_1_1_${_file}.xml
+ DEPENDS ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
)
add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i)
add_dependencies (${_file}class_doc_i doc)
find_package (SWIG)
if (SWIG_FOUND)
include (${SWIG_USE_FILE})
- set_source_files_properties (maa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
+ set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
if (BUILDSWIGPYTHON)
add_subdirectory (python)
#include <errno.h>
#include "aio.h"
-#include "maa_internal.h"
+#include "mraa_internal.h"
struct _aio {
unsigned int channel;
int adc_in_fp;
};
-static maa_result_t aio_get_valid_fp(maa_aio_context dev)
+static mraa_result_t aio_get_valid_fp(mraa_aio_context dev)
{
char file_path[64]= "";
dev->adc_in_fp = open(file_path, O_RDONLY);
if (dev->adc_in_fp == -1) {
fprintf(stderr, "Failed to open Analog input raw file %s for "
- "reading!\n", file_path); return( MAA_ERROR_INVALID_RESOURCE);
+ "reading!\n", file_path); return( MRAA_ERROR_INVALID_RESOURCE);
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
/** Initialise an Analog input, connected to the specified channel
*
* @param aio_channel Analog input channel to read
*
- * @returns pointer to maa_aio_context structure after initialisation of
+ * @returns pointer to mraa_aio_context structure after initialisation of
* Analog input pin connected to the device successfully, else returns NULL.
*/
-maa_aio_context maa_aio_init(unsigned int aio_channel)
+mraa_aio_context mraa_aio_init(unsigned int aio_channel)
{
- int checked_pin = maa_setup_aio(aio_channel);
+ int checked_pin = mraa_setup_aio(aio_channel);
if (checked_pin < 0) {
switch(checked_pin) {
case -1:
}
//Create ADC device connected to specified channel
- maa_aio_context dev = malloc(sizeof(struct _aio));
+ mraa_aio_context dev = malloc(sizeof(struct _aio));
if (dev == NULL) {
fprintf(stderr, "Insufficient memory for specified Analog input channel "
"%d\n", aio_channel);
dev->channel = checked_pin;
//Open valid analog input file and get the pointer.
- if (MAA_SUCCESS != aio_get_valid_fp(dev)) {
+ if (MRAA_SUCCESS != aio_get_valid_fp(dev)) {
free(dev);
return NULL;
}
/** Read the input voltage, represented as an unsigned short in the range [0x0,
* 0xFFFF]
*
- * @param pointer to maa_aio_context structure initialised by
- * maa_aio_init()
+ * @param pointer to mraa_aio_context structure initialised by
+ * mraa_aio_init()
*
* @returns
* unsigned 16 bit int representing the current input voltage, normalised to
* a 16-bit value
*/
-uint16_t maa_aio_read(maa_aio_context dev)
+uint16_t mraa_aio_read(mraa_aio_context dev)
{
char buffer[16];
unsigned int shifter_value = 0;
*
* @param dev - the analog input context
*
- * @return maa result type.
+ * @return mraa result type.
*/
-maa_result_t maa_aio_close(maa_aio_context dev)
+mraa_result_t mraa_aio_close(mraa_aio_context dev)
{
if (NULL != dev)
free(dev);
- return(MAA_SUCCESS);
+ return(MRAA_SUCCESS);
}
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "gpio.h"
-#include "maa_internal.h"
+#include "mraa_internal.h"
#include <stdlib.h>
#include <fcntl.h>
void *isr_args; /**< args return when interupt service request triggered */
pthread_t thread_id; /**< the isr handler thread id */
int isr_value_fp; /**< the isr file pointer on the value */
- maa_boolean_t owner; /**< If this context originally exported the pin */
- maa_boolean_t mmap;
+ mraa_boolean_t owner; /**< If this context originally exported the pin */
+ mraa_boolean_t mmap;
void *reg;
unsigned int reg_sz;
unsigned int reg_bit_pos;
/*@}*/
};
-static maa_result_t
-maa_gpio_get_valfp(maa_gpio_context dev)
+static mraa_result_t
+mraa_gpio_get_valfp(mraa_gpio_context dev)
{
char bu[MAX_SIZE];
sprintf(bu, SYSFS_CLASS_GPIO "/gpio%d/value", dev->pin);
dev->value_fp = open(bu, O_RDWR);
if (dev->value_fp == -1) {
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_gpio_context
-maa_gpio_init(int pin)
+mraa_gpio_context
+mraa_gpio_init(int pin)
{
- int pinm = maa_setup_gpio(pin);
+ int pinm = mraa_setup_gpio(pin);
if (pinm < 0)
return NULL;
- maa_gpio_context r = maa_gpio_init_raw(pinm);
+ mraa_gpio_context r = mraa_gpio_init_raw(pinm);
r->phy_pin = pin;
return r;
}
-maa_gpio_context
-maa_gpio_init_raw(int pin)
+mraa_gpio_context
+mraa_gpio_init_raw(int pin)
{
if (pin < 0)
return NULL;
char bu[MAX_SIZE];
int length;
- maa_gpio_context dev = (maa_gpio_context) malloc(sizeof(struct _gpio));
+ mraa_gpio_context dev = (mraa_gpio_context) malloc(sizeof(struct _gpio));
memset(dev, 0, sizeof(struct _gpio));
dev->value_fp = -1;
dev->isr_value_fp = -1;
return dev;
}
-static maa_result_t
-maa_gpio_write_register(maa_gpio_context dev,int value)
+static mraa_result_t
+mraa_gpio_write_register(mraa_gpio_context dev,int value)
{
if (value == 1) {
*((unsigned *)dev->reg) |= (1<<dev->reg_bit_pos);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
*((unsigned *)dev->reg) &= ~(1<<dev->reg_bit_pos);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-static maa_result_t
-maa_gpio_wait_interrupt(int fd)
+static mraa_result_t
+mraa_gpio_wait_interrupt(int fd)
{
unsigned char c;
struct pollfd pfd;
read (fd, &c, 1);
if (fd <= 0) {
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
// Wait for it forever or until pthread_cancel
// do a final read to clear interupt
read (fd, &c, 1);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
static void*
-maa_gpio_interrupt_handler(void* arg)
+mraa_gpio_interrupt_handler(void* arg)
{
- maa_gpio_context dev = (maa_gpio_context) arg;
- maa_result_t ret;
+ mraa_gpio_context dev = (mraa_gpio_context) arg;
+ mraa_result_t ret;
// open gpio value with open(3)
char bu[MAX_SIZE];
dev->isr_value_fp = open(bu, O_RDONLY);
for (;;) {
- ret = maa_gpio_wait_interrupt(dev->isr_value_fp);
- if (ret == MAA_SUCCESS) {
+ ret = mraa_gpio_wait_interrupt(dev->isr_value_fp);
+ if (ret == MRAA_SUCCESS) {
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
#ifdef SWIGPYTHON
// In order to call a python object (all python functions are objects) we
}
}
-maa_result_t
-maa_gpio_edge_mode(maa_gpio_context dev, gpio_edge_t mode)
+mraa_result_t
+mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode)
{
if (dev->value_fp != -1) {
close(dev->value_fp);
int edge = open(filepath, O_RDWR);
if (edge == -1) {
fprintf(stderr, "Failed to open edge for writing!\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char bu[MAX_SIZE];
int length;
switch(mode) {
- case MAA_GPIO_EDGE_NONE:
+ case MRAA_GPIO_EDGE_NONE:
length = snprintf(bu, sizeof(bu), "none");
break;
- case MAA_GPIO_EDGE_BOTH:
+ case MRAA_GPIO_EDGE_BOTH:
length = snprintf(bu, sizeof(bu), "both");
break;
- case MAA_GPIO_EDGE_RISING:
+ case MRAA_GPIO_EDGE_RISING:
length = snprintf(bu, sizeof(bu), "rising");
break;
- case MAA_GPIO_EDGE_FALLING:
+ case MRAA_GPIO_EDGE_FALLING:
length = snprintf(bu, sizeof(bu), "falling");
break;
default:
close(edge);
- return MAA_ERROR_FEATURE_NOT_IMPLEMENTED;
+ return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
if (write(edge, bu, length*sizeof(char)) == -1) {
fprintf(stderr, "Failed to write to edge\n");
close(edge);
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(edge);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_gpio_isr(maa_gpio_context dev, gpio_edge_t mode, void (*fptr)(void *), void * args)
+mraa_result_t
+mraa_gpio_isr(mraa_gpio_context dev, gpio_edge_t mode, void (*fptr)(void *), void * args)
{
- // we only allow one isr per maa_gpio_context
+ // we only allow one isr per mraa_gpio_context
if (dev->thread_id != 0) {
- return MAA_ERROR_NO_RESOURCES;
+ return MRAA_ERROR_NO_RESOURCES;
}
- if (MAA_SUCCESS != maa_gpio_edge_mode(dev, mode)) {
- return MAA_ERROR_UNSPECIFIED;
+ if (MRAA_SUCCESS != mraa_gpio_edge_mode(dev, mode)) {
+ return MRAA_ERROR_UNSPECIFIED;
}
dev->isr = fptr;
dev->isr_args = args;
- pthread_create (&dev->thread_id, NULL, maa_gpio_interrupt_handler, (void *) dev);
+ pthread_create (&dev->thread_id, NULL, mraa_gpio_interrupt_handler, (void *) dev);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_gpio_isr_exit(maa_gpio_context dev)
+mraa_result_t
+mraa_gpio_isr_exit(mraa_gpio_context dev)
{
- maa_result_t ret = MAA_SUCCESS;
+ mraa_result_t ret = MRAA_SUCCESS;
// wasting our time, there is no isr to exit from
if (dev->thread_id == 0 && dev->isr_value_fp == -1) {
}
// stop isr being useful
- ret = maa_gpio_edge_mode(dev, MAA_GPIO_EDGE_NONE);
+ ret = mraa_gpio_edge_mode(dev, MRAA_GPIO_EDGE_NONE);
if ((dev->thread_id != 0) &&
(pthread_cancel(dev->thread_id) != 0)) {
- ret = MAA_ERROR_INVALID_HANDLE;
+ ret = MRAA_ERROR_INVALID_HANDLE;
}
// close the filehandle in case it's still open
if (dev->isr_value_fp != -1) {
if (close(dev->isr_value_fp) != 0) {
- ret = MAA_ERROR_INVALID_PARAMETER;
+ ret = MRAA_ERROR_INVALID_PARAMETER;
}
}
return ret;
}
-maa_result_t
-maa_gpio_mode(maa_gpio_context dev, gpio_mode_t mode)
+mraa_result_t
+mraa_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode)
{
if (dev->value_fp != -1) {
close(dev->value_fp);
int drive = open(filepath, O_WRONLY);
if (drive == -1) {
fprintf(stderr, "Failed to open drive for writing!\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char bu[MAX_SIZE];
int length;
switch(mode) {
- case MAA_GPIO_STRONG:
+ case MRAA_GPIO_STRONG:
length = snprintf(bu, sizeof(bu), "strong");
break;
- case MAA_GPIO_PULLUP:
+ case MRAA_GPIO_PULLUP:
length = snprintf(bu, sizeof(bu), "pullup");
break;
- case MAA_GPIO_PULLDOWN:
+ case MRAA_GPIO_PULLDOWN:
length = snprintf(bu, sizeof(bu), "pulldown");
break;
- case MAA_GPIO_HIZ:
+ case MRAA_GPIO_HIZ:
length = snprintf(bu, sizeof(bu), "hiz");
break;
default:
close(drive);
- return MAA_ERROR_FEATURE_NOT_IMPLEMENTED;
+ return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
if (write(drive, bu, length*sizeof(char)) == -1) {
fprintf(stderr, "Failed to write to drive mode!\n");
close(drive);
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(drive);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_gpio_dir(maa_gpio_context dev, gpio_dir_t dir)
+mraa_result_t
+mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir)
{
if (dev == NULL) {
- return MAA_ERROR_INVALID_HANDLE;
+ return MRAA_ERROR_INVALID_HANDLE;
}
if (dev->value_fp != -1) {
close(dev->value_fp);
if (direction == -1) {
fprintf(stderr, "Failed to open direction for writing!\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char bu[MAX_SIZE];
int length;
int out_switch = 0;
switch(dir) {
- case MAA_GPIO_OUT:
+ case MRAA_GPIO_OUT:
length = snprintf(bu, sizeof(bu), "out");
out_switch = 1;
break;
- case MAA_GPIO_IN:
+ case MRAA_GPIO_IN:
length = snprintf(bu, sizeof(bu), "in");
break;
default:
close(direction);
- return MAA_ERROR_FEATURE_NOT_IMPLEMENTED;
+ return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
if (dev->phy_pin >= 0) {
- maa_result_t swap_res = maa_swap_complex_gpio(dev->phy_pin, out_switch);
- if (swap_res != MAA_SUCCESS)
+ mraa_result_t swap_res = mraa_swap_complex_gpio(dev->phy_pin, out_switch);
+ if (swap_res != MRAA_SUCCESS)
return swap_res;
}
if (write(direction, bu, length*sizeof(char)) == -1) {
close(direction);
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(direction);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
int
-maa_gpio_read(maa_gpio_context dev)
+mraa_gpio_read(mraa_gpio_context dev)
{
if (dev->value_fp == -1) {
- if (maa_gpio_get_valfp(dev) != MAA_SUCCESS) {
+ if (mraa_gpio_get_valfp(dev) != MRAA_SUCCESS) {
fprintf(stderr, "Failed to get value file pointer\n");
}
}
return ret;
}
-maa_result_t
-maa_gpio_write(maa_gpio_context dev, int value)
+mraa_result_t
+mraa_gpio_write(mraa_gpio_context dev, int value)
{
if (dev->mmap == 1)
- return maa_gpio_write_register(dev,value);
+ return mraa_gpio_write_register(dev,value);
if (dev->value_fp == -1) {
- maa_gpio_get_valfp(dev);
+ mraa_gpio_get_valfp(dev);
}
if (lseek(dev->value_fp, 0, SEEK_SET) == -1) {
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char bu[MAX_SIZE];
int length = snprintf(bu, sizeof(bu), "%d", value);
if (write(dev->value_fp, bu, length*sizeof(char)) == -1) {
- return MAA_ERROR_INVALID_HANDLE;
+ return MRAA_ERROR_INVALID_HANDLE;
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-static maa_result_t
-maa_gpio_unexport_force(maa_gpio_context dev)
+static mraa_result_t
+mraa_gpio_unexport_force(mraa_gpio_context dev)
{
int unexport = open(SYSFS_CLASS_GPIO "/unexport", O_WRONLY);
if (unexport == -1) {
fprintf(stderr, "Failed to open unexport for writing!\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char bu[MAX_SIZE];
if (write(unexport, bu, length*sizeof(char)) == -1) {
fprintf(stderr, "Failed to write to unexport\n");
close(unexport);
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(unexport);
- maa_gpio_isr_exit(dev);
- return MAA_SUCCESS;
+ mraa_gpio_isr_exit(dev);
+ return MRAA_SUCCESS;
}
-static maa_result_t
-maa_gpio_unexport(maa_gpio_context dev)
+static mraa_result_t
+mraa_gpio_unexport(mraa_gpio_context dev)
{
if(dev->owner) {
- return maa_gpio_unexport_force(dev);
+ return mraa_gpio_unexport_force(dev);
}
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
-maa_result_t
-maa_gpio_close(maa_gpio_context dev)
+mraa_result_t
+mraa_gpio_close(mraa_gpio_context dev)
{
if (dev->value_fp != -1) {
close(dev->value_fp);
}
- maa_gpio_unexport(dev);
+ mraa_gpio_unexport(dev);
free(dev);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_gpio_owner(maa_gpio_context dev, maa_boolean_t own)
+mraa_result_t
+mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t own)
{
if (dev == NULL)
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
dev->owner = own;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_gpio_use_mmaped(maa_gpio_context dev, maa_boolean_t mmap_en)
+mraa_result_t
+mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap_en)
{
if (dev == NULL) {
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
- if (maa_pin_mode_test(dev->phy_pin, MAA_PIN_FAST_GPIO) == 0)
- return MAA_ERROR_NO_RESOURCES;
+ if (mraa_pin_mode_test(dev->phy_pin, MRAA_PIN_FAST_GPIO) == 0)
+ return MRAA_ERROR_NO_RESOURCES;
- maa_mmap_pin_t *mmp = maa_setup_mmap_gpio(dev->phy_pin);
+ mraa_mmap_pin_t *mmp = mraa_setup_mmap_gpio(dev->phy_pin);
if (mmp == NULL)
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
if (mmap_en == 1) {
if (dev->mmap == 0) {
fd = open(mmp->mem_dev, O_RDWR);
if (fd < 1) {
fprintf(stderr, "Unable to open memory device\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
dev->reg_sz = mmp->mem_sz;
dev->reg = mmap(NULL, dev->reg_sz, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
dev->reg_bit_pos = mmp->bit_pos;
dev->mmap = 1;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
- return MAA_ERROR_INVALID_PARAMETER;
+ return MRAA_ERROR_INVALID_PARAMETER;
}
if (mmap_en == 0) {
munmap(dev->reg, dev->reg_sz);
dev->mmap = 0;
}
- return MAA_ERROR_INVALID_PARAMETER;
+ return MRAA_ERROR_INVALID_PARAMETER;
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
#include "i2c.h"
#include "smbus.h"
-#include "maa_internal.h"
+#include "mraa_internal.h"
struct _i2c {
/*@{*/
/*@}*/
};
-maa_i2c_context
-maa_i2c_init(int bus)
+mraa_i2c_context
+mraa_i2c_init(int bus)
{
- int checked_pin = maa_setup_i2c(bus);
+ int checked_pin = mraa_setup_i2c(bus);
if (checked_pin < 0) {
switch(checked_pin) {
case -1:
default: return NULL;
}
}
- return maa_i2c_init_raw((unsigned int) checked_pin);
+ return mraa_i2c_init_raw((unsigned int) checked_pin);
}
-maa_i2c_context
-maa_i2c_init_raw(unsigned int bus)
+mraa_i2c_context
+mraa_i2c_init_raw(unsigned int bus)
{
- maa_i2c_context dev = (maa_i2c_context) malloc(sizeof(struct _i2c));
+ mraa_i2c_context dev = (mraa_i2c_context) malloc(sizeof(struct _i2c));
if (dev == NULL)
return NULL;
return dev;
}
-maa_result_t
-maa_i2c_frequency(maa_i2c_context dev, int hz)
+mraa_result_t
+mraa_i2c_frequency(mraa_i2c_context dev, int hz)
{
dev->hz = hz;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
int
-maa_i2c_read(maa_i2c_context dev, uint8_t* data, int length)
+mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
{
- // this is the read(3) syscall not maa_i2c_read()
+ // this is the read(3) syscall not mraa_i2c_read()
if (read(dev->fh, data, length) == length) {
return length;
}
}
uint8_t
-maa_i2c_read_byte(maa_i2c_context dev)
+mraa_i2c_read_byte(mraa_i2c_context dev)
{
uint8_t byte = i2c_smbus_read_byte(dev->fh);
if (byte < 0) {
return byte;
}
-maa_result_t
-maa_i2c_write(maa_i2c_context dev, const uint8_t* data, int length)
+mraa_result_t
+mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length)
{
if (i2c_smbus_write_i2c_block_data(dev->fh, data[0], length-1, (uint8_t*) data+1) < 0) {
fprintf(stderr, "Failed to write to i2c\n");
- return MAA_ERROR_INVALID_HANDLE;
+ return MRAA_ERROR_INVALID_HANDLE;
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_i2c_write_byte(maa_i2c_context dev, const uint8_t data)
+mraa_result_t
+mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data)
{
if (i2c_smbus_write_byte(dev->fh, data) < 0) {
fprintf(stderr, "Failed to write to i2c\n");
- return MAA_ERROR_INVALID_HANDLE;
+ return MRAA_ERROR_INVALID_HANDLE;
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_i2c_address(maa_i2c_context dev, int addr)
+mraa_result_t
+mraa_i2c_address(mraa_i2c_context dev, int addr)
{
dev->addr = addr;
if (ioctl(dev->fh, I2C_SLAVE_FORCE, addr) < 0) {
fprintf(stderr, "Failed to set slave address %d\n", addr);
- return MAA_ERROR_INVALID_HANDLE;
+ return MRAA_ERROR_INVALID_HANDLE;
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_i2c_stop(maa_i2c_context dev)
+mraa_result_t
+mraa_i2c_stop(mraa_i2c_context dev)
{
free(dev);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
#include "common.h"
#include "intel_galileo_rev_d.h"
-maa_board_t*
-maa_intel_galileo_rev_d()
+mraa_board_t*
+mraa_intel_galileo_rev_d()
{
- maa_board_t* b = (maa_board_t*) malloc(sizeof(maa_board_t));
+ mraa_board_t* b = (mraa_board_t*) malloc(sizeof(mraa_board_t));
if (b == NULL)
return NULL;
b->gpio_count = 14;
b->aio_count = 6;
- b->pins = (maa_pininfo_t*) malloc(sizeof(maa_pininfo_t)*MAA_INTEL_GALILEO_REV_D_PINCOUNT);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t)*MRAA_INTEL_GALILEO_REV_D_PINCOUNT);
//GPIO IO0 - IO10
strncpy(b->pins[0].name, "IO0", 8);
- b->pins[0].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[0].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[0].gpio.pinmap = 50;
b->pins[0].gpio.parent_id = 0;
b->pins[0].gpio.mux_total = 1;
b->pins[0].gpio.mux[0].value = 1;
strncpy(b->pins[1].name, "IO1", 8);
- b->pins[1].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[1].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[1].gpio.pinmap = 51;
b->pins[1].gpio.mux_total = 1;
b->pins[1].gpio.mux[0].pin = 41;
b->pins[1].gpio.mux[0].value = 1;
strncpy(b->pins[2].name, "IO2", 8);
- b->pins[2].capabilites = (maa_pincapabilities_t) {1,1,0,1,0,0,0};
+ b->pins[2].capabilites = (mraa_pincapabilities_t) {1,1,0,1,0,0,0};
b->pins[2].gpio.pinmap = 32;
b->pins[2].gpio.mux_total = 1;
b->pins[2].gpio.mux[0].pin = 31;
b->pins[2].mmap.bit_pos = 6;
strncpy(b->pins[3].name, "IO3", 8);
- b->pins[3].capabilites = (maa_pincapabilities_t) {1,1,1,1,0,0,0};
+ b->pins[3].capabilites = (mraa_pincapabilities_t) {1,1,1,1,0,0,0};
b->pins[3].gpio.pinmap = 18;
b->pins[3].gpio.mux_total = 1;
b->pins[3].gpio.mux[0].pin = 30;
strncpy(b->pins[4].name, "IO4", 8);
- b->pins[4].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[4].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[4].gpio.pinmap = 28;
b->pins[4].gpio.mux_total = 0;
strncpy(b->pins[5].name, "IO5", 8);
- b->pins[5].capabilites = (maa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[5].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
b->pins[5].gpio.pinmap = 17;
b->pins[5].gpio.mux_total = 0;
b->pins[5].pwm.pinmap = 5;
strncpy(b->pins[6].name, "IO6", 8);
b->pins[6].gpio.pinmap = 24;
- b->pins[6].capabilites = (maa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[6].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
b->pins[6].gpio.mux_total = 0;
b->pins[6].pwm.pinmap = 6;
b->pins[6].pwm.parent_id = 0;
b->pins[6].pwm.mux_total = 0;
strncpy(b->pins[7].name, "IO7", 8);
- b->pins[7].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[7].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[7].gpio.pinmap = 27;
b->pins[7].gpio.mux_total = 0;
strncpy(b->pins[8].name, "IO8", 8);
- b->pins[8].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[8].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[8].gpio.pinmap = 26;
b->pins[8].gpio.mux_total = 0;
strncpy(b->pins[9].name, "IO9", 8);
- b->pins[9].capabilites = (maa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[9].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
b->pins[9].gpio.pinmap = 19;
b->pins[9].gpio.mux_total = 0;
b->pins[9].pwm.pinmap = 1;
b->pins[9].pwm.mux_total = 0;
strncpy(b->pins[10].name, "IO10", 8);
- b->pins[10].capabilites = (maa_pincapabilities_t) {1,1,1,0,1,0,0};
+ b->pins[10].capabilites = (mraa_pincapabilities_t) {1,1,1,0,1,0,0};
b->pins[10].gpio.pinmap = 16;
b->pins[10].gpio.mux_total = 1;
b->pins[10].gpio.mux[0].pin = 42;
b->pins[10].spi.mux[0].value = 0;
strncpy(b->pins[11].name, "IO11", 8);
- b->pins[11].capabilites = (maa_pincapabilities_t) {1,1,1,0,1,0,0};
+ b->pins[11].capabilites = (mraa_pincapabilities_t) {1,1,1,0,1,0,0};
b->pins[11].gpio.pinmap = 25;
b->pins[11].gpio.mux_total = 1;
b->pins[11].gpio.mux[0].pin = 43;
b->pins[11].spi.mux[0].value = 0;
strncpy(b->pins[12].name, "IO12", 8);
- b->pins[12].capabilites = (maa_pincapabilities_t) {1,1,0,0,1,0,0};
+ b->pins[12].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0};
b->pins[12].gpio.pinmap = 38;
b->pins[12].gpio.mux_total = 1;
b->pins[12].gpio.mux[0].pin = 54;
b->pins[12].spi.mux[0].value = 0;
strncpy(b->pins[13].name, "IO13", 8);
- b->pins[13].capabilites = (maa_pincapabilities_t) {1,1,0,0,1,0,0};
+ b->pins[13].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0};
b->pins[13].gpio.pinmap = 39;
b->pins[13].gpio.mux_total = 1;
b->pins[13].gpio.mux[0].pin = 55;
b->pins[13].spi.mux[0].value = 0;
strncpy(b->pins[14].name, "A0", 8);
- b->pins[14].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,1};
+ b->pins[14].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1};
b->pins[14].gpio.pinmap = 44;
b->pins[14].gpio.mux_total = 1;
b->pins[14].gpio.mux[0].pin = 37;
b->pins[14].aio.mux[0].value = 0;
strncpy(b->pins[15].name, "A1", 8);
- b->pins[15].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,1};
+ b->pins[15].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1};
b->pins[15].gpio.pinmap = 45;
b->pins[15].gpio.mux_total = 1;
b->pins[15].gpio.mux[0].pin = 36;
b->pins[15].aio.mux[0].value = 0;
strncpy(b->pins[16].name, "A2", 8);
- b->pins[16].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,1};
+ b->pins[16].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1};
b->pins[16].gpio.pinmap = 46;
b->pins[16].gpio.mux_total = 1;
b->pins[16].gpio.mux[0].pin = 23;
b->pins[16].aio.mux[0].value = 0;
strncpy(b->pins[17].name, "A3", 8);
- b->pins[17].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,1};
+ b->pins[17].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1};
b->pins[17].gpio.pinmap = 47;
b->pins[17].gpio.mux_total = 1;
b->pins[17].gpio.mux[0].pin = 22;
b->pins[17].aio.mux[0].value = 0;
strncpy(b->pins[18].name, "A4", 8);
- b->pins[18].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,1,1};
+ b->pins[18].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,1};
b->pins[18].gpio.pinmap = 48;
b->pins[18].gpio.mux_total = 2;
b->pins[18].gpio.mux[0].pin = 29;
b->pins[18].aio.mux[1].value = 0;
strncpy(b->pins[19].name, "A5", 8);
- b->pins[19].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,1,1};
+ b->pins[19].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,1};
b->pins[19].gpio.pinmap = 49;
b->pins[19].gpio.mux_total = 2;
b->pins[19].gpio.mux[0].pin = 29;
#include "common.h"
#include "intel_galileo_rev_g.h"
-maa_board_t*
-maa_intel_galileo_gen2()
+mraa_board_t*
+mraa_intel_galileo_gen2()
{
- maa_board_t* b = (maa_board_t*) malloc(sizeof(maa_board_t));
+ mraa_board_t* b = (mraa_board_t*) malloc(sizeof(mraa_board_t));
if (b == NULL)
return NULL;
b->gpio_count = 14;
b->aio_count = 6;
- b->pins = (maa_pininfo_t*) malloc(sizeof(maa_pininfo_t)*MAA_INTEL_GALILEO_GEN_2_PINCOUNT);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t)*MRAA_INTEL_GALILEO_GEN_2_PINCOUNT);
strncpy(b->pins[0].name, "IO0", 8);
- b->pins[0].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[0].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[0].gpio.pinmap = 11;
b->pins[0].gpio.parent_id = 0;
b->pins[0].gpio.mux_total = 0;
- b->pins[0].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[0].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[0].gpio.output_enable = 32;
b->pins[0].gpio.pullup_enable = 33;
strncpy(b->pins[1].name, "IO1", 8);
- b->pins[1].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[1].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[1].gpio.pinmap = 12;
b->pins[1].gpio.parent_id = 0;
b->pins[1].gpio.mux_total = 1;
b->pins[1].gpio.mux[0].pin = 45;
b->pins[1].gpio.mux[0].value = 0;
- b->pins[1].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[1].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[1].gpio.output_enable = 28;
b->pins[1].gpio.pullup_enable = 29;
strncpy(b->pins[2].name, "IO2", 8);
- b->pins[2].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[2].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[2].gpio.pinmap = 13;
b->pins[2].gpio.parent_id = 0;
b->pins[2].gpio.mux_total = 1;
b->pins[2].gpio.mux[0].pin = 77;
b->pins[2].gpio.mux[0].value = 0;
- b->pins[2].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[2].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[2].gpio.output_enable = 34;
b->pins[2].gpio.pullup_enable = 35;
strncpy(b->pins[3].name, "IO3", 8);
- b->pins[3].capabilites = (maa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[3].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
b->pins[3].gpio.pinmap = 14;
b->pins[3].gpio.parent_id = 0;
b->pins[3].gpio.mux_total = 2;
b->pins[3].gpio.mux[0].value = 0;
b->pins[3].gpio.mux[1].pin = 64;
b->pins[3].gpio.mux[1].value = 0;
- b->pins[3].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[3].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[3].gpio.output_enable = 16;
b->pins[3].gpio.pullup_enable = 17;
b->pins[3].pwm.pinmap = 1;
//ADD Othher Bits?
strncpy(b->pins[4].name, "IO4", 8);
- b->pins[4].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[4].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[4].gpio.pinmap = 6;
b->pins[4].gpio.parent_id = 0;
b->pins[4].gpio.mux_total = 0;
- b->pins[4].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[4].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[4].gpio.output_enable = 36;
b->pins[4].gpio.pullup_enable = 37;
strncpy(b->pins[5].name, "IO5", 8);
- b->pins[5].capabilites = (maa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[5].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
b->pins[5].gpio.pinmap = 0;
b->pins[5].gpio.parent_id = 0;
b->pins[5].gpio.mux_total = 1;
b->pins[5].gpio.mux[0].pin = 66;
b->pins[5].gpio.mux[0].value = 0;
- b->pins[5].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[5].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[5].gpio.output_enable = 18;
b->pins[5].gpio.pullup_enable = 19;
b->pins[5].pwm.pinmap = 4;
b->pins[5].pwm.mux[1].value = 0;
strncpy(b->pins[6].name, "IO6", 8);
- b->pins[6].capabilites = (maa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[6].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
b->pins[6].gpio.pinmap = 1;
b->pins[6].gpio.parent_id = 0;
b->pins[6].gpio.mux_total = 1;
b->pins[6].gpio.mux[0].pin = 68;
b->pins[6].gpio.mux[0].value = 0;
- b->pins[6].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[6].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[6].gpio.output_enable = 20;
b->pins[6].gpio.pullup_enable = 21;
b->pins[6].pwm.pinmap = 5;
b->pins[6].pwm.mux[1].value = 0;
strncpy(b->pins[7].name, "IO7", 8);
- b->pins[7].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[7].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[7].gpio.pinmap = 38;
b->pins[7].gpio.parent_id = 0;
b->pins[7].gpio.mux_total = 0;
- b->pins[7].gpio.complex_cap = (maa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[7].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
b->pins[7].gpio.pullup_enable = 39;
strncpy(b->pins[8].name, "IO8", 8);
- b->pins[8].capabilites = (maa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[8].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
b->pins[8].gpio.pinmap = 40;
b->pins[8].gpio.parent_id = 0;
b->pins[8].gpio.mux_total = 0;
- b->pins[8].gpio.complex_cap = (maa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[8].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
b->pins[8].gpio.pullup_enable = 41;
strncpy(b->pins[9].name, "IO9", 8);
- b->pins[9].capabilites = (maa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[9].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
b->pins[9].gpio.pinmap = 4;
b->pins[9].gpio.parent_id = 0;
b->pins[9].gpio.mux_total = 1;
b->pins[9].gpio.mux[0].pin = 70;
b->pins[9].gpio.mux[0].value = 0;
- b->pins[9].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[9].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[9].gpio.output_enable = 22;
b->pins[9].gpio.pullup_enable = 23;
b->pins[9].pwm.pinmap = 7;
b->pins[9].pwm.mux[1].value = 0;
strncpy(b->pins[10].name, "IO10", 8);
- b->pins[10].capabilites = (maa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[10].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
b->pins[10].gpio.pinmap = 10;
b->pins[10].gpio.parent_id = 0;
b->pins[10].gpio.mux_total = 1;
b->pins[10].gpio.mux[0].pin = 74;
b->pins[10].gpio.mux[0].value = 0;
- b->pins[10].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[10].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[10].gpio.output_enable = 26;
b->pins[10].gpio.pullup_enable = 27;
b->pins[10].pwm.pinmap = 11;
b->pins[10].pwm.mux[1].value = 0;
strncpy(b->pins[11].name, "IO11", 8);
- b->pins[11].capabilites = (maa_pincapabilities_t) {1,1,1,0,1,0,0};
+ b->pins[11].capabilites = (mraa_pincapabilities_t) {1,1,1,0,1,0,0};
b->pins[11].gpio.pinmap = 5;
b->pins[11].gpio.parent_id = 0;
b->pins[11].gpio.mux_total = 2;
b->pins[11].gpio.mux[0].value = 0;
b->pins[11].gpio.mux[1].pin = 44;
b->pins[11].gpio.mux[1].value = 0;
- b->pins[11].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[11].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[11].gpio.output_enable = 24;
b->pins[11].gpio.pullup_enable = 25;
b->pins[11].pwm.pinmap = 9;
b->pins[11].pwm.mux[2].value = 0;
strncpy(b->pins[12].name, "IO12", 8);
- b->pins[12].capabilites = (maa_pincapabilities_t) {1,1,0,0,1,0,0};
+ b->pins[12].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0};
b->pins[12].gpio.pinmap = 15;
b->pins[12].gpio.parent_id = 0;
b->pins[12].gpio.mux_total = 0;
- b->pins[12].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[12].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[12].gpio.output_enable = 42;
b->pins[12].gpio.pullup_enable = 43;
b->pins[12].spi.pinmap = 1;
// THIS NEEDS TESTING UNSURE IF MOSI WILL BE EXPOSED.
strncpy(b->pins[13].name, "IO13", 8);
- b->pins[13].capabilites = (maa_pincapabilities_t) {1,1,0,0,1,0,0};
+ b->pins[13].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0};
b->pins[13].gpio.pinmap = 7;
b->pins[13].gpio.parent_id = 0;
b->pins[13].gpio.mux_total = 1;
b->pins[13].gpio.mux[0].pin = 46;
b->pins[13].gpio.mux[0].value = 0;
- b->pins[13].gpio.complex_cap = (maa_pin_cap_complex_t) {1,1,0,1,1};
+ b->pins[13].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,1,0,1,1};
b->pins[13].gpio.output_enable = 30;
b->pins[13].gpio.pullup_enable = 31;
b->pins[13].spi.pinmap = 1;
//ANALOG
strncpy(b->pins[14].name, "A0", 8);
- b->pins[14].capabilites = (maa_pincapabilities_t) {1,0,0,0,0,0,1};
- b->pins[14].gpio.complex_cap = (maa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[14].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,1};
+ b->pins[14].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
b->pins[14].gpio.pullup_enable = 49;
b->pins[14].aio.pinmap = 0;
b->pins[14].aio.mux_total = 0;
strncpy(b->pins[15].name, "A1", 8);
- b->pins[15].capabilites = (maa_pincapabilities_t) {1,0,0,0,0,0,1};
- b->pins[15].gpio.complex_cap = (maa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[15].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,1};
+ b->pins[15].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
b->pins[15].gpio.pullup_enable = 51;
b->pins[15].aio.pinmap = 1;
b->pins[15].aio.mux_total = 0;
strncpy(b->pins[16].name, "A2", 8);
- b->pins[16].capabilites = (maa_pincapabilities_t) {1,0,0,0,0,0,1};
- b->pins[16].gpio.complex_cap = (maa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[16].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,1};
+ b->pins[16].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
b->pins[16].gpio.pullup_enable = 53;
b->pins[16].aio.pinmap = 2;
b->pins[16].aio.mux_total = 0;
strncpy(b->pins[17].name, "A3", 8);
- b->pins[17].capabilites = (maa_pincapabilities_t) {1,0,0,0,0,0,1};
- b->pins[17].gpio.complex_cap = (maa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[17].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,1};
+ b->pins[17].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
b->pins[17].gpio.pullup_enable = 55;
b->pins[17].aio.pinmap = 3;
b->pins[17].aio.mux_total = 0;
strncpy(b->pins[18].name, "A4", 8);
- b->pins[18].capabilites = (maa_pincapabilities_t) {1,0,0,0,0,1,1};
- b->pins[18].gpio.complex_cap = (maa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[18].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,1,1};
+ b->pins[18].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
b->pins[18].gpio.pullup_enable = 57;
b->pins[18].i2c.pinmap = 1;
b->pins[18].i2c.mux_total = 1;
b->pins[18].aio.mux[1].value = 0;
strncpy(b->pins[19].name, "A5", 8);
- b->pins[19].capabilites = (maa_pincapabilities_t) {1,0,0,0,0,1,1};
- b->pins[19].gpio.complex_cap = (maa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[19].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,1,1};
+ b->pins[19].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
b->pins[19].gpio.pullup_enable = 59;
b->pins[19].i2c.pinmap = 1;
b->pins[19].i2c.mux_total = 1;
set (CMAKE_CXX_FLAGS -DBUILDING_NODE_EXTENSION)
# SWIG treats SWIG_FLAGS as a list and not a string so semicolon seperation is required
-set_source_files_properties (maajs.i PROPERTIES SWIG_FLAGS "-node;-I${CMAKE_BINARY_DIR}/src")
-set_source_files_properties (maajs.i PROPERTIES CPLUSPLUS ON)
+set_source_files_properties (mraajs.i PROPERTIES SWIG_FLAGS "-node;-I${CMAKE_BINARY_DIR}/src")
+set_source_files_properties (mraajs.i PROPERTIES CPLUSPLUS ON)
-swig_add_module (maajs javascript maajs.i ${maa_LIB_SRCS})
-swig_link_libraries (maajs ${NODE_LIBRARIES})
+swig_add_module (mraajs javascript mraajs.i ${mraa_LIB_SRCS})
+swig_link_libraries (mraajs ${NODE_LIBRARIES})
if (DOXYGEN_FOUND)
foreach (_file ${DOCFILES})
- add_dependencies (${SWIG_MODULE_maajs_REAL_NAME} ${_file}doc_i)
+ add_dependencies (${SWIG_MODULE_mraajs_REAL_NAME} ${_file}doc_i)
endforeach ()
endif ()
-set_target_properties (maajs PROPERTIES
+set_target_properties (mraajs PROPERTIES
PREFIX ""
SUFFIX ".node"
)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/package.json
- ${CMAKE_CURRENT_BINARY_DIR}/maajs.node
- DESTINATION lib/node_modules/maajs)
+ ${CMAKE_CURRENT_BINARY_DIR}/mraajs.node
+ DESTINATION lib/node_modules/mraajs)
+++ /dev/null
-%module (docstring="Javascript interface to libmaa") maajs
-
-%feature("autodoc", "3");
-
-%include ../maa.i
--- /dev/null
+%module (docstring="Javascript interface to libmraa") mraajs
+
+%feature("autodoc", "3");
+
+%include ../mraa.i
{
- "name" : "maajs",
- "main" : "./maajs.node",
+ "name" : "mraajs",
+ "main" : "./mraajs.node",
"engines": {
"node": ">= 1.0.x"
},
#include <sched.h>
#include <string.h>
-#include "maa_internal.h"
+#include "mraa_internal.h"
#include "intel_galileo_rev_d.h"
#include "intel_galileo_rev_g.h"
#include "gpio.h"
#include "version.h"
-//static maa_pininfo_t* pindata;
-static maa_board_t* plat = NULL;
-static maa_platform_t platform_type = MAA_UNKNOWN_PLATFORM;
+//static mraa_pininfo_t* pindata;
+static mraa_board_t* plat = NULL;
+static mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
const char *
-maa_get_version()
+mraa_get_version()
{
return gVERSION;
}
#ifdef SWIG
-maa_result_t
-maa_init()
+mraa_result_t
+mraa_init()
#else
-maa_result_t __attribute__((constructor))
-maa_init()
+mraa_result_t __attribute__((constructor))
+mraa_init()
#endif
{
/** Once more board definitions have been added,
* A method for detecting them will need to be devised.
*/
if (plat != NULL) {
- return MAA_ERROR_PLATFORM_ALREADY_INITIALISED;
+ return MRAA_ERROR_PLATFORM_ALREADY_INITIALISED;
}
#ifdef SWIGPYTHON
// Initialise python threads, this allows use to grab the GIL when we are
if (fh != NULL) {
if (getline(&line, &len, fh) != -1) {
if (strncmp(line, "GalileoGen2", 10) == 0) {
- platform_type = MAA_INTEL_GALILEO_GEN2;
+ platform_type = MRAA_INTEL_GALILEO_GEN2;
} else {
- platform_type = MAA_INTEL_GALILEO_GEN1;
+ platform_type = MRAA_INTEL_GALILEO_GEN1;
}
}
}
fclose(fh);
switch(platform_type) {
- case MAA_INTEL_GALILEO_GEN2:
- plat = maa_intel_galileo_gen2();
+ case MRAA_INTEL_GALILEO_GEN2:
+ plat = mraa_intel_galileo_gen2();
break;
- case MAA_INTEL_GALILEO_GEN1:
- plat = maa_intel_galileo_rev_d();
+ case MRAA_INTEL_GALILEO_GEN1:
+ plat = mraa_intel_galileo_rev_d();
break;
default:
- plat = maa_intel_galileo_rev_d();
- fprintf(stderr, "Platform not found, initialising MAA_INTEL_GALILEO_GEN1\n");
+ plat = mraa_intel_galileo_rev_d();
+ fprintf(stderr, "Platform not found, initialising MRAA_INTEL_GALILEO_GEN1\n");
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
int
-maa_set_priority(const unsigned int priority)
+mraa_set_priority(const unsigned int priority)
{
struct sched_param sched_s;
return sched_setscheduler(0, SCHED_RR, &sched_s);
}
-static maa_result_t
-maa_setup_mux_mapped(maa_pin_t meta)
+static mraa_result_t
+mraa_setup_mux_mapped(mraa_pin_t meta)
{
int mi;
for (mi = 0; mi < meta.mux_total; mi++) {
- maa_gpio_context mux_i;
- mux_i = maa_gpio_init_raw(meta.mux[mi].pin);
+ mraa_gpio_context mux_i;
+ mux_i = mraa_gpio_init_raw(meta.mux[mi].pin);
if (mux_i == NULL)
- return MAA_ERROR_INVALID_HANDLE;
- maa_gpio_dir(mux_i, MAA_GPIO_OUT);
- if (maa_gpio_write(mux_i, meta.mux[mi].value) != MAA_SUCCESS)
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_HANDLE;
+ mraa_gpio_dir(mux_i, MRAA_GPIO_OUT);
+ if (mraa_gpio_write(mux_i, meta.mux[mi].value) != MRAA_SUCCESS)
+ return MRAA_ERROR_INVALID_RESOURCE;
}
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
unsigned int
-maa_setup_gpio(int pin)
+mraa_setup_gpio(int pin)
{
if (plat == NULL)
return -1;
return -1;
if (plat->pins[pin].gpio.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pin].gpio) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pin].gpio) != MRAA_SUCCESS)
return -1;
return plat->pins[pin].gpio.pinmap;
}
unsigned int
-maa_setup_aio(int aio)
+mraa_setup_aio(int aio)
{
if (plat == NULL)
return -3;
return -1;
if (plat->pins[pin].aio.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pin].aio) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pin].aio) != MRAA_SUCCESS)
return -1;
return plat->pins[pin].aio.pinmap;
}
unsigned int
-maa_setup_i2c(int bus)
+mraa_setup_i2c(int bus)
{
if (plat == NULL)
return -3;
int pos = plat->i2c_bus[bus].sda;
if (plat->pins[pos].i2c.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pos].i2c) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pos].i2c) != MRAA_SUCCESS)
return -2;
pos = plat->i2c_bus[bus].scl;
if (plat->pins[pos].i2c.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pos].i2c) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pos].i2c) != MRAA_SUCCESS)
return -2;
return plat->i2c_bus[bus].bus_id;
}
-maa_spi_bus_t*
-maa_setup_spi(int bus)
+mraa_spi_bus_t*
+mraa_setup_spi(int bus)
{
if (plat == NULL)
return NULL;
int pos = plat->spi_bus[bus].sclk;
if (plat->pins[pos].spi.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pos].spi) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pos].spi) != MRAA_SUCCESS)
return NULL;
pos = plat->spi_bus[bus].mosi;
if (plat->pins[pos].spi.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pos].spi) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pos].spi) != MRAA_SUCCESS)
return NULL;
pos = plat->spi_bus[bus].miso;
if (plat->pins[pos].spi.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pos].spi) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pos].spi) != MRAA_SUCCESS)
return NULL;
- maa_spi_bus_t *spi = &(plat->spi_bus[bus]);
+ mraa_spi_bus_t *spi = &(plat->spi_bus[bus]);
return spi;
}
-maa_pin_t*
-maa_setup_pwm(int pin)
+mraa_pin_t*
+mraa_setup_pwm(int pin)
{
if (plat == NULL)
return NULL;
return NULL;
if (plat->pins[pin].capabilites.gpio == 1) {
- maa_gpio_context mux_i;
- mux_i = maa_gpio_init_raw(plat->pins[pin].gpio.pinmap);
+ mraa_gpio_context mux_i;
+ mux_i = mraa_gpio_init_raw(plat->pins[pin].gpio.pinmap);
if (mux_i == NULL)
return NULL;
- if (maa_gpio_dir(mux_i, MAA_GPIO_OUT) != MAA_SUCCESS)
+ if (mraa_gpio_dir(mux_i, MRAA_GPIO_OUT) != MRAA_SUCCESS)
return NULL;
// Current REV D quirk. //TODO GEN 2
- if (maa_gpio_write(mux_i, 1) != MAA_SUCCESS)
+ if (mraa_gpio_write(mux_i, 1) != MRAA_SUCCESS)
return NULL;
- if (maa_gpio_close(mux_i) != MAA_SUCCESS)
+ if (mraa_gpio_close(mux_i) != MRAA_SUCCESS)
return NULL;
}
if (plat->pins[pin].pwm.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pin].pwm) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pin].pwm) != MRAA_SUCCESS)
return NULL;
- maa_pin_t *ret;
- ret = (maa_pin_t*) malloc(sizeof(maa_pin_t));
+ mraa_pin_t *ret;
+ ret = (mraa_pin_t*) malloc(sizeof(mraa_pin_t));
ret->pinmap = plat->pins[pin].pwm.pinmap;
ret->parent_id = plat->pins[pin].pwm.parent_id;
return ret;
}
void
-maa_result_print(maa_result_t result)
+mraa_result_print(mraa_result_t result)
{
switch (result) {
- case MAA_SUCCESS: fprintf(stderr, "MAA: SUCCESS\n");
+ case MRAA_SUCCESS: fprintf(stderr, "MRAA: SUCCESS\n");
break;
- case MAA_ERROR_FEATURE_NOT_IMPLEMENTED:
- fprintf(stderr, "MAA: Feature not implemented.\n");
+ case MRAA_ERROR_FEATURE_NOT_IMPLEMENTED:
+ fprintf(stderr, "MRAA: Feature not implemented.\n");
break;
- case MAA_ERROR_FEATURE_NOT_SUPPORTED:
- fprintf(stderr, "MAA: Feature not supported by Hardware.\n");
+ case MRAA_ERROR_FEATURE_NOT_SUPPORTED:
+ fprintf(stderr, "MRAA: Feature not supported by Hardware.\n");
break;
- case MAA_ERROR_INVALID_VERBOSITY_LEVEL:
- fprintf(stderr, "MAA: Invalid verbosity level.\n");
+ case MRAA_ERROR_INVALID_VERBOSITY_LEVEL:
+ fprintf(stderr, "MRAA: Invalid verbosity level.\n");
break;
- case MAA_ERROR_INVALID_PARAMETER:
- fprintf(stderr, "MAA: Invalid parameter.\n");
+ case MRAA_ERROR_INVALID_PARAMETER:
+ fprintf(stderr, "MRAA: Invalid parameter.\n");
break;
- case MAA_ERROR_INVALID_HANDLE:
- fprintf(stderr, "MAA: Invalid Handle.\n");
+ case MRAA_ERROR_INVALID_HANDLE:
+ fprintf(stderr, "MRAA: Invalid Handle.\n");
break;
- case MAA_ERROR_NO_RESOURCES:
- fprintf(stderr, "MAA: No resources.\n");
+ case MRAA_ERROR_NO_RESOURCES:
+ fprintf(stderr, "MRAA: No resources.\n");
break;
- case MAA_ERROR_INVALID_RESOURCE:
- fprintf(stderr, "MAA: Invalid resource.\n");
+ case MRAA_ERROR_INVALID_RESOURCE:
+ fprintf(stderr, "MRAA: Invalid resource.\n");
break;
- case MAA_ERROR_INVALID_QUEUE_TYPE:
- fprintf(stderr, "MAA: Invalid Queue Type.\n");
+ case MRAA_ERROR_INVALID_QUEUE_TYPE:
+ fprintf(stderr, "MRAA: Invalid Queue Type.\n");
break;
- case MAA_ERROR_NO_DATA_AVAILABLE:
- fprintf(stderr, "MAA: No Data available.\n");
+ case MRAA_ERROR_NO_DATA_AVAILABLE:
+ fprintf(stderr, "MRAA: No Data available.\n");
break;
- case MAA_ERROR_INVALID_PLATFORM:
- fprintf(stderr, "MAA: Platform not recognised.\n");
+ case MRAA_ERROR_INVALID_PLATFORM:
+ fprintf(stderr, "MRAA: Platform not recognised.\n");
break;
- case MAA_ERROR_PLATFORM_NOT_INITIALISED:
- fprintf(stderr, "MAA: Platform not initialised.\n");
+ case MRAA_ERROR_PLATFORM_NOT_INITIALISED:
+ fprintf(stderr, "MRAA: Platform not initialised.\n");
break;
- case MAA_ERROR_PLATFORM_ALREADY_INITIALISED:
- fprintf(stderr, "MAA: Platform already initialised.\n");
+ case MRAA_ERROR_PLATFORM_ALREADY_INITIALISED:
+ fprintf(stderr, "MRAA: Platform already initialised.\n");
break;
- case MAA_ERROR_UNSPECIFIED:
- fprintf(stderr, "MAA: Unspecified Error.\n");
+ case MRAA_ERROR_UNSPECIFIED:
+ fprintf(stderr, "MRAA: Unspecified Error.\n");
break;
- default: fprintf(stderr, "MAA: Unrecognised error.\n");
+ default: fprintf(stderr, "MRAA: Unrecognised error.\n");
break;
}
}
-maa_boolean_t
-maa_pin_mode_test(int pin, maa_pinmodes_t mode)
+mraa_boolean_t
+mraa_pin_mode_test(int pin, mraa_pinmodes_t mode)
{
if (plat == NULL) {
- maa_init();
+ mraa_init();
if (plat == NULL)
return 0;
}
return 0;
switch(mode) {
- case MAA_PIN_VALID:
+ case MRAA_PIN_VALID:
if (plat->pins[pin].capabilites.valid == 1)
return 1;
break;
- case MAA_PIN_GPIO:
+ case MRAA_PIN_GPIO:
if (plat->pins[pin].capabilites.gpio ==1)
return 1;
break;
- case MAA_PIN_PWM:
+ case MRAA_PIN_PWM:
if (plat->pins[pin].capabilites.pwm ==1)
return 1;
break;
- case MAA_PIN_FAST_GPIO:
+ case MRAA_PIN_FAST_GPIO:
if (plat->pins[pin].capabilites.fast_gpio ==1)
return 1;
break;
- case MAA_PIN_SPI:
+ case MRAA_PIN_SPI:
if (plat->pins[pin].capabilites.spi ==1)
return 1;
break;
- case MAA_PIN_I2C:
+ case MRAA_PIN_I2C:
if (plat->pins[pin].capabilites.i2c ==1)
return 1;
break;
- case MAA_PIN_AIO:
+ case MRAA_PIN_AIO:
if (pin < plat->aio_count)
pin = pin + plat->gpio_count;
if (plat->pins[pin].capabilites.aio ==1)
return 0;
}
-maa_mmap_pin_t*
-maa_setup_mmap_gpio(int pin)
+mraa_mmap_pin_t*
+mraa_setup_mmap_gpio(int pin)
{
if (plat == NULL)
return NULL;
return NULL;
if (plat->pins[pin].mmap.gpio.mux_total > 0)
- if (maa_setup_mux_mapped(plat->pins[pin].mmap.gpio) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pin].mmap.gpio) != MRAA_SUCCESS)
return NULL;
- if (maa_setup_mux_mapped(plat->pins[pin].mmap.gpio) != MAA_SUCCESS)
+ if (mraa_setup_mux_mapped(plat->pins[pin].mmap.gpio) != MRAA_SUCCESS)
return NULL;
- maa_mmap_pin_t *ret = &(plat->pins[pin].mmap);
+ mraa_mmap_pin_t *ret = &(plat->pins[pin].mmap);
return ret;
}
-maa_result_t
-maa_swap_complex_gpio(int pin, int out)
+mraa_result_t
+mraa_swap_complex_gpio(int pin, int out)
{
if (plat == NULL)
- return MAA_ERROR_INVALID_PLATFORM;
+ return MRAA_ERROR_INVALID_PLATFORM;
switch (platform_type) {
- case MAA_INTEL_GALILEO_GEN2:
+ case MRAA_INTEL_GALILEO_GEN2:
if (plat->pins[pin].gpio.complex_cap.complex_pin != 1)
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
if (plat->pins[pin].gpio.complex_cap.output_en == 1) {
- maa_gpio_context output_e;
- output_e = maa_gpio_init_raw(plat->pins[pin].gpio.output_enable);
- if (maa_gpio_dir(output_e, MAA_GPIO_OUT) != MAA_SUCCESS)
- return MAA_ERROR_INVALID_RESOURCE;
+ mraa_gpio_context output_e;
+ output_e = mraa_gpio_init_raw(plat->pins[pin].gpio.output_enable);
+ if (mraa_gpio_dir(output_e, MRAA_GPIO_OUT) != MRAA_SUCCESS)
+ return MRAA_ERROR_INVALID_RESOURCE;
int output_val;
if (plat->pins[pin].gpio.complex_cap.output_en_high == 1)
output_val = out;
output_val = 0;
else
output_val = 1;
- if (maa_gpio_write(output_e, output_val) != MAA_SUCCESS)
- return MAA_ERROR_INVALID_RESOURCE;
+ if (mraa_gpio_write(output_e, output_val) != MRAA_SUCCESS)
+ return MRAA_ERROR_INVALID_RESOURCE;
}
//if (plat->pins[pin].gpio.complex_cap.pullup_en == 1) {
- // maa_gpio_context pullup_e;
- // pullup_e = maa_gpio_init_raw(plat->pins[pin].gpio.pullup_enable);
- // if (maa_gpio_mode(pullup_e, MAA_GPIO_HIZ) != MAA_SUCCESS)
- // return MAA_ERROR_INVALID_RESOURCE;
+ // mraa_gpio_context pullup_e;
+ // pullup_e = mraa_gpio_init_raw(plat->pins[pin].gpio.pullup_enable);
+ // if (mraa_gpio_mode(pullup_e, MRAA_GPIO_HIZ) != MRAA_SUCCESS)
+ // return MRAA_ERROR_INVALID_RESOURCE;
//}
break;
- default: return MAA_SUCCESS;
+ default: return MRAA_SUCCESS;
}
}
-maa_platform_t maa_get_platform_type()
+mraa_platform_t mraa_get_platform_type()
{
return platform_type;
}
%}
%init %{
- //Adding maa_init() to the module initialisation process
- maa_init();
+ //Adding mraa_init() to the module initialisation process
+ mraa_init();
%}
-%rename(getVersion) maa_get_version;
+%rename(getVersion) mraa_get_version;
-%rename(setPriority) maa_set_priority;
+%rename(setPriority) mraa_set_priority;
-%rename(printError) maa_result_print(maa_result_t error);
+%rename(printError) mraa_result_print(mraa_result_t error);
-%rename(getPlatform) maa_get_platform_type;
+%rename(getPlatform) mraa_get_platform_type;
%typemap(in) uint8_t = char;
libdir=${exec_prefix}/lib@LIB_SUFFIX@
includedir=${prefix}/include
-Name: maa
+Name: mraa
Description: Low Level Skeleton Library for Communication
-Version: @maa_VERSION_STRING@
+Version: @mraa_VERSION_STRING@
-Libs: -L${libdir} -lmaa
+Libs: -L${libdir} -lmraa
Cflags: -I${includedir}
#include <unistd.h>
#include "pwm.h"
-#include "maa_internal.h"
+#include "mraa_internal.h"
#define MAX_SIZE 64
#define SYSFS_PWM "/sys/class/pwm"
int pin; /**< the pin number, as known to the os. */
int chipid; /**< the chip id, which the pwm resides */
int duty_fp; /**< File pointer to duty file */
- maa_boolean_t owner; /**< Owner of pwm context*/
+ mraa_boolean_t owner; /**< Owner of pwm context*/
/*@}*/
};
static int
-maa_pwm_setup_duty_fp(maa_pwm_context dev)
+mraa_pwm_setup_duty_fp(mraa_pwm_context dev)
{
char bu[MAX_SIZE];
snprintf(bu,MAX_SIZE, "/sys/class/pwm/pwmchip%d/pwm%d/duty_cycle", dev->chipid, dev->pin);
return 0;
}
-static maa_result_t
-maa_pwm_write_period(maa_pwm_context dev, int period)
+static mraa_result_t
+mraa_pwm_write_period(mraa_pwm_context dev, int period)
{
char bu[MAX_SIZE];
snprintf(bu,MAX_SIZE ,"/sys/class/pwm/pwmchip%d/pwm%d/period", dev->chipid, dev->pin);
int period_f = open(bu, O_RDWR);
if (period_f == -1) {
fprintf(stderr, "Failed to open period for writing!\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char out[MAX_SIZE];
int length = snprintf(out, MAX_SIZE, "%d", period);
if (write(period_f, out, length*sizeof(char)) == -1) {
close(period_f);
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(period_f);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-static maa_result_t
-maa_pwm_write_duty(maa_pwm_context dev, int duty)
+static mraa_result_t
+mraa_pwm_write_duty(mraa_pwm_context dev, int duty)
{
if (dev->duty_fp == -1) {
- maa_pwm_setup_duty_fp(dev);
+ mraa_pwm_setup_duty_fp(dev);
}
char bu[64];
int length = sprintf(bu, "%d", duty);
if (write(dev->duty_fp, bu, length * sizeof(char)) == -1)
- return MAA_ERROR_INVALID_RESOURCE;
- return MAA_SUCCESS;
+ return MRAA_ERROR_INVALID_RESOURCE;
+ return MRAA_SUCCESS;
}
static int
-maa_pwm_get_period(maa_pwm_context dev)
+mraa_pwm_get_period(mraa_pwm_context dev)
{
char bu[MAX_SIZE];
char output[MAX_SIZE];
}
static int
-maa_pwm_get_duty(maa_pwm_context dev)
+mraa_pwm_get_duty(mraa_pwm_context dev)
{
if (dev->duty_fp == -1) {
- maa_pwm_setup_duty_fp(dev);
+ mraa_pwm_setup_duty_fp(dev);
} else {
lseek(dev->duty_fp, 0, SEEK_SET);
}
return ret;
}
-maa_pwm_context
-maa_pwm_init(int pin) {
- maa_pin_t* pinm = maa_setup_pwm(pin);
+mraa_pwm_context
+mraa_pwm_init(int pin) {
+ mraa_pin_t* pinm = mraa_setup_pwm(pin);
if (pinm == NULL)
return NULL;
int chip = pinm->parent_id;
int pinn = pinm->pinmap;
free(pinm);
- return maa_pwm_init_raw(chip,pinn);
+ return mraa_pwm_init_raw(chip,pinn);
}
-maa_pwm_context
-maa_pwm_init_raw(int chipin, int pin)
+mraa_pwm_context
+mraa_pwm_init_raw(int chipin, int pin)
{
- maa_pwm_context dev = (maa_pwm_context) malloc(sizeof(struct _pwm));
+ mraa_pwm_context dev = (mraa_pwm_context) malloc(sizeof(struct _pwm));
if (dev == NULL)
return NULL;
dev->duty_fp = -1;
dev->owner = 1;
close(export_f);
}
- maa_pwm_setup_duty_fp(dev);
+ mraa_pwm_setup_duty_fp(dev);
return dev;
}
-maa_result_t
-maa_pwm_write(maa_pwm_context dev, float percentage)
+mraa_result_t
+mraa_pwm_write(mraa_pwm_context dev, float percentage)
{
- return maa_pwm_write_duty(dev, percentage * maa_pwm_get_period(dev));
+ return mraa_pwm_write_duty(dev, percentage * mraa_pwm_get_period(dev));
}
float
-maa_pwm_read(maa_pwm_context dev)
+mraa_pwm_read(mraa_pwm_context dev)
{
- float output = maa_pwm_get_duty(dev) / (float) maa_pwm_get_period(dev);
+ float output = mraa_pwm_get_duty(dev) / (float) mraa_pwm_get_period(dev);
return output;
}
-maa_result_t
-maa_pwm_period(maa_pwm_context dev, float seconds)
+mraa_result_t
+mraa_pwm_period(mraa_pwm_context dev, float seconds)
{
- return maa_pwm_period_ms(dev, seconds*1000);
+ return mraa_pwm_period_ms(dev, seconds*1000);
}
-maa_result_t
-maa_pwm_period_ms(maa_pwm_context dev, int ms)
+mraa_result_t
+mraa_pwm_period_ms(mraa_pwm_context dev, int ms)
{
- return maa_pwm_period_us(dev, ms*1000);
+ return mraa_pwm_period_us(dev, ms*1000);
}
-maa_result_t
-maa_pwm_period_us(maa_pwm_context dev, int us)
+mraa_result_t
+mraa_pwm_period_us(mraa_pwm_context dev, int us)
{
- return maa_pwm_write_period(dev, us*1000);
+ return mraa_pwm_write_period(dev, us*1000);
}
-maa_result_t
-maa_pwm_pulsewidth(maa_pwm_context dev, float seconds)
+mraa_result_t
+mraa_pwm_pulsewidth(mraa_pwm_context dev, float seconds)
{
- return maa_pwm_pulsewidth_ms(dev, seconds*1000);
+ return mraa_pwm_pulsewidth_ms(dev, seconds*1000);
}
-maa_result_t
-maa_pwm_pulsewidth_ms(maa_pwm_context dev, int ms)
+mraa_result_t
+mraa_pwm_pulsewidth_ms(mraa_pwm_context dev, int ms)
{
- return maa_pwm_pulsewidth_us(dev, ms*1000);
+ return mraa_pwm_pulsewidth_us(dev, ms*1000);
}
-maa_result_t
-maa_pwm_pulsewidth_us(maa_pwm_context dev, int us)
+mraa_result_t
+mraa_pwm_pulsewidth_us(mraa_pwm_context dev, int us)
{
- return maa_pwm_write_duty(dev, us*1000);
+ return mraa_pwm_write_duty(dev, us*1000);
}
-maa_result_t
-maa_pwm_enable(maa_pwm_context dev, int enable)
+mraa_result_t
+mraa_pwm_enable(mraa_pwm_context dev, int enable)
{
int status;
if (enable != 0) {
if (enable_f == -1) {
fprintf(stderr, "Failed to open enable for writing!\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char out[2];
int size = snprintf(out, sizeof(out), "%d", enable);
if (write(enable_f, out, size * sizeof(char)) == -1) {
fprintf(stderr, "Failed to write to enable!\n");
close(enable_f);
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(enable_f);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_pwm_unexport_force(maa_pwm_context dev)
+mraa_result_t
+mraa_pwm_unexport_force(mraa_pwm_context dev)
{
char filepath[MAX_SIZE];
snprintf(filepath, MAX_SIZE, "/sys/class/pwm/pwmchip%d/unexport", dev->chipid);
int unexport_f = open(filepath, O_WRONLY);
if (unexport_f == -1) {
fprintf(stderr, "Failed to open unexport for writing!\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char out[MAX_SIZE];
if (write(unexport_f, out, size*sizeof(char)) == -1) {
fprintf(stderr, "Failed to write to unexport!\n");
close(unexport_f);
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(unexport_f);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_pwm_unexport(maa_pwm_context dev)
+mraa_result_t
+mraa_pwm_unexport(mraa_pwm_context dev)
{
- maa_pwm_enable(dev, 0);
+ mraa_pwm_enable(dev, 0);
if (dev->owner) {
- return maa_pwm_unexport_force(dev);
+ return mraa_pwm_unexport_force(dev);
}
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
-maa_result_t
-maa_pwm_close(maa_pwm_context dev)
+mraa_result_t
+mraa_pwm_close(mraa_pwm_context dev)
{
- maa_pwm_unexport(dev);
+ mraa_pwm_unexport(dev);
free(dev);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_pwm_owner(maa_pwm_context dev, maa_boolean_t owner_new)
+mraa_result_t
+mraa_pwm_owner(mraa_pwm_context dev, mraa_boolean_t owner_new)
{
if (dev == NULL)
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
dev->owner = owner_new;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
${PYTHON_INCLUDE_DIRS}
)
-set_source_files_properties (pymaa.i PROPERTIES CPLUSPLUS ON)
-set_source_files_properties (pymaa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
-swig_add_module (pymaa python pymaa.i ${maa_LIB_SRCS})
-swig_link_libraries (pymaa ${PYTHON_LIBRARIES})
+set_source_files_properties (pymraa.i PROPERTIES CPLUSPLUS ON)
+set_source_files_properties (pymraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
+swig_add_module (pymraa python pymraa.i ${mraa_LIB_SRCS})
+swig_link_libraries (pymraa ${PYTHON_LIBRARIES})
set (CMAKE_C_FLAGS -DSWIGPYTHON=${SWIG_FOUND})
if (DOXYGEN_FOUND)
foreach (_file ${DOCCLASSES})
- add_dependencies (${SWIG_MODULE_pymaa_REAL_NAME} ${_file}class_doc_i)
+ add_dependencies (${SWIG_MODULE_pymraa_REAL_NAME} ${_file}class_doc_i)
endforeach ()
- add_dependencies (${SWIG_MODULE_pymaa_REAL_NAME} commondoc_i)
+ add_dependencies (${SWIG_MODULE_pymraa_REAL_NAME} commondoc_i)
add_custom_target (pydoc
- pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/pymaa.py ${CMAKE_CURRENT_BINARY_DIR}/
+ pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/pymraa.py ${CMAKE_CURRENT_BINARY_DIR}/
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with pydoc" VERBATIM
)
list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
list (GET PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
-install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_pymaa.so
- ${CMAKE_CURRENT_BINARY_DIR}/pymaa.py
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_pymraa.so
+ ${CMAKE_CURRENT_BINARY_DIR}/pymraa.py
DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/)
add_subdirectory (docs)
COMMENT "Building HTML documentation with Sphinx"
)
- add_dependencies (sphinx ${SWIG_MODULE_pymaa_REAL_NAME})
+ add_dependencies (sphinx ${SWIG_MODULE_pymraa_REAL_NAME})
endif ()
endif ()
master_doc = 'index'
# General information about the project.
-project = 'pymaa'
+project = 'pymraa'
copyright = '2014, Intel Corporation'
# The version info for the project you're documenting, acts as replacement for
# built documents.
#
# The short X.Y version.
-version = '@maa_VERSION_STRING@'
+version = '@mraa_VERSION_STRING@'
# The full version, including alpha/beta/rc tags.
release = '@VERSION@'
#html_file_suffix = None
# Output file base name for HTML help builder.
-htmlhelp_basename = 'pymaadoc'
+htmlhelp_basename = 'pymraadoc'
# -- Options for LaTeX output ---------------------------------------------
#######
Example
#######
-Here are some examples of how to use pymaa, common convention is to import pymaa as maa to keep it short but feel free to import it globally!
+Here are some examples of how to use pymraa, common convention is to import pymraa as mraa to keep it short but feel free to import it globally!
Hello GPIO
==========
-Here is the simplest Gpio program in pymaa.
+Here is the simplest Gpio program in pymraa.
.. literalinclude:: ../../../examples/python/hello_gpio.py
- :prepend: import pymaa
- :start-after: import pymaa
+ :prepend: import pymraa
+ :start-after: import pymraa
GPIO Interupt (isr)
===================
**Note:** Galileo Gen1 only supports EDGE_BOTH
.. literalinclude:: ../../../examples/python/hello_isr.py
- :prepend: import pymaa as maa
- :start-after: import pymaa as maa
+ :prepend: import pymraa as mraa
+ :start-after: import pymraa as mraa
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-Welcome to Pymaa's documentation!
+Welcome to Pymraa's documentation!
=============================
Contents:
.. toctree::
:maxdepth: 2
- pymaa
+ pymraa
example
-pymaa module
+pymraa module
============
-.. automodule:: pymaa
+.. automodule:: pymraa
:members:
:undoc-members:
:show-inheritance:
+++ /dev/null
-%module(docstring="Python interface to libmaa") pymaa
-
-%feature("autodoc", "3");
-
-%include ../maa.i
-
--- /dev/null
+%module(docstring="Python interface to libmraa") pymraa
+
+%feature("autodoc", "3");
+
+%include ../mraa.i
+
#include <unistd.h>
#include "spi.h"
-#include "maa_internal.h"
+#include "mraa_internal.h"
#define MAX_SIZE 64
#define SPI_MAX_LENGTH 4096
int devfd; /**< File descriptor to SPI Device */
int mode; /**< Spi mode see spidev.h */
int clock; /**< clock to run transactions at */
- maa_boolean_t lsb; /**< least significant bit mode */
+ mraa_boolean_t lsb; /**< least significant bit mode */
unsigned int bpw; /**< Bits per word */
/*@}*/
};
-maa_spi_context
-maa_spi_init(int bus)
+mraa_spi_context
+mraa_spi_init(int bus)
{
- maa_spi_bus_t *spi = maa_setup_spi(bus);
+ mraa_spi_bus_t *spi = mraa_setup_spi(bus);
if(bus < 0) {
fprintf(stderr, "Failed. SPI platform Error\n");
return NULL;
}
- maa_spi_context dev = (maa_spi_context) malloc(sizeof(struct _spi));
+ mraa_spi_context dev = (mraa_spi_context) malloc(sizeof(struct _spi));
memset(dev, 0, sizeof(struct _spi));
char path[MAX_SIZE];
return dev;
}
-maa_result_t
-maa_spi_mode(maa_spi_context dev, unsigned short mode)
+mraa_result_t
+mraa_spi_mode(mraa_spi_context dev, unsigned short mode)
{
dev->mode = mode;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_spi_frequency(maa_spi_context dev, int hz)
+mraa_result_t
+mraa_spi_frequency(mraa_spi_context dev, int hz)
{
dev->clock = hz;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_spi_lsbmode(maa_spi_context dev, maa_boolean_t lsb)
+mraa_result_t
+mraa_spi_lsbmode(mraa_spi_context dev, mraa_boolean_t lsb)
{
uint8_t lsb_mode = 0;
if (lsb == 1) {
}
if (ioctl (dev->devfd, SPI_IOC_WR_LSB_FIRST, &lsb_mode) < 0) {
fprintf(stderr, "Failed to set bit order\n");
- return MAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
dev->lsb = lsb;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
-maa_result_t
-maa_spi_bit_per_word(maa_spi_context dev, unsigned int bits)
+mraa_result_t
+mraa_spi_bit_per_word(mraa_spi_context dev, unsigned int bits)
{
dev->bpw = bits;
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
uint8_t
-maa_spi_write(maa_spi_context dev, uint8_t data)
+mraa_spi_write(mraa_spi_context dev, uint8_t data)
{
struct spi_ioc_transfer msg;
memset(&msg, 0, sizeof(msg));
}
uint8_t*
-maa_spi_write_buf(maa_spi_context dev, uint8_t* data, int length)
+mraa_spi_write_buf(mraa_spi_context dev, uint8_t* data, int length)
{
struct spi_ioc_transfer msg;
memset(&msg, 0, sizeof(msg));
return recv;
}
-maa_result_t
-maa_spi_stop(maa_spi_context dev)
+mraa_result_t
+mraa_spi_stop(mraa_spi_context dev)
{
close(dev->devfd);
- return MAA_SUCCESS;
+ return MRAA_SUCCESS;
}
${PROJECT_SOURCE_DIR}/include
)
-add_executable(${PROJECT_TEST_NAME} "maa_test.cxx")
+add_executable(${PROJECT_TEST_NAME} "mraa_test.cxx")
-target_link_libraries(${PROJECT_TEST_NAME} ${PROJECT_NAME_STR} ${GTEST_BOTH_LIBRARIES} maa pthread)
+target_link_libraries(${PROJECT_TEST_NAME} ${PROJECT_NAME_STR} ${GTEST_BOTH_LIBRARIES} mraa pthread)
add_test(Basic ${PROJECT_TEST_NAME})
-#include <maa.h>
+#include <mraa.h>
#include "gtest/gtest.h"
#include "version.h"
/* Careful, this test will only attempt to check the returned version is valid,
* it doesn't try to check the version is a release one.
*/
-TEST (basic, maa_get_version) {
+TEST (basic, mraa_get_version) {
char bar[64];
- strcpy(bar, maa_get_version());
- ASSERT_STREQ(maa_get_version(), gVERSION);
+ strcpy(bar, mraa_get_version());
+ ASSERT_STREQ(mraa_get_version(), gVERSION);
}