mraa: Add types.hpp; Use types.hpp for C++ and SWIG
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com> Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
679d1a55b6
commit
3934897864
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <stdexcept>
|
||||
#include "aio.h"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace mraa
|
||||
{
|
||||
@@ -85,12 +86,12 @@ class Aio
|
||||
* Set the bit value which mraa will shift the raw reading
|
||||
* from the ADC to. I.e. 10bits
|
||||
* @param bits the bits the return from read should be i.e 10
|
||||
* @return mraa result type
|
||||
* @return mraa::Result type
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
setBit(int bits)
|
||||
{
|
||||
return mraa_aio_set_bit(m_aio, bits);
|
||||
return (Result) mraa_aio_set_bit(m_aio, bits);
|
||||
}
|
||||
/**
|
||||
* Gets the bit value mraa is shifting the analog read to.
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include "types.hpp"
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
@@ -51,10 +52,10 @@ namespace mraa
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
inline mraa_result_t
|
||||
inline Result
|
||||
init()
|
||||
{
|
||||
return mraa_init();
|
||||
return (Result) mraa_init();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,23 +88,23 @@ setPriority(const unsigned int priority)
|
||||
/**
|
||||
* Get platform type, board must be initialised.
|
||||
*
|
||||
* @return mraa_platform_t Platform type enum
|
||||
* @return mraa::platform Platform type enum
|
||||
*/
|
||||
inline mraa_platform_t
|
||||
inline Platform
|
||||
getPlatformType()
|
||||
{
|
||||
return mraa_get_platform_type();
|
||||
return (Platform) mraa_get_platform_type();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a textual representation of the mraa_result_t
|
||||
* Print a textual representation of the mraa::Result
|
||||
*
|
||||
* @param result the result to print
|
||||
* @param Result the Result to print
|
||||
*/
|
||||
inline void
|
||||
printError(mraa_result_t result)
|
||||
printError(Result result)
|
||||
{
|
||||
mraa_result_print(result);
|
||||
mraa_result_print((mraa_result_t) result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,9 +115,9 @@ printError(mraa_result_t result)
|
||||
* @return boolean if the mode is supported, 0=false.
|
||||
*/
|
||||
inline bool
|
||||
pinModeTest(int pin, mraa_pinmodes_t mode)
|
||||
pinModeTest(int pin, Pinmodes mode)
|
||||
{
|
||||
return (bool) mraa_pin_mode_test(pin, mode);
|
||||
return (bool) mraa_pin_mode_test(pin, (mraa_pinmodes_t) mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,10 +210,10 @@ getPinName(int pin)
|
||||
* @param level
|
||||
* @return Result of operation
|
||||
*/
|
||||
inline mraa_result_t
|
||||
inline Result
|
||||
setLogLevel(int level)
|
||||
{
|
||||
return mraa_set_log_level(level);
|
||||
return (Result) mraa_set_log_level(level);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "gpio.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(SWIGJAVASCRIPT)
|
||||
@@ -144,16 +145,16 @@ class Gpio
|
||||
* @param mode The edge mode to set
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
edge(Edge mode)
|
||||
{
|
||||
return mraa_gpio_edge_mode(m_gpio, (mraa_gpio_edge_t) mode);
|
||||
return (Result) mraa_gpio_edge_mode(m_gpio, (mraa_gpio_edge_t) mode);
|
||||
}
|
||||
#if defined(SWIGPYTHON)
|
||||
mraa_result_t
|
||||
Result
|
||||
isr(Edge mode, PyObject* pyfunc, PyObject* args)
|
||||
{
|
||||
return mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, (void (*) (void*)) pyfunc, (void*) args);
|
||||
return (Result) mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, (void (*) (void*)) pyfunc, (void*) args);
|
||||
}
|
||||
#elif defined(SWIGJAVASCRIPT)
|
||||
static void
|
||||
@@ -185,7 +186,7 @@ class Gpio
|
||||
uv_queue_work(uv_default_loop(), req, nop, v8isr);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
Result
|
||||
isr(Edge mode, v8::Handle<v8::Function> func)
|
||||
{
|
||||
#if NODE_MODULE_VERSION >= 0x000D
|
||||
@@ -193,13 +194,13 @@ class Gpio
|
||||
#else
|
||||
m_v8isr = v8::Persistent<v8::Function>::New(func);
|
||||
#endif
|
||||
return mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, &uvwork, this);
|
||||
return (Result) mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, &uvwork, this);
|
||||
}
|
||||
#elif defined(SWIGJAVA)
|
||||
mraa_result_t
|
||||
Result
|
||||
isr(Edge mode, IsrCallback* cb, void* args)
|
||||
{
|
||||
return mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, generic_isr_callback, cb);
|
||||
return (Result) mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, generic_isr_callback, cb);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
@@ -211,10 +212,10 @@ class Gpio
|
||||
* @param args Arguments passed to the interrupt handler (fptr)
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
isr(Edge mode, void (*fptr)(void*), void* args)
|
||||
{
|
||||
return mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, fptr, args);
|
||||
return (Result) mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, fptr, args);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
@@ -223,7 +224,7 @@ class Gpio
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
isrExit()
|
||||
{
|
||||
#if defined(SWIGJAVASCRIPT)
|
||||
@@ -234,7 +235,7 @@ class Gpio
|
||||
m_v8isr.Clear();
|
||||
#endif
|
||||
#endif
|
||||
return mraa_gpio_isr_exit(m_gpio);
|
||||
return (Result) mraa_gpio_isr_exit(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Change Gpio mode
|
||||
@@ -242,10 +243,10 @@ class Gpio
|
||||
* @param mode The mode to change the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
mode(Mode mode)
|
||||
{
|
||||
return mraa_gpio_mode(m_gpio, (mraa_gpio_mode_t) mode);
|
||||
return (Result )mraa_gpio_mode(m_gpio, (mraa_gpio_mode_t) mode);
|
||||
}
|
||||
/**
|
||||
* Change Gpio direction
|
||||
@@ -253,10 +254,10 @@ class Gpio
|
||||
* @param dir The direction to change the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
dir(Dir dir)
|
||||
{
|
||||
return mraa_gpio_dir(m_gpio, (mraa_gpio_dir_t) dir);
|
||||
return (Result )mraa_gpio_dir(m_gpio, (mraa_gpio_dir_t) dir);
|
||||
}
|
||||
/**
|
||||
* Read value from Gpio
|
||||
@@ -274,10 +275,10 @@ class Gpio
|
||||
* @param value Value to write to Gpio
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
write(int value)
|
||||
{
|
||||
return mraa_gpio_write(m_gpio, value);
|
||||
return (Result) mraa_gpio_write(m_gpio, value);
|
||||
}
|
||||
/**
|
||||
* Enable use of mmap i/o if available.
|
||||
@@ -285,10 +286,10 @@ class Gpio
|
||||
* @param enable true to use mmap
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
useMmap(bool enable)
|
||||
{
|
||||
return mraa_gpio_use_mmaped(m_gpio, (mraa_boolean_t) enable);
|
||||
return (Result) mraa_gpio_use_mmaped(m_gpio, (mraa_boolean_t) enable);
|
||||
}
|
||||
/**
|
||||
* Get pin number of Gpio. If raw param is True will return the
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "i2c.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mraa
|
||||
@@ -80,10 +81,10 @@ class I2c
|
||||
* @param mode Frequency to set the bus to
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
frequency(mraa_i2c_mode_t mode)
|
||||
Result
|
||||
frequency(I2cMode mode)
|
||||
{
|
||||
return mraa_i2c_frequency(m_i2c, mode);
|
||||
return (Result) mraa_i2c_frequency(m_i2c, (mraa_i2c_mode_t) mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,10 +94,10 @@ class I2c
|
||||
* @param address Communicate to the i2c slave on this address
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
address(uint8_t address)
|
||||
{
|
||||
return mraa_i2c_address(m_i2c, address);
|
||||
return (Result) mraa_i2c_address(m_i2c, address);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,10 +169,10 @@ class I2c
|
||||
* @param data The byte to send on the bus
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
writeByte(uint8_t data)
|
||||
{
|
||||
return mraa_i2c_write_byte(m_i2c, data);
|
||||
return (Result) mraa_i2c_write_byte(m_i2c, data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,10 +183,10 @@ class I2c
|
||||
* @param length Size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
write(const uint8_t* data, int length)
|
||||
{
|
||||
return mraa_i2c_write(m_i2c, data, length);
|
||||
return (Result) mraa_i2c_write(m_i2c, data, length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,10 +196,10 @@ class I2c
|
||||
* @param data Value to write to register
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
writeReg(uint8_t reg, uint8_t data)
|
||||
{
|
||||
return mraa_i2c_write_byte_data(m_i2c, data, reg);
|
||||
return (Result) mraa_i2c_write_byte_data(m_i2c, data, reg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,10 +209,10 @@ class I2c
|
||||
* @param data Value to write to register
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
writeWordReg(uint8_t reg, uint16_t data)
|
||||
{
|
||||
return mraa_i2c_write_word_data(m_i2c, data, reg);
|
||||
return (Result) mraa_i2c_write_word_data(m_i2c, data, reg);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "pwm.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mraa
|
||||
@@ -81,10 +82,10 @@ class Pwm
|
||||
* 1.0f
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
write(float percentage)
|
||||
{
|
||||
return mraa_pwm_write(m_pwm, percentage);
|
||||
return (Result) mraa_pwm_write(m_pwm, percentage);
|
||||
}
|
||||
/**
|
||||
* Read the ouput duty-cycle percentage, as a float
|
||||
@@ -105,10 +106,10 @@ class Pwm
|
||||
* @param period Period represented as a float in seconds
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
period(float period)
|
||||
{
|
||||
return mraa_pwm_period(m_pwm, period);
|
||||
return (Result) mraa_pwm_period(m_pwm, period);
|
||||
}
|
||||
/**
|
||||
* Set period, milliseconds
|
||||
@@ -116,10 +117,10 @@ class Pwm
|
||||
* @param ms milliseconds for period
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
period_ms(int ms)
|
||||
{
|
||||
return mraa_pwm_period_ms(m_pwm, ms);
|
||||
return (Result) mraa_pwm_period_ms(m_pwm, ms);
|
||||
}
|
||||
/**
|
||||
* Set period, microseconds
|
||||
@@ -127,10 +128,10 @@ class Pwm
|
||||
* @param us microseconds as period
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
period_us(int us)
|
||||
{
|
||||
return mraa_pwm_period_us(m_pwm, us);
|
||||
return (Result) mraa_pwm_period_us(m_pwm, us);
|
||||
}
|
||||
/**
|
||||
* Set pulsewidth, As represnted by seconds in a (float)
|
||||
@@ -138,10 +139,10 @@ class Pwm
|
||||
* @param seconds The duration of a pulse
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
pulsewidth(float seconds)
|
||||
{
|
||||
return mraa_pwm_pulsewidth(m_pwm, seconds);
|
||||
return (Result) mraa_pwm_pulsewidth(m_pwm, seconds);
|
||||
}
|
||||
/**
|
||||
* Set pulsewidth, milliseconds
|
||||
@@ -149,10 +150,10 @@ class Pwm
|
||||
* @param ms milliseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
pulsewidth_ms(int ms)
|
||||
{
|
||||
return mraa_pwm_pulsewidth_ms(m_pwm, ms);
|
||||
return (Result) mraa_pwm_pulsewidth_ms(m_pwm, ms);
|
||||
}
|
||||
/**
|
||||
* The pulsewidth, microseconds
|
||||
@@ -160,10 +161,10 @@ class Pwm
|
||||
* @param us microseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
pulsewidth_us(int us)
|
||||
{
|
||||
return mraa_pwm_pulsewidth_us(m_pwm, us);
|
||||
return (Result) mraa_pwm_pulsewidth_us(m_pwm, us);
|
||||
}
|
||||
/**
|
||||
* Set the enable status of the PWM pin. None zero will assume on with
|
||||
@@ -172,13 +173,13 @@ class Pwm
|
||||
* @param enable enable status of pin
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
return mraa_pwm_enable(m_pwm, 1);
|
||||
return (Result) mraa_pwm_enable(m_pwm, 1);
|
||||
else
|
||||
return mraa_pwm_enable(m_pwm, 0);
|
||||
return (Result) mraa_pwm_enable(m_pwm, 0);
|
||||
}
|
||||
/**
|
||||
* Set the period and duty of a PWM object.
|
||||
@@ -187,10 +188,10 @@ class Pwm
|
||||
* @param duty represnted in ms as float.
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
config_ms(int period, float duty)
|
||||
{
|
||||
return mraa_pwm_config_ms(m_pwm, period, duty);
|
||||
return (Result) mraa_pwm_config_ms(m_pwm, period, duty);
|
||||
}
|
||||
/**
|
||||
* Set the period and duty (percent) of a PWM object.
|
||||
@@ -199,10 +200,10 @@ class Pwm
|
||||
* @param duty percentage i.e. 50% = 0.5f
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
config_percent(int period, float duty)
|
||||
{
|
||||
return mraa_pwm_config_percent(m_pwm, period, duty);
|
||||
return (Result) mraa_pwm_config_percent(m_pwm, period, duty);
|
||||
}
|
||||
/**
|
||||
* Get the maximum pwm period in us
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "spi.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mraa
|
||||
@@ -83,10 +84,10 @@ class Spi
|
||||
* @param mode the mode. See Linux spidev doc
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
mode(Spi_Mode mode)
|
||||
{
|
||||
return mraa_spi_mode(m_spi, (mraa_spi_mode_t) mode);
|
||||
return (Result) mraa_spi_mode(m_spi, (mraa_spi_mode_t) mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,10 +96,10 @@ class Spi
|
||||
* @param hz the frequency to set in hz
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
frequency(int hz)
|
||||
{
|
||||
return mraa_spi_frequency(m_spi, hz);
|
||||
return (Result) mraa_spi_frequency(m_spi, hz);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,10 +168,10 @@ class Spi
|
||||
* @param length size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
transfer(uint8_t* txBuf, uint8_t* rxBuf, int length)
|
||||
{
|
||||
return mraa_spi_transfer_buf(m_spi, txBuf, rxBuf, length);
|
||||
return (Result) mraa_spi_transfer_buf(m_spi, txBuf, rxBuf, length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,10 +183,10 @@ class Spi
|
||||
* @param length size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
transfer_word(uint16_t* txBuf, uint16_t* rxBuf, int length)
|
||||
{
|
||||
return mraa_spi_transfer_buf_word(m_spi, txBuf, rxBuf, length);
|
||||
return (Result) mraa_spi_transfer_buf_word(m_spi, txBuf, rxBuf, length);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -195,10 +196,10 @@ class Spi
|
||||
* @param lsb Use least significant bit transmission - 0 for msbi
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
lsbmode(bool lsb)
|
||||
{
|
||||
return mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb);
|
||||
return (Result) mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,10 +208,10 @@ class Spi
|
||||
* @param bits bits per word
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
bitPerWord(unsigned int bits)
|
||||
{
|
||||
return mraa_spi_bit_per_word(m_spi, bits);
|
||||
return (Result) mraa_spi_bit_per_word(m_spi, bits);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
234
api/mraa/types.hpp
Normal file
234
api/mraa/types.hpp
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright © 2014 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @file
|
||||
*
|
||||
* This file defines the basic shared types for libmraa
|
||||
* this file is different to common.h in that swig takes this as an input
|
||||
*/
|
||||
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
//These enums must match the enums in types.h
|
||||
|
||||
/**
|
||||
* MRAA supported platform types
|
||||
*/
|
||||
typedef enum {
|
||||
INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
|
||||
INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
|
||||
INTEL_EDISON_FAB_C = 2, /**< The Intel Edison (FAB C) */
|
||||
INTEL_DE3815 = 3, /**< The Intel DE3815 Baytrail NUC */
|
||||
INTEL_MINNOWBOARD_MAX = 4, /**< The Intel Minnow Board Max */
|
||||
RASPBERRY_PI = 5, /**< The different Raspberry PI Models -like A,B,A+,B+ */
|
||||
BEAGLEBONE = 6, /**< The different BeagleBone Black Modes B/C */
|
||||
BANANA = 7, /**< Allwinner A20 based Banana Pi and Banana Pro */
|
||||
|
||||
UNKNOWN_PLATFORM =
|
||||
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
} Platform;
|
||||
|
||||
/**
|
||||
* Intel edison miniboard numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
INTEL_EDISON_MINIBOARD_J17_1 = 0,
|
||||
INTEL_EDISON_MINIBOARD_J17_5 = 4,
|
||||
INTEL_EDISON_MINIBOARD_J17_7 = 6,
|
||||
INTEL_EDISON_MINIBOARD_J17_8 = 7,
|
||||
INTEL_EDISON_MINIBOARD_J17_9 = 8,
|
||||
INTEL_EDISON_MINIBOARD_J17_10 = 9,
|
||||
INTEL_EDISON_MINIBOARD_J17_11 = 10,
|
||||
INTEL_EDISON_MINIBOARD_J17_12 = 11,
|
||||
INTEL_EDISON_MINIBOARD_J17_14 = 13,
|
||||
INTEL_EDISON_MINIBOARD_J18_1 = 14,
|
||||
INTEL_EDISON_MINIBOARD_J18_2 = 15,
|
||||
INTEL_EDISON_MINIBOARD_J18_6 = 19,
|
||||
INTEL_EDISON_MINIBOARD_J18_7 = 20,
|
||||
INTEL_EDISON_MINIBOARD_J18_8 = 21,
|
||||
INTEL_EDISON_MINIBOARD_J18_10 = 23,
|
||||
INTEL_EDISON_MINIBOARD_J18_11 = 24,
|
||||
INTEL_EDISON_MINIBOARD_J18_12 = 25,
|
||||
INTEL_EDISON_MINIBOARD_J18_13 = 26,
|
||||
INTEL_EDISON_MINIBOARD_J19_4 = 31,
|
||||
INTEL_EDISON_MINIBOARD_J19_5 = 32,
|
||||
INTEL_EDISON_MINIBOARD_J19_6 = 33,
|
||||
INTEL_EDISON_MINIBOARD_J19_8 = 35,
|
||||
INTEL_EDISON_MINIBOARD_J19_9 = 36,
|
||||
INTEL_EDISON_MINIBOARD_J19_10 = 37,
|
||||
INTEL_EDISON_MINIBOARD_J19_11 = 38,
|
||||
INTEL_EDISON_MINIBOARD_J19_12 = 39,
|
||||
INTEL_EDISON_MINIBOARD_J19_13 = 40,
|
||||
INTEL_EDISON_MINIBOARD_J19_14 = 41,
|
||||
INTEL_EDISON_MINIBOARD_J20_3 = 44,
|
||||
INTEL_EDISON_MINIBOARD_J20_4 = 45,
|
||||
INTEL_EDISON_MINIBOARD_J20_5 = 46,
|
||||
INTEL_EDISON_MINIBOARD_J20_6 = 47,
|
||||
INTEL_EDISON_MINIBOARD_J20_7 = 48,
|
||||
INTEL_EDISON_MINIBOARD_J20_8 = 49,
|
||||
INTEL_EDISON_MINIBOARD_J20_9 = 50,
|
||||
INTEL_EDISON_MINIBOARD_J20_10 = 51,
|
||||
INTEL_EDISON_MINIBOARD_J20_11 = 52,
|
||||
INTEL_EDISON_MINIBOARD_J20_12 = 53,
|
||||
INTEL_EDISON_MINIBOARD_J20_13 = 54,
|
||||
INTEL_EDISON_MINIBOARD_J20_14 = 55
|
||||
} IntelEdisonMiniboard;
|
||||
|
||||
/**
|
||||
* Intel Edison raw GPIO numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
INTEL_EDISON_GP182 = 0,
|
||||
INTEL_EDISON_GP135 = 4,
|
||||
INTEL_EDISON_GP27 = 6,
|
||||
INTEL_EDISON_GP20 = 7,
|
||||
INTEL_EDISON_GP28 = 8,
|
||||
INTEL_EDISON_GP111 = 0,
|
||||
INTEL_EDISON_GP109 = 10,
|
||||
INTEL_EDISON_GP115 = 11,
|
||||
INTEL_EDISON_GP128 = 13,
|
||||
INTEL_EDISON_GP13 = 14,
|
||||
INTEL_EDISON_GP165 = 15,
|
||||
INTEL_EDISON_GP19 = 19,
|
||||
INTEL_EDISON_GP12 = 20,
|
||||
INTEL_EDISON_GP183 = 21,
|
||||
INTEL_EDISON_GP110 = 23,
|
||||
INTEL_EDISON_GP114 = 24,
|
||||
INTEL_EDISON_GP129 = 25,
|
||||
INTEL_EDISON_GP130 = 26,
|
||||
INTEL_EDISON_GP44 = 31,
|
||||
INTEL_EDISON_GP46 = 32,
|
||||
INTEL_EDISON_GP48 = 33,
|
||||
INTEL_EDISON_GP131 = 35,
|
||||
INTEL_EDISON_GP14 = 36,
|
||||
INTEL_EDISON_GP40 = 37,
|
||||
INTEL_EDISON_GP43 = 38,
|
||||
INTEL_EDISON_GP77 = 39,
|
||||
INTEL_EDISON_GP82 = 40,
|
||||
INTEL_EDISON_GP83 = 41,
|
||||
INTEL_EDISON_GP134 = 44,
|
||||
INTEL_EDISON_GP45 = 45,
|
||||
INTEL_EDISON_GP47 = 46,
|
||||
INTEL_EDISON_GP49 = 47,
|
||||
INTEL_EDISON_GP15 = 48,
|
||||
INTEL_EDISON_GP84 = 49,
|
||||
INTEL_EDISON_GP42 = 50,
|
||||
INTEL_EDISON_GP41 = 51,
|
||||
INTEL_EDISON_GP78 = 52,
|
||||
INTEL_EDISON_GP79 = 53,
|
||||
INTEL_EDISON_GP80 = 54,
|
||||
INTEL_EDISON_GP81 = 55
|
||||
} IntelEdison;
|
||||
|
||||
/**
|
||||
* Raspberry PI Wiring compatible numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
RASPBERRY_WIRING_PIN8 = 3,
|
||||
RASPBERRY_WIRING_PIN9 = 5,
|
||||
RASPBERRY_WIRING_PIN7 = 7,
|
||||
RASPBERRY_WIRING_PIN15 = 8,
|
||||
RASPBERRY_WIRING_PIN16 = 10,
|
||||
RASPBERRY_WIRING_PIN0 = 11,
|
||||
RASPBERRY_WIRING_PIN1 = 12,
|
||||
RASPBERRY_WIRING_PIN2 = 13,
|
||||
RASPBERRY_WIRING_PIN3 = 15,
|
||||
RASPBERRY_WIRING_PIN4 = 16,
|
||||
RASPBERRY_WIRING_PIN5 = 18,
|
||||
RASPBERRY_WIRING_PIN12 = 19,
|
||||
RASPBERRY_WIRING_PIN13 = 21,
|
||||
RASPBERRY_WIRING_PIN6 = 22,
|
||||
RASPBERRY_WIRING_PIN14 = 23,
|
||||
RASPBERRY_WIRING_PIN10 = 24,
|
||||
RASPBERRY_WIRING_PIN11 = 26,
|
||||
RASPBERRY_WIRING_PIN17 = 29, // RPi B V2
|
||||
RASPBERRY_WIRING_PIN21 = 29,
|
||||
RASPBERRY_WIRING_PIN18 = 30, // RPi B V2
|
||||
RASPBERRY_WIRING_PIN19 = 31, // RPI B V2
|
||||
RASPBERRY_WIRING_PIN22 = 31,
|
||||
RASPBERRY_WIRING_PIN20 = 32, // RPi B V2
|
||||
RASPBERRY_WIRING_PIN26 = 32,
|
||||
RASPBERRY_WIRING_PIN23 = 33,
|
||||
RASPBERRY_WIRING_PIN24 = 35,
|
||||
RASPBERRY_WIRING_PIN27 = 36,
|
||||
RASPBERRY_WIRING_PIN25 = 37,
|
||||
RASPBERRY_WIRING_PIN28 = 38,
|
||||
RASPBERRY_WIRING_PIN29 = 40
|
||||
} RaspberryWiring;
|
||||
|
||||
/**
|
||||
* MRAA return codes
|
||||
*/
|
||||
typedef enum {
|
||||
SUCCESS = 0, /**< Expected response */
|
||||
ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
|
||||
ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
|
||||
ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
|
||||
ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
|
||||
ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
|
||||
ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
|
||||
ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
|
||||
ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
|
||||
ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
|
||||
ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
|
||||
ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
|
||||
ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
|
||||
|
||||
ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
} Result;
|
||||
|
||||
/**
|
||||
* Enum representing different possible modes for a pin.
|
||||
*/
|
||||
typedef enum {
|
||||
PIN_VALID = 0, /**< Pin Valid */
|
||||
PIN_GPIO = 1, /**< General Purpose IO */
|
||||
PIN_PWM = 2, /**< Pulse Width Modulation */
|
||||
PIN_FAST_GPIO = 3, /**< Faster GPIO */
|
||||
PIN_SPI = 4, /**< SPI */
|
||||
PIN_I2C = 5, /**< I2C */
|
||||
PIN_AIO = 6, /**< Analog in */
|
||||
PIN_UART = 7 /**< UART */
|
||||
} Pinmodes;
|
||||
|
||||
/**
|
||||
* Enum reprensenting different i2c speeds/modes
|
||||
*/
|
||||
typedef enum {
|
||||
I2C_STD = 0, /**< up to 100Khz */
|
||||
I2C_FAST = 1, /**< up to 400Khz */
|
||||
I2C_HIGH = 2 /**< up to 3.4Mhz */
|
||||
} I2cMode;
|
||||
|
||||
typedef enum {
|
||||
UART_PARITY_NONE = 0,
|
||||
UART_PARITY_EVEN = 1,
|
||||
UART_PARITY_ODD = 2,
|
||||
UART_PARITY_MARK = 3,
|
||||
UART_PARITY_SPACE = 4
|
||||
} UartParity;
|
||||
|
||||
}
|
||||
@@ -170,10 +170,10 @@ class Uart
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
flush()
|
||||
{
|
||||
return mraa_uart_flush(m_uart);
|
||||
return (Result) mraa_uart_flush(m_uart);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,26 +184,26 @@ class Uart
|
||||
* @param baud unsigned int of baudrate i.e. 9600
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
setBaudRate(unsigned int baud)
|
||||
{
|
||||
return mraa_uart_set_baudrate(m_uart, baud);
|
||||
return (Result) mraa_uart_set_baudrate(m_uart, baud);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the transfer mode
|
||||
* For example setting the mode to 8N1 would be
|
||||
* "dev.setMode(8,MRAA_UART_PARITY_NONE , 1)"
|
||||
* "dev.setMode(8,UART_PARITY_NONE , 1)"
|
||||
*
|
||||
* @param bytesize data bits
|
||||
* @param parity Parity bit setting
|
||||
* @param stopbits stop bits
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
setMode(int bytesize, mraa_uart_parity_t parity, int stopbits)
|
||||
Result
|
||||
setMode(int bytesize, UartParity parity, int stopbits)
|
||||
{
|
||||
return mraa_uart_set_mode(m_uart, bytesize, parity, stopbits);
|
||||
return (Result) mraa_uart_set_mode(m_uart, bytesize, (mraa_uart_parity_t) parity, stopbits);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,10 +213,10 @@ class Uart
|
||||
* @param rtscts RTS/CTS out of band hardware flow control
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
setFlowcontrol(bool xonxoff, bool rtscts)
|
||||
{
|
||||
return mraa_uart_set_flowcontrol(m_uart, xonxoff, rtscts);
|
||||
return (Result) mraa_uart_set_flowcontrol(m_uart, xonxoff, rtscts);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,10 +228,10 @@ class Uart
|
||||
* @param interchar inbetween char timeout
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
Result
|
||||
setTimeout(int read, int write, int interchar)
|
||||
{
|
||||
return mraa_uart_set_timeout(m_uart, read, write, interchar);
|
||||
return (Result) mraa_uart_set_timeout(m_uart, read, write, interchar);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -58,10 +58,10 @@ main(int argc, char** argv)
|
||||
//! [Interesting]
|
||||
mraa::Gpio* gpio = new mraa::Gpio(iopin);
|
||||
if (gpio == NULL) {
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
return mraa::ERROR_UNSPECIFIED;
|
||||
}
|
||||
mraa_result_t response = gpio->dir(mraa::DIR_OUT);
|
||||
if (response != MRAA_SUCCESS) {
|
||||
mraa::Result response = gpio->dir(mraa::DIR_OUT);
|
||||
if (response != mraa::SUCCESS) {
|
||||
mraa::printError(response);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ main()
|
||||
}
|
||||
for (i = 130; i > 90; i--) {
|
||||
data[1] = i;
|
||||
if (spi->transfer(data, rxBuf, 2) == MRAA_SUCCESS) {
|
||||
if (spi->transfer(data, rxBuf, 2) == mraa::SUCCESS) {
|
||||
printf("Writing -%i", i);
|
||||
printf("RECIVED-%i-%i\n", rxBuf[0], rxBuf[1]);
|
||||
}
|
||||
@@ -76,5 +76,5 @@ main()
|
||||
delete spi;
|
||||
//! [Interesting]
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
return mraa::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -49,15 +49,15 @@ main()
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
if (dev->setBaudRate(115200) != MRAA_SUCCESS) {
|
||||
if (dev->setBaudRate(115200) != mraa::SUCCESS) {
|
||||
std::cout << "Error setting parity on UART" << std::endl;
|
||||
}
|
||||
|
||||
if (dev->setMode(8, MRAA_UART_PARITY_NONE, 1) != MRAA_SUCCESS) {
|
||||
if (dev->setMode(8, mraa::UART_PARITY_NONE, 1) != mraa::SUCCESS) {
|
||||
std::cout << "Error setting parity on UART" << std::endl;
|
||||
}
|
||||
|
||||
if (dev->setFlowcontrol(false, false) != MRAA_SUCCESS) {
|
||||
if (dev->setFlowcontrol(false, false) != mraa::SUCCESS) {
|
||||
std::cout << "Error setting flow control UART" << std::endl;
|
||||
}
|
||||
|
||||
@@ -66,5 +66,5 @@ main()
|
||||
|
||||
delete dev;
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
return mraa::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
%{
|
||||
#include "common.hpp"
|
||||
#include "types.hpp"
|
||||
#include "gpio.hpp"
|
||||
#include "pwm.hpp"
|
||||
#include "i2c.hpp"
|
||||
@@ -37,9 +38,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
%include "common.hpp"
|
||||
%include "types.hpp"
|
||||
|
||||
%include "types.h"
|
||||
%include "common.hpp"
|
||||
|
||||
%ignore Gpio::nop(uv_work_t* req);
|
||||
%ignore Gpio::v8isr(uv_work_t* req);
|
||||
|
||||
Reference in New Issue
Block a user