--- /dev/null
+AccessModifierOffset: -2
+AlignEscapedNewlinesLeft: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortFunctionsOnASingleLine: false
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+AlwaysBreakAfterDefinitionReturnType: true
+BinPackParameters: false
+BreakBeforeBinaryOperators: false
+BreakBeforeBraces: Linux
+BreakBeforeTernaryOperators: false
+BreakConstructorInitializersBeforeComma: false
+ColumnLimit: 100
+CommentPragmas: ''
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 0
+ContinuationIndentWidth: 0
+Cpp11BracedListStyle: false
+DerivePointerBinding: false
+IndentCaseLabels: true
+IndentFunctionDeclarationAfterType: false
+IndentWidth: 4
+Language: Cpp
+MaxEmptyLinesToKeep: 2
+NamespaceIndentation: None
+ObjCSpaceAfterProperty: true
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 100
+PenaltyBreakComment: 100
+PenaltyBreakFirstLessLess: 0
+PenaltyBreakString: 100
+PenaltyExcessCharacter: 1
+PenaltyReturnTypeOnItsOwnLine: 20
+PointerBindsToType: true
+PointerAlignment: Left
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInCStyleCastParentheses: false
+SpaceAfterCStyleCast: true
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+Standard: Cpp11
+TabWidth: 4
+UseTab: Never
#include <stdexcept>
#include "aio.h"
-namespace mraa {
+namespace mraa
+{
/**
* @brief API to Analog IO
*
* @snippet examples/c++/AioA0.cpp Interesting
*/
-class Aio {
- public:
- /**
- * Aio Constructor, takes a pin number which will map directly to the
- * board number
- *
- * @param pin channel number to read ADC inputs
- */
- Aio(unsigned int pin) {
- m_aio = mraa_aio_init(pin);
- if (m_aio == NULL) {
- throw std::invalid_argument("Invalid AIO pin specified - do you have an ADC?");
- }
- }
- /**
- * Aio destructor
- */
- ~Aio() {
- mraa_aio_close(m_aio);
- }
- /**
- * Read a value from the AIO pin. By default mraa will shift
- * the raw value up or down to a 10 bit value.
- *
- * @returns The current input voltage. By default, a 10bit value
- */
- int read() {
- return mraa_aio_read(m_aio);
- }
- /**
- * Read a value from the AIO pin and return it as a normalized float.
- *
- * @returns The current input voltage as a normalized float (0.0f-1.0f)
- */
- float readFloat() {
- return mraa_aio_read_float(m_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
- */
- mraa_result_t setBit(int bits) {
- return mraa_aio_set_bit(m_aio, bits);
- }
- /**
- * Gets the bit value mraa is shifting the analog read to.
- *
- * @return bit value mraa is set return from the read function
- */
- int getBit() {
- return mraa_aio_get_bit(m_aio);
+class Aio
+{
+ public:
+ /**
+ * Aio Constructor, takes a pin number which will map directly to the
+ * board number
+ *
+ * @param pin channel number to read ADC inputs
+ */
+ Aio(unsigned int pin)
+ {
+ m_aio = mraa_aio_init(pin);
+ if (m_aio == NULL) {
+ throw std::invalid_argument("Invalid AIO pin specified - do you have an ADC?");
}
+ }
+ /**
+ * Aio destructor
+ */
+ ~Aio()
+ {
+ mraa_aio_close(m_aio);
+ }
+ /**
+ * Read a value from the AIO pin. By default mraa will shift
+ * the raw value up or down to a 10 bit value.
+ *
+ * @returns The current input voltage. By default, a 10bit value
+ */
+ int
+ read()
+ {
+ return mraa_aio_read(m_aio);
+ }
+ /**
+ * Read a value from the AIO pin and return it as a normalized float.
+ *
+ * @returns The current input voltage as a normalized float (0.0f-1.0f)
+ */
+ float
+ readFloat()
+ {
+ return mraa_aio_read_float(m_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
+ */
+ mraa_result_t
+ setBit(int bits)
+ {
+ return mraa_aio_set_bit(m_aio, bits);
+ }
+ /**
+ * Gets the bit value mraa is shifting the analog read to.
+ *
+ * @return bit value mraa is set return from the read function
+ */
+ int
+ getBit()
+ {
+ return mraa_aio_get_bit(m_aio);
+ }
- private:
- mraa_aio_context m_aio;
+ private:
+ mraa_aio_context m_aio;
};
-
}
/**
* @namespace mraa namespace
*/
-namespace mraa {
+namespace mraa
+{
/**
* @file
*
* @return Result of operation
*/
-inline mraa_result_t init()
+inline mraa_result_t
+init()
{
return mraa_init();
}
*
* @return libmraa version (e.g. v0.4.0-20-gb408207)
*/
-inline std::string getVersion()
+inline std::string
+getVersion()
{
std::string ret = mraa_get_version();
return ret;
* @param priority Value from typically 0 to 99
* @return The priority value set
*/
-inline int setPriority(const unsigned int priority)
+inline int
+setPriority(const unsigned int priority)
{
return mraa_set_priority(priority);
}
*
* @return mraa_platform_t Platform type enum
*/
-inline mraa_platform_t getPlatformType()
+inline mraa_platform_t
+getPlatformType()
{
return mraa_get_platform_type();
}
*
* @param result the result to print
*/
-inline void printError(mraa_result_t result)
+inline void
+printError(mraa_result_t result)
{
mraa_result_print(result);
}
* @param mode the mode to be tested.
* @return boolean if the mode is supported, 0=false.
*/
-inline bool pinModeTest(int pin, mraa_pinmodes_t mode)
+inline bool
+pinModeTest(int pin, mraa_pinmodes_t mode)
{
- return (bool) mraa_pin_mode_test(pin,mode);
+ return (bool) mraa_pin_mode_test(pin, mode);
}
/**
*
* @return raw bits being read from kernel module. Zero if no ADC
*/
-inline unsigned int adcRawBits()
+inline unsigned int
+adcRawBits()
{
return mraa_adc_raw_bits();
}
*
* @return return actual bit size the adc value should be understood as.
*/
-inline unsigned int adcSupportedBits()
+inline unsigned int
+adcSupportedBits()
{
return mraa_adc_supported_bits();
}
*
* @return platform name
*/
-inline std::string getPlatformName()
+inline std::string
+getPlatformName()
{
std::string ret_val(mraa_get_platform_name());
return ret_val;
*
* @return uint of physical pins.
*/
-inline unsigned int getPinCount()
+inline unsigned int
+getPinCount()
{
return mraa_get_pin_count();
}
*
* @return char* of pin name
*/
-inline std::string getPinName(int pin)
+inline std::string
+getPinName(int pin)
{
std::string ret_val(mraa_get_pin_name(pin));
return ret_val;
* @param level
* @return Result of operation
*/
-inline mraa_result_t setLogLevel(int level)
+inline mraa_result_t
+setLogLevel(int level)
{
return mraa_set_log_level(level);
}
-
}
* Gpio Output modes
*/
typedef enum {
- MRAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
- MRAA_GPIO_PULLUP = 1, /**< Resistive High */
- MRAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
- MRAA_GPIO_HIZ = 3 /**< High Z State */
+ MRAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
+ MRAA_GPIO_PULLUP = 1, /**< Resistive High */
+ MRAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
+ MRAA_GPIO_HIZ = 3 /**< High Z State */
} gpio_mode_t;
/**
* Gpio Direction options
*/
typedef enum {
- MRAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
- MRAA_GPIO_IN = 1, /**< Input */
+ MRAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
+ MRAA_GPIO_IN = 1, /**< Input */
MRAA_GPIO_OUT_HIGH = 2, /**< Output. Init High */
- MRAA_GPIO_OUT_LOW = 3 /**< Output. Init Low */
+ MRAA_GPIO_OUT_LOW = 3 /**< Output. Init Low */
} gpio_dir_t;
/**
* Gpio Edge types for interupts
*/
typedef enum {
- MRAA_GPIO_EDGE_NONE = 0, /**< No interrupt on Gpio */
- MRAA_GPIO_EDGE_BOTH = 1, /**< Interupt on rising & falling */
- MRAA_GPIO_EDGE_RISING = 2, /**< Interupt on rising only */
- MRAA_GPIO_EDGE_FALLING = 3 /**< Interupt on falling only */
+ 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 args Arguments passed to the interrupt handler (fptr)
* @return Result of operation
*/
-mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, gpio_edge_t edge, void (*fptr)(void *), void * args);
+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
#include <stdexcept>
#if defined(SWIGJAVASCRIPT)
- #if NODE_MODULE_VERSION >= 0x000D
- #include <uv.h>
- #endif
+#if NODE_MODULE_VERSION >= 0x000D
+#include <uv.h>
+#endif
#endif
-namespace mraa {
+namespace mraa
+{
// These enums must match the enums in gpio.h
* Gpio Output modes
*/
typedef enum {
- MODE_STRONG = 0, /**< Default. Strong High and Low */
- MODE_PULLUP = 1, /**< Interupt on rising & falling */
+ MODE_STRONG = 0, /**< Default. Strong High and Low */
+ MODE_PULLUP = 1, /**< Interupt on rising & falling */
MODE_PULLDOWN = 2, /**< Interupt on rising only */
- MODE_HIZ = 3 /**< Interupt on falling only */
+ MODE_HIZ = 3 /**< Interupt on falling only */
} Mode;
/**
* Gpio Direction options
*/
typedef enum {
- DIR_OUT = 0, /**< Output. A Mode can also be set */
- DIR_IN = 1, /**< Input */
+ DIR_OUT = 0, /**< Output. A Mode can also be set */
+ DIR_IN = 1, /**< Input */
DIR_OUT_HIGH = 2, /**< Output. Init High */
- DIR_OUT_LOW = 3 /**< Output. Init Low */
+ DIR_OUT_LOW = 3 /**< Output. Init Low */
} Dir;
/**
* Gpio Edge types for interupts
*/
typedef enum {
- EDGE_NONE = 0, /**< No interrupt on Gpio */
- EDGE_BOTH = 1, /**< Interupt on rising & falling */
- EDGE_RISING = 2, /**< Interupt on rising only */
- EDGE_FALLING = 3 /**< Interupt on falling only */
+ EDGE_NONE = 0, /**< No interrupt on Gpio */
+ EDGE_BOTH = 1, /**< Interupt on rising & falling */
+ EDGE_RISING = 2, /**< Interupt on rising only */
+ EDGE_FALLING = 3 /**< Interupt on falling only */
} Edge;
/**
*
* @snippet Blink-IO.cpp Interesting
*/
-class Gpio {
- public:
- /**
- * Instanciates a Gpio object
- *
- * @param pin pin number to use
- * @param owner (optional) Set pin owner, default behaviour is to 'own'
- * the pin if we exported it. This means we will close it on destruct.
- * Otherwise it will get left open. This is only valid in sysfs use
- * cases
- * @param raw (optional) Raw pins will use gpiolibs pin numbering from
- * the kernel module. Note that you will not get any muxers set up for
- * you so this may not always work as expected.
- */
- Gpio(int pin, bool owner=true, bool raw=false) {
- if (raw) {
- m_gpio = mraa_gpio_init_raw(pin);
- }
- else {
- m_gpio = mraa_gpio_init(pin);
- }
-
- if (m_gpio == NULL) {
- throw std::invalid_argument("Invalid GPIO pin specified");
- }
-
- if (!owner) {
- mraa_gpio_owner(m_gpio, 0);
- }
+class Gpio
+{
+ public:
+ /**
+ * Instanciates a Gpio object
+ *
+ * @param pin pin number to use
+ * @param owner (optional) Set pin owner, default behaviour is to 'own'
+ * the pin if we exported it. This means we will close it on destruct.
+ * Otherwise it will get left open. This is only valid in sysfs use
+ * cases
+ * @param raw (optional) Raw pins will use gpiolibs pin numbering from
+ * the kernel module. Note that you will not get any muxers set up for
+ * you so this may not always work as expected.
+ */
+ Gpio(int pin, bool owner = true, bool raw = false)
+ {
+ if (raw) {
+ m_gpio = mraa_gpio_init_raw(pin);
+ } else {
+ m_gpio = mraa_gpio_init(pin);
}
- /**
- * Gpio object destructor, this will only unexport the gpio if we where
- * the owner
- */
- ~Gpio() {
- mraa_gpio_close(m_gpio);
+
+ if (m_gpio == NULL) {
+ throw std::invalid_argument("Invalid GPIO pin specified");
}
- /**
- * Set the edge mode for ISR
- *
- * @param mode The edge mode to set
- * @return Result of operation
- */
- mraa_result_t edge(Edge mode) {
- return mraa_gpio_edge_mode(m_gpio, (gpio_edge_t) mode);
+
+ if (!owner) {
+ mraa_gpio_owner(m_gpio, 0);
}
+ }
+ /**
+ * Gpio object destructor, this will only unexport the gpio if we where
+ * the owner
+ */
+ ~Gpio()
+ {
+ mraa_gpio_close(m_gpio);
+ }
+ /**
+ * Set the edge mode for ISR
+ *
+ * @param mode The edge mode to set
+ * @return Result of operation
+ */
+ mraa_result_t
+ edge(Edge mode)
+ {
+ return mraa_gpio_edge_mode(m_gpio, (gpio_edge_t) mode);
+ }
#if defined(SWIGPYTHON)
- mraa_result_t isr(Edge mode, PyObject *pyfunc, PyObject* args) {
- return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, (void (*) (void *)) pyfunc, (void *) args);
- }
+ 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);
+ }
#elif defined(SWIGJAVASCRIPT)
- static void v8isr(uv_work_t* req, int status) {
- mraa::Gpio *This = (mraa::Gpio *)req->data;
- int argc = 1;
- v8::Local<v8::Value> argv[] = { SWIGV8_INTEGER_NEW(-1) };
+ static void
+ v8isr(uv_work_t* req, int status)
+ {
+ mraa::Gpio* This = (mraa::Gpio*) req->data;
+ int argc = 1;
+ v8::Local<v8::Value> argv[] = { SWIGV8_INTEGER_NEW(-1) };
#if NODE_MODULE_VERSION >= 0x000D
- v8::Local<v8::Function> f = v8::Local<v8::Function>::New(v8::Isolate::GetCurrent(), This->m_v8isr);
- f->Call(SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::New(v8::Isolate::GetCurrent(), This->m_v8isr);
+ f->Call(SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);
#else
- This->m_v8isr->Call(SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);
+ This->m_v8isr->Call(SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);
#endif
- delete req;
- }
+ delete req;
+ }
- static void nop(uv_work_t* req)
- {
- // Do nothing.
- }
+ static void
+ nop(uv_work_t* req)
+ {
+ // Do nothing.
+ }
- static void uvwork(void *ctx) {
- uv_work_t* req = new uv_work_t;
- req->data = ctx;
- uv_queue_work(uv_default_loop(), req, nop, v8isr);
- }
+ static void
+ uvwork(void* ctx)
+ {
+ uv_work_t* req = new uv_work_t;
+ req->data = ctx;
+ uv_queue_work(uv_default_loop(), req, nop, v8isr);
+ }
- mraa_result_t isr(Edge mode, v8::Handle<v8::Function> func) {
+ mraa_result_t
+ isr(Edge mode, v8::Handle<v8::Function> func)
+ {
#if NODE_MODULE_VERSION >= 0x000D
- m_v8isr.Reset(v8::Isolate::GetCurrent(), func);
+ m_v8isr.Reset(v8::Isolate::GetCurrent(), func);
#else
- m_v8isr = v8::Persistent<v8::Function>::New(func);
+ m_v8isr = v8::Persistent<v8::Function>::New(func);
#endif
- return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, &uvwork, this);
- }
+ return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, &uvwork, this);
+ }
#else
- /**
- * Sets a callback to be called when pin value changes
- *
- * @param mode The edge mode to set
- * @param fptr Function pointer to function to be called when interupt is
- * triggered
- * @param args Arguments passed to the interrupt handler (fptr)
- * @return Result of operation
- */
- mraa_result_t isr(Edge mode, void (*fptr)(void *), void * args) {
- return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, fptr, args);
- }
+ /**
+ * Sets a callback to be called when pin value changes
+ *
+ * @param mode The edge mode to set
+ * @param fptr Function pointer to function to be called when interupt is
+ * triggered
+ * @param args Arguments passed to the interrupt handler (fptr)
+ * @return Result of operation
+ */
+ mraa_result_t
+ isr(Edge mode, void (*fptr)(void*), void* args)
+ {
+ return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, fptr, args);
+ }
#endif
- /**
- * Exits callback - this call will not kill the isr thread imediatlu
- * but only when it is out of it's critical section
- *
- * @return Result of operation
- */
- mraa_result_t isrExit() {
+ /**
+ * Exits callback - this call will not kill the isr thread imediatlu
+ * but only when it is out of it's critical section
+ *
+ * @return Result of operation
+ */
+ mraa_result_t
+ isrExit()
+ {
#if defined(SWIGJAVASCRIPT)
- #if NODE_MODULE_VERSION >= 0x000D
- m_v8isr.Reset();
- #else
- m_v8isr.Dispose();
- m_v8isr.Clear();
- #endif
+#if NODE_MODULE_VERSION >= 0x000D
+ m_v8isr.Reset();
+#else
+ m_v8isr.Dispose();
+ m_v8isr.Clear();
#endif
- return mraa_gpio_isr_exit(m_gpio);
- }
- /**
- * Change Gpio mode
- *
- * @param mode The mode to change the gpio into
- * @return Result of operation
- */
- mraa_result_t mode(Mode mode) {
- return mraa_gpio_mode(m_gpio, (gpio_mode_t) mode);
- }
- /**
- * Change Gpio direction
- *
- * @param dir The direction to change the gpio into
- * @return Result of operation
- */
- mraa_result_t dir(Dir dir) {
- return mraa_gpio_dir(m_gpio, (gpio_dir_t) dir);
- }
- /**
- * Read value from Gpio
- *
- * @return Gpio value
- */
- int read() {
- return mraa_gpio_read(m_gpio);
- }
- /**
- * Write value to Gpio
- *
- * @param value Value to write to Gpio
- * @return Result of operation
- */
- mraa_result_t write(int value) {
- return mraa_gpio_write(m_gpio, value);
- }
- /**
- * Enable use of mmap i/o if available.
- *
- * @param enable true to use mmap
- * @return Result of operation
- */
- mraa_result_t useMmap(bool enable) {
- return mraa_gpio_use_mmaped(m_gpio, (mraa_boolean_t) enable);
- }
- /**
- * Get pin number of Gpio. If raw param is True will return the
- * number as used within sysfs
- *
- * @param raw (optional) get the raw gpio number.
- * @return Pin number
- */
- int getPin(bool raw = false) {
- if (raw) {
- return mraa_gpio_get_pin_raw(m_gpio);
- }
- return mraa_gpio_get_pin(m_gpio);
+#endif
+ return mraa_gpio_isr_exit(m_gpio);
+ }
+ /**
+ * Change Gpio mode
+ *
+ * @param mode The mode to change the gpio into
+ * @return Result of operation
+ */
+ mraa_result_t
+ mode(Mode mode)
+ {
+ return mraa_gpio_mode(m_gpio, (gpio_mode_t) mode);
+ }
+ /**
+ * Change Gpio direction
+ *
+ * @param dir The direction to change the gpio into
+ * @return Result of operation
+ */
+ mraa_result_t
+ dir(Dir dir)
+ {
+ return mraa_gpio_dir(m_gpio, (gpio_dir_t) dir);
+ }
+ /**
+ * Read value from Gpio
+ *
+ * @return Gpio value
+ */
+ int
+ read()
+ {
+ return mraa_gpio_read(m_gpio);
+ }
+ /**
+ * Write value to Gpio
+ *
+ * @param value Value to write to Gpio
+ * @return Result of operation
+ */
+ mraa_result_t
+ write(int value)
+ {
+ return mraa_gpio_write(m_gpio, value);
+ }
+ /**
+ * Enable use of mmap i/o if available.
+ *
+ * @param enable true to use mmap
+ * @return Result of operation
+ */
+ mraa_result_t
+ useMmap(bool enable)
+ {
+ return mraa_gpio_use_mmaped(m_gpio, (mraa_boolean_t) enable);
+ }
+ /**
+ * Get pin number of Gpio. If raw param is True will return the
+ * number as used within sysfs
+ *
+ * @param raw (optional) get the raw gpio number.
+ * @return Pin number
+ */
+ int
+ getPin(bool raw = false)
+ {
+ if (raw) {
+ return mraa_gpio_get_pin_raw(m_gpio);
}
- private:
- mraa_gpio_context m_gpio;
+ return mraa_gpio_get_pin(m_gpio);
+ }
+
+ private:
+ mraa_gpio_context m_gpio;
#if defined(SWIGJAVASCRIPT)
- v8::Persistent<v8::Function> m_v8isr;
+ v8::Persistent<v8::Function> m_v8isr;
#endif
};
-
}
* @param length max number of bytes to read
* @return length of the read in bytes or 0
*/
-int mraa_i2c_read(mraa_i2c_context dev, uint8_t *data, int length);
+int mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length);
/**
* Simple read for a single byte from the i2c context, this will always begin
* @param length the number of bytes to transmit
* @return Result of operation
*/
-mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t *data, int length);
+mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length);
/**
* Write a single byte to an i2c context, always at offset 0x0
#include "i2c.h"
#include <stdexcept>
-namespace mraa {
+namespace mraa
+{
/**
* @brief API to Inter-Integrated Circuit
*
* @snippet I2c-compass.cpp Interesting
*/
-class I2c {
- public:
- /**
- * Instantiates an i2c bus. Multiple instances of the same bus can
- * exist and the bus is not guarranteed to be on the correct address
- * before read/write.
- *
- * @param bus The i2c bus to use
- * @param raw Whether to disable pinmapper for your board
- */
- I2c(int bus, bool raw=false) {
- if (raw) {
- m_i2c = mraa_i2c_init_raw(bus);
- }
- else {
- m_i2c = mraa_i2c_init(bus);
- }
- if (m_i2c == NULL) {
- throw std::invalid_argument("Invalid i2c bus");
- }
+class I2c
+{
+ public:
+ /**
+ * Instantiates an i2c bus. Multiple instances of the same bus can
+ * exist and the bus is not guarranteed to be on the correct address
+ * before read/write.
+ *
+ * @param bus The i2c bus to use
+ * @param raw Whether to disable pinmapper for your board
+ */
+ I2c(int bus, bool raw = false)
+ {
+ if (raw) {
+ m_i2c = mraa_i2c_init_raw(bus);
+ } else {
+ m_i2c = mraa_i2c_init(bus);
}
-
- /**
- * Closes the I2c Bus used. This does not guarrantee the bus will not
- * be usable by anyone else or communicates this disconnect to any
- * slaves.
- */
- ~I2c() {
- mraa_i2c_stop(m_i2c);
- }
-
- /**
- * Sets the i2c Frequency for communication. Your board may not support
- * the set frequency. Anyone can change this at any time and this will
- * affect every slave on the bus
- *
- * @param mode Frequency to set the bus to
- * @return Result of operation
- */
- mraa_result_t frequency(mraa_i2c_mode_t mode) {
- return mraa_i2c_frequency(m_i2c, mode);
- }
-
- /**
- * Set the slave to talk to, typically called before every read/write
- * operation
- *
- * @param address Communicate to the i2c slave on this address
- * @return Result of operation
- */
- mraa_result_t address(uint8_t address) {
- return mraa_i2c_address(m_i2c, address);
- }
-
- /**
- * Read exactly one byte from the bus
- *
- * @return char read from the bus
- */
- uint8_t readByte() {
- return (uint8_t) mraa_i2c_read_byte(m_i2c);
- }
-
- /**
- * Read length bytes from the bus into *data pointer
- *
- * @param data Data to read into
- * @param length Size of read in bytes to make
- * @return length of read, should match length
- */
- int read(uint8_t *data, int length) {
- return mraa_i2c_read(m_i2c, data, length);
- }
-
- /**
- * Read byte from an i2c register
- *
- * @param reg Register to read from
- * @return char read from register
- */
- uint8_t readReg(uint8_t reg) {
- return mraa_i2c_read_byte_data(m_i2c, reg);
- }
-
- /**
- * Read word from an i2c register
- *
- * @param reg Register to read from
- * @return char read from register
- */
- uint16_t readWordReg(uint8_t reg) {
- return mraa_i2c_read_word_data(m_i2c, reg);
- }
-
- /**
- * Read length bytes from the bus into *data pointer starting from
- * an i2c register
- *
- * @param reg Register to read from
- * @param data pointer to the byte array to read data in to
- * @param length max number of bytes to read
- * @return length passed to the function or 0
- */
- int readBytesReg(uint8_t reg, uint8_t* data, int length) {
- return mraa_i2c_read_bytes_data(m_i2c, reg, data, length);
- }
-
- /**
- * Write a byte on the bus
- *
- * @param data The byte to send on the bus
- * @return Result of operation
- */
- mraa_result_t writeByte(uint8_t data) {
- return mraa_i2c_write_byte(m_i2c, data);
- }
-
- /**
- * Write length bytes to the bus, the first byte in the array is the
- * command/register to write
- *
- * @param data Buffer to send on the bus, first byte is i2c command
- * @param length Size of buffer to send
- * @return Result of operation
- */
- mraa_result_t write(const uint8_t* data, int length) {
- return mraa_i2c_write(m_i2c, data, length);
- }
-
- /**
- * Write a byte to an i2c register
- *
- * @param reg Register to write to
- * @param data Value to write to register
- * @return Result of operation
- */
- mraa_result_t writeReg(uint8_t reg, uint8_t data) {
- return mraa_i2c_write_byte_data(m_i2c, data, reg);
+ if (m_i2c == NULL) {
+ throw std::invalid_argument("Invalid i2c bus");
}
-
- /**
- * Write a word to an i2c register
- *
- * @param reg Register to write to
- * @param data Value to write to register
- * @return Result of operation
- */
- mraa_result_t writeWordReg(uint8_t reg, uint16_t data) {
- return mraa_i2c_write_word_data(m_i2c, data, reg);
- }
- private:
- mraa_i2c_context m_i2c;
+ }
+
+ /**
+ * Closes the I2c Bus used. This does not guarrantee the bus will not
+ * be usable by anyone else or communicates this disconnect to any
+ * slaves.
+ */
+ ~I2c()
+ {
+ mraa_i2c_stop(m_i2c);
+ }
+
+ /**
+ * Sets the i2c Frequency for communication. Your board may not support
+ * the set frequency. Anyone can change this at any time and this will
+ * affect every slave on the bus
+ *
+ * @param mode Frequency to set the bus to
+ * @return Result of operation
+ */
+ mraa_result_t
+ frequency(mraa_i2c_mode_t mode)
+ {
+ return mraa_i2c_frequency(m_i2c, mode);
+ }
+
+ /**
+ * Set the slave to talk to, typically called before every read/write
+ * operation
+ *
+ * @param address Communicate to the i2c slave on this address
+ * @return Result of operation
+ */
+ mraa_result_t
+ address(uint8_t address)
+ {
+ return mraa_i2c_address(m_i2c, address);
+ }
+
+ /**
+ * Read exactly one byte from the bus
+ *
+ * @return char read from the bus
+ */
+ uint8_t
+ readByte()
+ {
+ return (uint8_t) mraa_i2c_read_byte(m_i2c);
+ }
+
+ /**
+ * Read length bytes from the bus into *data pointer
+ *
+ * @param data Data to read into
+ * @param length Size of read in bytes to make
+ * @return length of read, should match length
+ */
+ int
+ read(uint8_t* data, int length)
+ {
+ return mraa_i2c_read(m_i2c, data, length);
+ }
+
+ /**
+ * Read byte from an i2c register
+ *
+ * @param reg Register to read from
+ * @return char read from register
+ */
+ uint8_t
+ readReg(uint8_t reg)
+ {
+ return mraa_i2c_read_byte_data(m_i2c, reg);
+ }
+
+ /**
+ * Read word from an i2c register
+ *
+ * @param reg Register to read from
+ * @return char read from register
+ */
+ uint16_t
+ readWordReg(uint8_t reg)
+ {
+ return mraa_i2c_read_word_data(m_i2c, reg);
+ }
+
+ /**
+ * Read length bytes from the bus into *data pointer starting from
+ * an i2c register
+ *
+ * @param reg Register to read from
+ * @param data pointer to the byte array to read data in to
+ * @param length max number of bytes to read
+ * @return length passed to the function or 0
+ */
+ int
+ readBytesReg(uint8_t reg, uint8_t* data, int length)
+ {
+ return mraa_i2c_read_bytes_data(m_i2c, reg, data, length);
+ }
+
+ /**
+ * Write a byte on the bus
+ *
+ * @param data The byte to send on the bus
+ * @return Result of operation
+ */
+ mraa_result_t
+ writeByte(uint8_t data)
+ {
+ return mraa_i2c_write_byte(m_i2c, data);
+ }
+
+ /**
+ * Write length bytes to the bus, the first byte in the array is the
+ * command/register to write
+ *
+ * @param data Buffer to send on the bus, first byte is i2c command
+ * @param length Size of buffer to send
+ * @return Result of operation
+ */
+ mraa_result_t
+ write(const uint8_t* data, int length)
+ {
+ return mraa_i2c_write(m_i2c, data, length);
+ }
+
+ /**
+ * Write a byte to an i2c register
+ *
+ * @param reg Register to write to
+ * @param data Value to write to register
+ * @return Result of operation
+ */
+ mraa_result_t
+ writeReg(uint8_t reg, uint8_t data)
+ {
+ return mraa_i2c_write_byte_data(m_i2c, data, reg);
+ }
+
+ /**
+ * Write a word to an i2c register
+ *
+ * @param reg Register to write to
+ * @param data Value to write to register
+ * @return Result of operation
+ */
+ mraa_result_t
+ writeWordReg(uint8_t reg, uint16_t data)
+ {
+ return mraa_i2c_write_word_data(m_i2c, data, reg);
+ }
+
+ private:
+ mraa_i2c_context m_i2c;
};
-
}
#include "pwm.h"
#include <stdexcept>
-namespace mraa {
+namespace mraa
+{
/**
* @brief API to Pulse Width Modulation
*
* @snippet Pwm3-cycle.cpp Interesting
*/
-class Pwm {
- public:
- /**
- * instanciates a PWM object on a pin
- *
- * @param pin the pin number used on your board
- * @param owner if you are the owner of the pin the destructor will
- * @param chipid the pwmchip to use, use only in raw mode
- * unexport the pin from sysfs, default behaviour is you are the owner
- * if the pinmapper exported it
- */
- Pwm(int pin, bool owner=true, int chipid=-1) {
- if (chipid == -1) {
- m_pwm = mraa_pwm_init(pin);
- }
- else {
- m_pwm = mraa_pwm_init_raw(chipid, pin);
- }
-
- if (m_pwm == NULL) {
- throw std::invalid_argument("Error initialising PWM on pin");
- }
-
- if (!owner) {
- mraa_pwm_owner(m_pwm, 0);
- }
- }
- /**
- * Pwm destructor
- */
- ~Pwm() {
- mraa_pwm_close(m_pwm);
- }
- /**
- * Set the output duty-cycle percentage, as a float
- *
- * @param percentage A floating-point value representing percentage of
- * output. The value should lie between 0.0f (representing on 0%) and
- * 1.0f Values above or below this range will be set at either 0.0f or
- * 1.0f
- * @return Result of operation
- */
- mraa_result_t write(float percentage) {
- return mraa_pwm_write(m_pwm, percentage);
- }
- /**
- * Read the ouput duty-cycle percentage, as a float
- *
- * @return A floating-point value representing percentage of
- * output. The value should lie between 0.0f (representing on 0%) and
- * 1.0f Values above or below this range will be set at either 0.0f or
- * 1.0f
- */
- float read() {
- return mraa_pwm_read(m_pwm);
- }
- /**
- * Set the PWM period as seconds represented in a float
- *
- * @param period Period represented as a float in seconds
- * @return Result of operation
- */
- mraa_result_t period(float period) {
- return mraa_pwm_period(m_pwm, period);
- }
- /**
- * Set period, milliseconds
- *
- * @param ms milliseconds for period
- * @return Result of operation
- */
- mraa_result_t period_ms(int ms) {
- return mraa_pwm_period_ms(m_pwm, ms);
- }
- /**
- * Set period, microseconds
- *
- * @param us microseconds as period
- * @return Result of operation
- */
- mraa_result_t period_us(int us) {
- return mraa_pwm_period_us(m_pwm, us);
+class Pwm
+{
+ public:
+ /**
+ * instanciates a PWM object on a pin
+ *
+ * @param pin the pin number used on your board
+ * @param owner if you are the owner of the pin the destructor will
+ * @param chipid the pwmchip to use, use only in raw mode
+ * unexport the pin from sysfs, default behaviour is you are the owner
+ * if the pinmapper exported it
+ */
+ Pwm(int pin, bool owner = true, int chipid = -1)
+ {
+ if (chipid == -1) {
+ m_pwm = mraa_pwm_init(pin);
+ } else {
+ m_pwm = mraa_pwm_init_raw(chipid, pin);
}
- /**
- * Set pulsewidth, As represnted by seconds in a (float)
- *
- * @param seconds The duration of a pulse
- * @return Result of operation
- */
- mraa_result_t pulsewidth(float seconds) {
- return mraa_pwm_pulsewidth(m_pwm, seconds);
- }
- /**
- * Set pulsewidth, milliseconds
- *
- * @param ms milliseconds for pulsewidth
- * @return Result of operation
- */
- mraa_result_t pulsewidth_ms(int ms) {
- return mraa_pwm_pulsewidth_ms(m_pwm, ms);
- }
- /**
- * The pulsewidth, microseconds
- *
- * @param us microseconds for pulsewidth
- * @return Result of operation
- */
- mraa_result_t pulsewidth_us(int us) {
- return mraa_pwm_pulsewidth_us(m_pwm, us);
- }
- /**
- * Set the enable status of the PWM pin. None zero will assume on with
- * output being driven and 0 will disable the output
- *
- * @param enable enable status of pin
- * @return Result of operation
- */
- mraa_result_t enable(bool enable) {
- if (enable)
- return mraa_pwm_enable(m_pwm, 1);
- else
- return mraa_pwm_enable(m_pwm, 0);
- }
- /**
- * Set the period and duty of a PWM object.
- *
- * @param period represented in ms.
- * @param duty represnted in ms as float.
- * @return Result of operation
- */
- mraa_result_t config_ms(int period, float duty) {
- return mraa_pwm_config_ms(m_pwm, period, duty);
+
+ if (m_pwm == NULL) {
+ throw std::invalid_argument("Error initialising PWM on pin");
}
- /**
- * Set the period and duty (percent) of a PWM object.
- *
- * @param period as represented in ms.
- * @param duty percentage i.e. 50% = 0.5f
- * @return Result of operation
- */
- mraa_result_t config_percent(int period, float duty) {
- return mraa_pwm_config_percent(m_pwm, period, duty);
+
+ if (!owner) {
+ mraa_pwm_owner(m_pwm, 0);
}
+ }
+ /**
+ * Pwm destructor
+ */
+ ~Pwm()
+ {
+ mraa_pwm_close(m_pwm);
+ }
+ /**
+ * Set the output duty-cycle percentage, as a float
+ *
+ * @param percentage A floating-point value representing percentage of
+ * output. The value should lie between 0.0f (representing on 0%) and
+ * 1.0f Values above or below this range will be set at either 0.0f or
+ * 1.0f
+ * @return Result of operation
+ */
+ mraa_result_t
+ write(float percentage)
+ {
+ return mraa_pwm_write(m_pwm, percentage);
+ }
+ /**
+ * Read the ouput duty-cycle percentage, as a float
+ *
+ * @return A floating-point value representing percentage of
+ * output. The value should lie between 0.0f (representing on 0%) and
+ * 1.0f Values above or below this range will be set at either 0.0f or
+ * 1.0f
+ */
+ float
+ read()
+ {
+ return mraa_pwm_read(m_pwm);
+ }
+ /**
+ * Set the PWM period as seconds represented in a float
+ *
+ * @param period Period represented as a float in seconds
+ * @return Result of operation
+ */
+ mraa_result_t
+ period(float period)
+ {
+ return mraa_pwm_period(m_pwm, period);
+ }
+ /**
+ * Set period, milliseconds
+ *
+ * @param ms milliseconds for period
+ * @return Result of operation
+ */
+ mraa_result_t
+ period_ms(int ms)
+ {
+ return mraa_pwm_period_ms(m_pwm, ms);
+ }
+ /**
+ * Set period, microseconds
+ *
+ * @param us microseconds as period
+ * @return Result of operation
+ */
+ mraa_result_t
+ period_us(int us)
+ {
+ return mraa_pwm_period_us(m_pwm, us);
+ }
+ /**
+ * Set pulsewidth, As represnted by seconds in a (float)
+ *
+ * @param seconds The duration of a pulse
+ * @return Result of operation
+ */
+ mraa_result_t
+ pulsewidth(float seconds)
+ {
+ return mraa_pwm_pulsewidth(m_pwm, seconds);
+ }
+ /**
+ * Set pulsewidth, milliseconds
+ *
+ * @param ms milliseconds for pulsewidth
+ * @return Result of operation
+ */
+ mraa_result_t
+ pulsewidth_ms(int ms)
+ {
+ return mraa_pwm_pulsewidth_ms(m_pwm, ms);
+ }
+ /**
+ * The pulsewidth, microseconds
+ *
+ * @param us microseconds for pulsewidth
+ * @return Result of operation
+ */
+ mraa_result_t
+ pulsewidth_us(int us)
+ {
+ return mraa_pwm_pulsewidth_us(m_pwm, us);
+ }
+ /**
+ * Set the enable status of the PWM pin. None zero will assume on with
+ * output being driven and 0 will disable the output
+ *
+ * @param enable enable status of pin
+ * @return Result of operation
+ */
+ mraa_result_t
+ enable(bool enable)
+ {
+ if (enable)
+ return mraa_pwm_enable(m_pwm, 1);
+ else
+ return mraa_pwm_enable(m_pwm, 0);
+ }
+ /**
+ * Set the period and duty of a PWM object.
+ *
+ * @param period represented in ms.
+ * @param duty represnted in ms as float.
+ * @return Result of operation
+ */
+ mraa_result_t
+ config_ms(int period, float duty)
+ {
+ return mraa_pwm_config_ms(m_pwm, period, duty);
+ }
+ /**
+ * Set the period and duty (percent) of a PWM object.
+ *
+ * @param period as represented in ms.
+ * @param duty percentage i.e. 50% = 0.5f
+ * @return Result of operation
+ */
+ mraa_result_t
+ config_percent(int period, float duty)
+ {
+ return mraa_pwm_config_percent(m_pwm, period, duty);
+ }
- private:
- mraa_pwm_context m_pwm;
+ private:
+ mraa_pwm_context m_pwm;
};
-
}
* MRAA SPI Modes
*/
typedef enum {
- MRAA_SPI_MODE0 = 0, /**< CPOL = 0, CPHA = 0, Clock idle low, data is clocked in on rising edge, output data (change) on falling edge */
- MRAA_SPI_MODE1 = 1, /**< CPOL = 0, CPHA = 1, Clock idle low, data is clocked in on falling edge, output data (change) on rising edge */
- MRAA_SPI_MODE2 = 2, /**< CPOL = 1, CPHA = 0, Clock idle low, data is clocked in on falling edge, output data (change) on rising edge */
- MRAA_SPI_MODE3 = 3, /**< CPOL = 1, CPHA = 1, Clock idle low, data is clocked in on rising, edge output data (change) on falling edge */
+ MRAA_SPI_MODE0 = 0, /**< CPOL = 0, CPHA = 0, Clock idle low, data is clocked in on rising edge,
+ output data (change) on falling edge */
+ MRAA_SPI_MODE1 = 1, /**< CPOL = 0, CPHA = 1, Clock idle low, data is clocked in on falling edge,
+ output data (change) on rising edge */
+ MRAA_SPI_MODE2 = 2, /**< CPOL = 1, CPHA = 0, Clock idle low, data is clocked in on falling edge,
+ output data (change) on rising edge */
+ MRAA_SPI_MODE3 = 3, /**< CPOL = 1, CPHA = 1, Clock idle low, data is clocked in on rising, edge
+ output data (change) on falling edge */
} mraa_spi_mode_t;
/**
#include "spi.h"
#include <stdexcept>
-namespace mraa {
+namespace mraa
+{
/**
* MRAA SPI Modes
*/
typedef enum {
- SPI_MODE0 = 0, /**< CPOL = 0, CPHA = 0, Clock idle low, data is clocked in on rising edge, output data (change) on falling edge */
- SPI_MODE1 = 1, /**< CPOL = 0, CPHA = 1, Clock idle low, data is clocked in on falling edge, output data (change) on rising edge */
- SPI_MODE2 = 2, /**< CPOL = 1, CPHA = 0, Clock idle low, data is clocked in on falling edge, output data (change) on rising edge */
- SPI_MODE3 = 3, /**< CPOL = 1, CPHA = 1, Clock idle low, data is clocked in on rising, edge output data (change) on falling edge */
+ SPI_MODE0 = 0, /**< CPOL = 0, CPHA = 0, Clock idle low, data is clocked in on rising edge,
+ output data (change) on falling edge */
+ SPI_MODE1 = 1, /**< CPOL = 0, CPHA = 1, Clock idle low, data is clocked in on falling edge,
+ output data (change) on rising edge */
+ SPI_MODE2 = 2, /**< CPOL = 1, CPHA = 0, Clock idle low, data is clocked in on falling edge,
+ output data (change) on rising edge */
+ SPI_MODE3 = 3, /**< CPOL = 1, CPHA = 1, Clock idle low, data is clocked in on rising, edge
+ output data (change) on falling edge */
} Spi_Mode;
- /**
- * @brief API to Serial Peripheral Interface
- *
- * This file defines the SPI interface for libmraa
- *
- * @snippet Spi-pot.cpp Interesting
- */
-class Spi {
- public:
- /**
- * Initialise SPI object using the board mapping to set muxes
- *
- * @param bus to use, as listed in the platform definition, normally 0
- */
- Spi(int bus) {
- m_spi = mraa_spi_init(bus);
-
- if (m_spi == NULL) {
- throw std::invalid_argument("Error initialising SPI bus");
- }
- }
-
- /**
- * Closes spi bus
- */
- ~Spi() {
- mraa_spi_stop(m_spi);
- }
-
- /**
- * Set the SPI device mode. see spidev0-3
- *
- * @param mode the mode. See Linux spidev doc
- * @return Result of operation
- */
- mraa_result_t mode(Spi_Mode mode) {
- return mraa_spi_mode(m_spi, (mraa_spi_mode_t) mode);
- }
-
- /**
- * Set the SPI device operating clock frequency
- *
- * @param hz the frequency to set in hz
- * @return Result of operation
- */
- mraa_result_t frequency(int hz) {
- return mraa_spi_frequency(m_spi, hz);
- }
-
- /**
- * Write single byte to the SPI device
- *
- * @param data the byte to send
- * @return data received on the miso line or -1 in case of error
- */
- int writeByte(uint8_t data) {
- return mraa_spi_write(m_spi, (uint8_t) data);
- }
-
- /**
- * Write single byte to the SPI device
- *
- * @param data the byte to send
- * @return data received on the miso line
- */
- uint16_t write_word(uint16_t data) {
- return mraa_spi_write_word(m_spi, (uint16_t) data);
- }
-
- /**
- * Write buffer of bytes to SPI device The pointer return has to be
- * free'd by the caller. It will return a NULL pointer in cases of
- * error
- *
- * @param txBuf buffer to send
- * @param length size of buffer to send
- * @return uint8_t* data received on the miso line. Same length as passed in
- */
- uint8_t* write(uint8_t* txBuf, int length) {
- return mraa_spi_write_buf(m_spi, txBuf, length);
- }
-
- /**
- * Write buffer of bytes to SPI device The pointer return has to be
- * free'd by the caller. It will return a NULL pointer in cases of
- * error
- *
- * @param txBuf buffer to send
- * @param length size of buffer (in bytes) to send
- * @return uint8_t* data received on the miso line. Same length as passed in
- */
- uint16_t* write_word(uint16_t* txBuf, int length) {
- return mraa_spi_write_buf_word(m_spi, txBuf, length);
+/**
+* @brief API to Serial Peripheral Interface
+*
+* This file defines the SPI interface for libmraa
+*
+* @snippet Spi-pot.cpp Interesting
+*/
+class Spi
+{
+ public:
+ /**
+ * Initialise SPI object using the board mapping to set muxes
+ *
+ * @param bus to use, as listed in the platform definition, normally 0
+ */
+ Spi(int bus)
+ {
+ m_spi = mraa_spi_init(bus);
+
+ if (m_spi == NULL) {
+ throw std::invalid_argument("Error initialising SPI bus");
}
+ }
+
+ /**
+ * Closes spi bus
+ */
+ ~Spi()
+ {
+ mraa_spi_stop(m_spi);
+ }
+
+ /**
+ * Set the SPI device mode. see spidev0-3
+ *
+ * @param mode the mode. See Linux spidev doc
+ * @return Result of operation
+ */
+ mraa_result_t
+ mode(Spi_Mode mode)
+ {
+ return mraa_spi_mode(m_spi, (mraa_spi_mode_t) mode);
+ }
+
+ /**
+ * Set the SPI device operating clock frequency
+ *
+ * @param hz the frequency to set in hz
+ * @return Result of operation
+ */
+ mraa_result_t
+ frequency(int hz)
+ {
+ return mraa_spi_frequency(m_spi, hz);
+ }
+
+ /**
+ * Write single byte to the SPI device
+ *
+ * @param data the byte to send
+ * @return data received on the miso line or -1 in case of error
+ */
+ int
+ writeByte(uint8_t data)
+ {
+ return mraa_spi_write(m_spi, (uint8_t) data);
+ }
+
+ /**
+ * Write single byte to the SPI device
+ *
+ * @param data the byte to send
+ * @return data received on the miso line
+ */
+ uint16_t
+ write_word(uint16_t data)
+ {
+ return mraa_spi_write_word(m_spi, (uint16_t) data);
+ }
+
+ /**
+ * Write buffer of bytes to SPI device The pointer return has to be
+ * free'd by the caller. It will return a NULL pointer in cases of
+ * error
+ *
+ * @param txBuf buffer to send
+ * @param length size of buffer to send
+ * @return uint8_t* data received on the miso line. Same length as passed in
+ */
+ uint8_t*
+ write(uint8_t* txBuf, int length)
+ {
+ return mraa_spi_write_buf(m_spi, txBuf, length);
+ }
+
+ /**
+ * Write buffer of bytes to SPI device The pointer return has to be
+ * free'd by the caller. It will return a NULL pointer in cases of
+ * error
+ *
+ * @param txBuf buffer to send
+ * @param length size of buffer (in bytes) to send
+ * @return uint8_t* data received on the miso line. Same length as passed in
+ */
+ uint16_t*
+ write_word(uint16_t* txBuf, int length)
+ {
+ return mraa_spi_write_buf_word(m_spi, txBuf, length);
+ }
#ifndef SWIG
- /**
- * Transfer data to and from SPI device Receive pointer may be null if
- * return data is not needed.
- *
- * @param data buffer to send
- * @param rxBuf buffer to optionally receive data from spi device
- * @param length size of buffer to send
- * @return Result of operation
- */
- mraa_result_t transfer(uint8_t* txBuf, uint8_t* rxBuf, int length) {
- return mraa_spi_transfer_buf(m_spi, txBuf, rxBuf, length);
- }
-
- /**
- * Transfer data to and from SPI device Receive pointer may be null if
- * return data is not needed.
- *
- * @param data buffer to send
- * @param rxBuf buffer to optionally receive data from spi device
- * @param length size of buffer to send
- * @return Result of operation
- */
- mraa_result_t transfer_word(uint16_t* txBuf, uint16_t* rxBuf, int length) {
- return mraa_spi_transfer_buf_word(m_spi, txBuf, rxBuf, length);
- }
+ /**
+ * Transfer data to and from SPI device Receive pointer may be null if
+ * return data is not needed.
+ *
+ * @param data buffer to send
+ * @param rxBuf buffer to optionally receive data from spi device
+ * @param length size of buffer to send
+ * @return Result of operation
+ */
+ mraa_result_t
+ transfer(uint8_t* txBuf, uint8_t* rxBuf, int length)
+ {
+ return mraa_spi_transfer_buf(m_spi, txBuf, rxBuf, length);
+ }
+
+ /**
+ * Transfer data to and from SPI device Receive pointer may be null if
+ * return data is not needed.
+ *
+ * @param data buffer to send
+ * @param rxBuf buffer to optionally receive data from spi device
+ * @param length size of buffer to send
+ * @return Result of operation
+ */
+ mraa_result_t
+ transfer_word(uint16_t* txBuf, uint16_t* rxBuf, int length)
+ {
+ return mraa_spi_transfer_buf_word(m_spi, txBuf, rxBuf, length);
+ }
#endif
- /**
- * Change the SPI lsb mode
- *
- * @param lsb Use least significant bit transmission - 0 for msbi
- * @return Result of operation
- */
- mraa_result_t lsbmode(bool lsb) {
- return mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb);
- }
-
- /**
- * Set bits per mode on transaction, default is 8
- *
- * @param bits bits per word
- * @return Result of operation
- */
- mraa_result_t bitPerWord(unsigned int bits) {
- return mraa_spi_bit_per_word(m_spi, bits);
- }
-
- private:
- mraa_spi_context m_spi;
+ /**
+ * Change the SPI lsb mode
+ *
+ * @param lsb Use least significant bit transmission - 0 for msbi
+ * @return Result of operation
+ */
+ mraa_result_t
+ lsbmode(bool lsb)
+ {
+ return mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb);
+ }
+
+ /**
+ * Set bits per mode on transaction, default is 8
+ *
+ * @param bits bits per word
+ * @return Result of operation
+ */
+ mraa_result_t
+ bitPerWord(unsigned int bits)
+ {
+ return mraa_spi_bit_per_word(m_spi, bits);
+ }
+
+ private:
+ mraa_spi_context m_spi;
};
}
* MRAA supported platform types
*/
typedef enum {
- MRAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
- MRAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
- MRAA_INTEL_EDISON_FAB_C = 2, /**< The Intel Edison (FAB C) */
- MRAA_INTEL_DE3815 = 3, /**< The Intel DE3815 Baytrail NUC */
+ MRAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
+ MRAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
+ MRAA_INTEL_EDISON_FAB_C = 2, /**< The Intel Edison (FAB C) */
+ MRAA_INTEL_DE3815 = 3, /**< The Intel DE3815 Baytrail NUC */
MRAA_INTEL_MINNOWBOARD_MAX = 4, /**< The Intel Minnow Board Max */
- MRAA_RASPBERRY_PI = 5, /**< The different Raspberry PI Models -like A,B,A+,B+ */
+ MRAA_RASPBERRY_PI = 5, /**< The different Raspberry PI Models -like A,B,A+,B+ */
- MRAA_UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
+ MRAA_UNKNOWN_PLATFORM =
+ 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
} mraa_platform_t;
/**
MRAA_RASPBERRY_WIRING_PIN14 = 23,
MRAA_RASPBERRY_WIRING_PIN10 = 24,
MRAA_RASPBERRY_WIRING_PIN11 = 26,
- MRAA_RASPBERRY_WIRING_PIN17 = 29, //RPi B V2
+ MRAA_RASPBERRY_WIRING_PIN17 = 29, // RPi B V2
MRAA_RASPBERRY_WIRING_PIN21 = 29,
- MRAA_RASPBERRY_WIRING_PIN18 = 30, //RPi B V2
- MRAA_RASPBERRY_WIRING_PIN19 = 31, //RPI B V2
+ MRAA_RASPBERRY_WIRING_PIN18 = 30, // RPi B V2
+ MRAA_RASPBERRY_WIRING_PIN19 = 31, // RPI B V2
MRAA_RASPBERRY_WIRING_PIN22 = 31,
- MRAA_RASPBERRY_WIRING_PIN20 = 32, //RPi B V2
+ MRAA_RASPBERRY_WIRING_PIN20 = 32, // RPi B V2
MRAA_RASPBERRY_WIRING_PIN26 = 32,
MRAA_RASPBERRY_WIRING_PIN23 = 33,
MRAA_RASPBERRY_WIRING_PIN24 = 35,
* MRAA return codes
*/
typedef enum {
- MRAA_SUCCESS = 0, /**< Expected response */
- MRAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
- MRAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
- MRAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
- MRAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
- MRAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
- MRAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
- MRAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
- MRAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
- MRAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
- MRAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
- MRAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
- MRAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
+ MRAA_SUCCESS = 0, /**< Expected response */
+ MRAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
+ MRAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
+ MRAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
+ MRAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
+ MRAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
+ MRAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
+ MRAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
+ MRAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
+ MRAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
+ MRAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
+ MRAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
+ MRAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
- MRAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
+ MRAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
} mraa_result_t;
/**
* Enum representing different possible modes for a pin.
*/
typedef enum {
- MRAA_PIN_VALID = 0, /**< Pin Valid */
- MRAA_PIN_GPIO = 1, /**< General Purpose IO */
- MRAA_PIN_PWM = 2, /**< Pulse Width Modulation */
- MRAA_PIN_FAST_GPIO = 3, /**< Faster GPIO */
- MRAA_PIN_SPI = 4, /**< SPI */
- MRAA_PIN_I2C = 5, /**< I2C */
- MRAA_PIN_AIO = 6, /**< Analog in */
- MRAA_PIN_UART = 7 /**< UART */
+ 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_PIN_UART = 7 /**< UART */
} mraa_pinmodes_t;
/**
* Enum reprensenting different i2c speeds/modes
*/
typedef enum {
- MRAA_I2C_STD = 0, /**< up to 100Khz */
+ MRAA_I2C_STD = 0, /**< up to 100Khz */
MRAA_I2C_FAST = 1, /**< up to 400Khz */
MRAA_I2C_HIGH = 2 /**< up to 3.4Mhz */
} mraa_i2c_mode_t;
#include "uart.h"
#include <stdexcept>
-namespace mraa {
+namespace mraa
+{
/**
* @brief API to UART (enabling only)
*
* This file defines the UART interface for libmraa
*/
-class Uart {
- public:
- /**
- * Uart Constructor, takes a pin number which will map directly to the
- * linux uart number, this 'enables' the uart, nothing more
- *
- * @param uart the index of the uart set to use
- */
- Uart(int uart) {
- m_uart = mraa_uart_init(uart);
+class Uart
+{
+ public:
+ /**
+ * Uart Constructor, takes a pin number which will map directly to the
+ * linux uart number, this 'enables' the uart, nothing more
+ *
+ * @param uart the index of the uart set to use
+ */
+ Uart(int uart)
+ {
+ m_uart = mraa_uart_init(uart);
- if (m_uart == NULL) {
- throw std::invalid_argument("Error initialising UART");
- }
- }
- /**
- * Uart destructor
- */
- ~Uart() {
- return;
+ if (m_uart == NULL) {
+ throw std::invalid_argument("Error initialising UART");
}
+ }
+ /**
+ * Uart destructor
+ */
+ ~Uart()
+ {
+ return;
+ }
- /**
- * Get string with tty device path within Linux
- * For example. Could point to "/dev/ttyS0"
- *
- * @return char pointer of device path
- */
- std::string getDevicePath() {
- std::string ret_val(mraa_uart_get_dev_path(m_uart));
- return ret_val;
- }
- private:
- mraa_uart_context m_uart;
-};
+ /**
+ * Get string with tty device path within Linux
+ * For example. Could point to "/dev/ttyS0"
+ *
+ * @return char pointer of device path
+ */
+ std::string
+ getDevicePath()
+ {
+ std::string ret_val(mraa_uart_get_dev_path(m_uart));
+ return ret_val;
+ }
+ private:
+ mraa_uart_context m_uart;
+};
}
- Try not to break master. In any commit.
- Try to split commits up logically, you will be asked to rebase them if they
are not.
-- Try to stick to the established coding style regardless of your personal feeling for it!
+- Try to stick to the established coding style regardless of your personal
+ feeling for it! Use clang-format (3.6+ required)
Code signing
------------
//! [Interesting]
#include "mraa/aio.h"
-int main ()
+int
+main()
{
mraa_aio_context adc_a0;
uint16_t adc_value = 0;
return 1;
}
- for(;;) {
+ for (;;) {
adc_value = mraa_aio_read(adc_a0);
adc_value_float = mraa_aio_read_float(adc_a0);
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
}
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
mraa_result_t r = MRAA_SUCCESS;
iopin = DEFAULT_IOPIN;
}
mraa_init();
- fprintf(stdout, "MRAA Version: %s\nStarting Blinking on IO%d\n",
- mraa_get_version(), iopin);
+ fprintf(stdout, "MRAA Version: %s\nStarting Blinking on IO%d\n", mraa_get_version(), 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);
+ exit(1);
}
printf("Initialised pin%d\n", iopin);
#include "mraa/gpio.h"
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
mraa_platform_t platform = mraa_get_platform_type();
mraa_gpio_context gpio, gpio_in = NULL;
case MRAA_INTEL_GALILEO_GEN1:
gpio = mraa_gpio_init_raw(3);
break;
- case MRAA_INTEL_MINNOWBOARD_MAX:
- // there is no onboard LED that we can flash on the minnowboard max
- // but on the calamari lure pin 21 is an LED. If you don't have the
- // lure put an LED on pin 21
- gpio = mraa_gpio_init(21);
+ case MRAA_INTEL_MINNOWBOARD_MAX:
+ // there is no onboard LED that we can flash on the minnowboard max
+ // but on the calamari lure pin 21 is an LED. If you don't have the
+ // lure put an LED on pin 21
+ gpio = mraa_gpio_init(21);
break;
default:
gpio = mraa_gpio_init(13);
}
- fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n",
- mraa_get_version(), board_name);
+ fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
if (gpio == NULL) {
// on platforms with physical button use gpio_in
if (platform == MRAA_INTEL_MINNOWBOARD_MAX) {
gpio_in = mraa_gpio_init(14);
- if (gpio_in != NULL) {
+ if (gpio_in != NULL) {
mraa_gpio_dir(gpio_in, MRAA_GPIO_IN);
// S1 on minnowboardmax's calamari lure maps to pin 14, SW1 != S1
fprintf(stdout, "Press and hold S1 to stop, Press SW1 to shutdown!\n");
//! [Interesting]
#include "mraa.hpp"
-int main ()
+int
+main()
{
uint16_t adc_value;
float adc_value_float;
return MRAA_ERROR_UNSPECIFIED;
}
- for(;;) {
+ for (;;) {
adc_value = a0->read();
adc_value_float = a0->readFloat();
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
running = -1;
}
}
-int main (int argc, char **argv)
+int
+main(int argc, char** argv)
{
if (argc < 2) {
printf("Provide an int arg if you want to flash on something other than %d\n", DEFAULT_IOPIN);
signal(SIGINT, sig_handler);
-//! [Interesting]
+ //! [Interesting]
mraa::Gpio* gpio = new mraa::Gpio(iopin);
if (gpio == NULL) {
return MRAA_ERROR_UNSPECIFIED;
}
delete gpio;
return response;
-//! [Interesting]
+ //! [Interesting]
}
#define MAX_BUFFER_LENGTH 6
#define HMC5883L_I2C_ADDR 0x1E
-//configuration registers
+// configuration registers
#define HMC5883L_CONF_REG_A 0x00
#define HMC5883L_CONF_REG_B 0x01
-//mode register
+// mode register
#define HMC5883L_MODE_REG 0x02
-//data register
+// data register
#define HMC5883L_X_MSB_REG 0
#define HMC5883L_X_LSB_REG 1
#define HMC5883L_Z_MSB_REG 2
#define HMC5883L_Y_LSB_REG 5
#define DATA_REG_SIZE 6
-//status register
+// status register
#define HMC5883L_STATUS_REG 0x09
-//ID registers
+// ID registers
#define HMC5883L_ID_A_REG 0x0A
#define HMC5883L_ID_B_REG 0x0B
#define HMC5883L_ID_C_REG 0x0C
#define HMC5883L_CONT_MODE 0x00
#define HMC5883L_DATA_REG 0x03
-//scales
+// scales
#define GA_0_88_REG 0x00 << 5
#define GA_1_3_REG 0x01 << 5
#define GA_1_9_REG 0x02 << 5
#define GA_5_6_REG 0x06 << 5
#define GA_8_1_REG 0x07 << 5
-//digital resolutions
+// digital resolutions
#define SCALE_0_73_MG 0.73
#define SCALE_0_92_MG 0.92
#define SCALE_1_22_MG 1.22
}
}
-int main ()
+int
+main()
{
float direction = 0;
int16_t x = 0, y = 0, z = 0;
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
-//! [Interesting]
+ //! [Interesting]
mraa::I2c* i2c;
i2c = new mraa::I2c(0);
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
rx_tx_buf[1] = GA_1_3_REG;
i2c->write(rx_tx_buf, 2);
-//! [Interesting]
+ //! [Interesting]
i2c->address(HMC5883L_I2C_ADDR);
rx_tx_buf[0] = HMC5883L_MODE_REG;
i2c->address(HMC5883L_I2C_ADDR);
i2c->read(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] ;
- y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Y_LSB_REG] ;
+ 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];
+ y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
- //scale and calculate direction
+ // scale and calculate direction
direction = atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
- //check if the signs are reversed
+ // check if the signs are reversed
if (direction < 0)
direction += 2 * M_PI;
- printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG, z * SCALE_0_92_MG) ;
- printf("Heading : %f\n", direction * 180/M_PI);
+ printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG,
+ z * SCALE_0_92_MG);
+ printf("Heading : %f\n", direction * 180 / M_PI);
sleep(1);
}
delete i2c;
}
}
-int main ()
+int
+main()
{
signal(SIGINT, sig_handler);
-//! [Interesting]
+ //! [Interesting]
mraa::Pwm* pwm;
pwm = new mraa::Pwm(3);
}
}
delete pwm;
-//! [Interesting]
+ //! [Interesting]
return MRAA_SUCCESS;
}
}
}
-int main ()
+int
+main()
{
signal(SIGINT, sig_handler);
-//! [Interesting]
+ //! [Interesting]
mraa::Spi* spi;
spi = new mraa::Spi(0);
- uint8_t data[] = {0x00, 100};
+ uint8_t data[] = { 0x00, 100 };
uint8_t rxBuf[2];
- uint8_t *recv;
+ uint8_t* recv;
while (running == 0) {
int i;
for (i = 90; i < 130; i++) {
data[1] = i;
recv = spi->write(data, 2);
- printf("Writing -%i",i);
+ printf("Writing -%i", i);
if (recv) {
- printf("RECIVED-%i-%i\n",recv[0],recv[1]);
+ printf("RECIVED-%i-%i\n", recv[0], recv[1]);
free(recv);
}
usleep(100000);
for (i = 130; i > 90; i--) {
data[1] = i;
if (spi->transfer(data, rxBuf, 2) == MRAA_SUCCESS) {
- printf("Writing -%i",i);
- printf("RECIVED-%i-%i\n",rxBuf[0],rxBuf[1]);
+ printf("Writing -%i", i);
+ printf("RECIVED-%i-%i\n", rxBuf[0], rxBuf[1]);
}
usleep(100000);
}
-
}
delete spi;
-//! [Interesting]
+ //! [Interesting]
return MRAA_SUCCESS;
}
#include "mraa.h"
int
-main ()
+main()
{
mraa_init();
-//! [Interesting]
+ //! [Interesting]
mraa_pwm_context pwm;
pwm = mraa_pwm_init(3);
if (pwm == NULL) {
}
float output = mraa_pwm_read(pwm);
}
-//! [Interesting]
+ //! [Interesting]
return 0;
}
#include "mraa/gpio.h"
struct gpio_source {
- int pin;
- mraa_gpio_context context;
+ int pin;
+ mraa_gpio_context context;
};
void
-print_version() {
+print_version()
+{
fprintf(stdout, "Version %s on %s\n", mraa_get_version(), mraa_get_platform_name());
}
void
-print_help() {
+print_help()
+{
fprintf(stdout, "list List pins\n");
fprintf(stdout, "set pin level Set pin to level (0/1)\n");
fprintf(stdout, "setraw pin level Set pin to level (0/1) via mmap (if available)\n");
}
void
-print_command_error() {
+print_command_error()
+{
fprintf(stdout, "Invalid command, options are:\n");
print_help();
}
void
-list_pins() {
+list_pins()
+{
int pin_count = mraa_get_pin_count();
if (pin_count == 0) {
fprintf(stdout, "No Pins\n");
}
int i;
for (i = 0; i < pin_count; ++i) {
- if (strcmp(mraa_get_pin_name(i),"INVALID") != 0) {
+ if (strcmp(mraa_get_pin_name(i), "INVALID") != 0) {
fprintf(stdout, "%02d ", i);
fprintf(stdout, "%8s: ", mraa_get_pin_name(i));
if (mraa_pin_mode_test(i, MRAA_PIN_GPIO))
}
mraa_result_t
-gpio_set(int pin, int level, mraa_boolean_t raw) {
+gpio_set(int pin, int level, mraa_boolean_t raw)
+{
mraa_gpio_context gpio = mraa_gpio_init(pin);
if (gpio != NULL) {
mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
if (raw != 0) {
if (mraa_gpio_use_mmaped(gpio, 1) != MRAA_SUCCESS) {
- fprintf(stdout, "mmapped access to gpio not supported, falling back to normal mode\n", pin);
+ fprintf(stdout,
+ "mmapped access to gpio not supported, falling back to normal mode\n", pin);
}
}
mraa_gpio_write(gpio, level);
}
mraa_result_t
-gpio_get(int pin, int *level, mraa_boolean_t raw) {
+gpio_get(int pin, int* level, mraa_boolean_t raw)
+{
mraa_gpio_context gpio = mraa_gpio_init(pin);
if (gpio != NULL) {
mraa_gpio_dir(gpio, MRAA_GPIO_IN);
if (raw != 0) {
if (mraa_gpio_use_mmaped(gpio, 1) != MRAA_SUCCESS) {
- fprintf(stdout, "mmapped access to gpio not supported, falling back to normal mode\n", pin);
+ fprintf(stdout,
+ "mmapped access to gpio not supported, falling back to normal mode\n", pin);
}
}
*level = mraa_gpio_read(gpio);
}
-void gpio_isr_handler(void * args) {
- struct gpio_source* gpio_info = (struct gpio_source*)args;
- int level = mraa_gpio_read(gpio_info->context);
- fprintf(stdout, "Pin %d = %d\n", gpio_info->pin, level);
+void
+gpio_isr_handler(void* args)
+{
+ struct gpio_source* gpio_info = (struct gpio_source*) args;
+ int level = mraa_gpio_read(gpio_info->context);
+ fprintf(stdout, "Pin %d = %d\n", gpio_info->pin, level);
}
mraa_result_t
-gpio_isr_start(struct gpio_source* gpio_info) {
+gpio_isr_start(struct gpio_source* gpio_info)
+{
gpio_info->context = mraa_gpio_init(gpio_info->pin);
if (gpio_info->context != NULL) {
mraa_result_t status = mraa_gpio_dir(gpio_info->context, MRAA_GPIO_IN);
mraa_result_t
-gpio_isr_stop(struct gpio_source* gpio_info) {
+gpio_isr_stop(struct gpio_source* gpio_info)
+{
mraa_gpio_isr_exit(gpio_info->context);
mraa_gpio_close(gpio_info->context);
return MRAA_SUCCESS;
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
if (argc == 1) {
print_command_error();
mraa_boolean_t rawmode = strcmp(argv[1], "getraw") == 0;
if (gpio_get(pin, &level, rawmode) == MRAA_SUCCESS) {
fprintf(stdout, "Pin %d = %d\n", pin, level);
- }
- else {
+ } else {
fprintf(stdout, "Could not initialize gpio %d\n", pin);
}
} else {
print_command_error();
}
- } else if (strcmp(argv[1], "monitor") == 0) {
+ } else if (strcmp(argv[1], "monitor") == 0) {
if (argc == 3) {
int pin = atoi(argv[2]);
struct gpio_source gpio_info;
if (gpio_isr_start(&gpio_info) == MRAA_SUCCESS) {
fprintf(stdout, "Monitoring level changes to pin %d. Press RETURN to exit.\n", pin);
gpio_isr_handler(&gpio_info);
- while (getchar() != '\n');
+ while (getchar() != '\n')
+ ;
gpio_isr_stop(&gpio_info);
- }
- else {
+ } else {
fprintf(stdout, "Failed to register ISR for pin %d\n", pin);
- }
+ }
} else {
print_command_error();
}
- } else {
+ } else {
print_command_error();
- }
+ }
}
return 0;
}
#include "mraa.h"
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
mraa_init();
- fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6\n",
- mraa_get_version());
+ fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6\n", mraa_get_version());
-//! [Interesting]
+ //! [Interesting]
mraa_gpio_context gpio;
gpio = mraa_gpio_init(6);
}
mraa_gpio_close(gpio);
-//! [Interesting]
+ //! [Interesting]
return 0;
}
#include "mraa.h"
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
mraa_result_t ret = MRAA_SUCCESS;
mraa_platform_t platform_type = mraa_get_platform_type();
#include "mraa.h"
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
char* board_name = mraa_get_platform_name();
#define MAX_BUFFER_LENGTH 6
#define HMC5883L_I2C_ADDR 0x1E
-//configuration registers
+// configuration registers
#define HMC5883L_CONF_REG_A 0x00
#define HMC5883L_CONF_REG_B 0x01
-//mode register
+// mode register
#define HMC5883L_MODE_REG 0x02
-//data register
+// data register
#define HMC5883L_X_MSB_REG 0
#define HMC5883L_X_LSB_REG 1
#define HMC5883L_Z_MSB_REG 2
#define HMC5883L_Y_LSB_REG 5
#define DATA_REG_SIZE 6
-//status register
+// status register
#define HMC5883L_STATUS_REG 0x09
-//ID registers
+// ID registers
#define HMC5883L_ID_A_REG 0x0A
#define HMC5883L_ID_B_REG 0x0B
#define HMC5883L_ID_C_REG 0x0C
#define HMC5883L_CONT_MODE 0x00
#define HMC5883L_DATA_REG 0x03
-//scales
+// scales
#define GA_0_88_REG 0x00 << 5
#define GA_1_3_REG 0x01 << 5
#define GA_1_9_REG 0x02 << 5
#define GA_5_6_REG 0x06 << 5
#define GA_8_1_REG 0x07 << 5
-//digital resolutions
+// digital resolutions
#define SCALE_0_73_MG 0.73
#define SCALE_0_92_MG 0.92
#define SCALE_1_22_MG 1.22
#define SCALE_4_35_MG 4.35
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
mraa_init();
float direction = 0;
int16_t x = 0, y = 0, z = 0;
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
-//! [Interesting]
+ //! [Interesting]
mraa_i2c_context i2c;
i2c = mraa_i2c_init(0);
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
rx_tx_buf[1] = GA_1_3_REG;
mraa_i2c_write(i2c, rx_tx_buf, 2);
-//! [Interesting]
+ //! [Interesting]
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
rx_tx_buf[0] = HMC5883L_MODE_REG;
rx_tx_buf[1] = HMC5883L_CONT_MODE;
mraa_i2c_write(i2c, rx_tx_buf, 2);
- for(;;) {
+ for (;;) {
#if 0
int i = 0;
//alternative, equivalent method which helps to understand exactly what
// this call behaves very similarly to the Wire receive() call
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] ;
- y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Y_LSB_REG] ;
+ 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];
+ y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
- //scale and calculate direction
+ // scale and calculate direction
direction = atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
- //check if the signs are reversed
+ // check if the signs are reversed
if (direction < 0)
direction += 2 * M_PI;
- printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG, z * SCALE_0_92_MG) ;
- printf("Heading : %f\n", direction * 180/M_PI) ;
+ printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG,
+ z * SCALE_0_92_MG);
+ printf("Heading : %f\n", direction * 180 / M_PI);
}
}
static volatile int counter = 0;
static volatile int oldcounter = 0;
-void interrupt (void * args) {
+void
+interrupt(void* args)
+{
++counter;
}
-int main ()
+int
+main()
{
mraa_init();
mraa_gpio_context x;
mraa_gpio_dir(x, MRAA_GPIO_IN);
gpio_edge_t edge = MRAA_GPIO_EDGE_BOTH;
-
+
mraa_gpio_isr(x, edge, &interrupt, NULL);
- for(;;) {
- if(counter != oldcounter) {
- fprintf(stdout, "timeout counter == %d\n", counter);
- oldcounter = counter;
+ for (;;) {
+ if (counter != oldcounter) {
+ fprintf(stdout, "timeout counter == %d\n", counter);
+ oldcounter = counter;
}
// got to relieve our poor CPU!
sleep(1);
#include "mraa.h"
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
-//! [Interesting]
+ //! [Interesting]
fprintf(stdout, "hello mraa\n Version: %s\n", mraa_get_version());
mraa_gpio_context gpio;
gpio = mraa_gpio_init(2);
mraa_gpio_use_mmaped(gpio, 1);
for (;;) {
- mraa_gpio_write(gpio , 1);
+ mraa_gpio_write(gpio, 1);
usleep(50000);
mraa_gpio_write(gpio, 0);
usleep(50000);
}
-//! [Interesting]
+ //! [Interesting]
}
#include <stdint.h>
int
-main(int argc, char **argv) {
-//! [Interesting]
+main(int argc, char** argv)
+{
+ //! [Interesting]
mraa_spi_context spi;
spi = mraa_spi_init(1);
if (spi == NULL) {
exit(1);
};
- mraa_spi_write_word(spi, 0x0900); // Do not decode bits
- mraa_spi_write_word(spi, 0x0a05); // Brightness of LEDs
- mraa_spi_write_word(spi, 0x0b07); // Show all Scan Lines
- mraa_spi_write_word(spi, 0x0c01); // Display on
- mraa_spi_write_word(spi, 0x0f00); // Testmode off
+ mraa_spi_write_word(spi, 0x0900); // Do not decode bits
+ mraa_spi_write_word(spi, 0x0a05); // Brightness of LEDs
+ mraa_spi_write_word(spi, 0x0b07); // Show all Scan Lines
+ mraa_spi_write_word(spi, 0x0c01); // Display on
+ mraa_spi_write_word(spi, 0x0f00); // Testmode off
// Display Pattern on the display
- uint16_t dataAA55[] = {0x01aa, 0x0255, 0x03aa, 0x0455, 0x05aa, 0x0655, 0x07aa, 0x0855};
+ uint16_t dataAA55[] = { 0x01aa, 0x0255, 0x03aa, 0x0455, 0x05aa, 0x0655, 0x07aa, 0x0855 };
mraa_spi_write_buf_word(spi, dataAA55, 16);
sleep(2);
// Display inverted Pattern
- uint16_t data55AA[] = {0x0155, 0x02aa, 0x0355, 0x04aa, 0x0555, 0x06aa, 0x0755, 0x08aa};
+ uint16_t data55AA[] = { 0x0155, 0x02aa, 0x0355, 0x04aa, 0x0555, 0x06aa, 0x0755, 0x08aa };
mraa_spi_write_buf_word(spi, data55AA, 16);
sleep(2);
// Clear the display
- uint16_t data[] = {0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700, 0x0800};
+ uint16_t data[] = { 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700, 0x0800 };
mraa_spi_write_buf_word(spi, data, 16);
int i;
mraa_spi_stop(spi);
-//! [Interesting]
+ //! [Interesting]
}
#include <stdint.h>
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
mraa_init();
-//! [Interesting]
+ //! [Interesting]
mraa_spi_context spi;
spi = mraa_spi_init(0);
unsigned int response = 0;
printf("Hello, SPI initialised\n");
- uint8_t data[] = {0x00, 100};
- uint8_t *recv;
- while(1) {
+ uint8_t data[] = { 0x00, 100 };
+ uint8_t* recv;
+ while (1) {
int i;
for (i = 90; i < 130; i++) {
data[1] = i;
recv = mraa_spi_write_buf(spi, data, 2);
- printf("Writing -%i",i);
- printf("RECIVED-%i-%i\n",recv[0],recv[1]);
+ 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 = mraa_spi_write_buf(spi, data, 2);
- printf("Writing -%i",i);
- printf("RECIVED-%i-%i\n",recv[0],recv[1]);
+ printf("Writing -%i", i);
+ printf("RECIVED-%i-%i\n", recv[0], recv[1]);
usleep(100000);
}
}
-//! [Interesting]
+ //! [Interesting]
}
#include "mraa.h"
int
-main(int argc, char **argv)
+main(int argc, char** argv)
{
mraa_uart_context uart;
uart = mraa_uart_init(0);
if (advance_func->aio_get_valid_fp != NULL)
return advance_func->aio_get_valid_fp(dev);
- char file_path[64]= "";
+ char file_path[64] = "";
- //Open file Analog device input channel raw voltage file for reading.
- snprintf(file_path, 64, "/sys/bus/iio/devices/iio:device0/in_voltage%d_raw",
- dev->channel );
+ // Open file Analog device input channel raw voltage file for reading.
+ snprintf(file_path, 64, "/sys/bus/iio/devices/iio:device0/in_voltage%d_raw", dev->channel);
dev->adc_in_fp = open(file_path, O_RDONLY);
if (dev->adc_in_fp == -1) {
- syslog(LOG_ERR, "aio: Failed to open input raw file %s for reading!",
- file_path);
+ syslog(LOG_ERR, "aio: Failed to open input raw file %s for reading!", file_path);
return MRAA_ERROR_INVALID_RESOURCE;
}
}
}
- //Create ADC device connected to specified channel
+ // Create ADC device connected to specified channel
mraa_aio_context dev = malloc(sizeof(struct _aio));
if (dev == NULL) {
syslog(LOG_ERR, "aio: Insufficient memory for specified input channel "
- "%d\n", aio);
+ "%d\n",
+ aio);
return NULL;
}
dev->channel = plat->pins[pin].aio.pinmap;
dev->value_bit = DEFAULT_BITS;
- //Open valid analog input file and get the pointer.
+ // Open valid analog input file and get the pointer.
if (MRAA_SUCCESS != aio_get_valid_fp(dev)) {
free(dev);
return NULL;
lseek(dev->adc_in_fp, 0, SEEK_SET);
errno = 0;
- char *end;
+ char* end;
unsigned int analog_value = (unsigned int) strtoul(buffer, &end, 10);
if (end == &buffer[0]) {
syslog(LOG_ERR, "aio: Value is not a decimal number");
- }
- else if (errno != 0) {
+ } else if (errno != 0) {
syslog(LOG_ERR, "aio: Errno was set");
}
/* Adjust the raw analog input reading to supported resolution value*/
if (raw_bits > dev->value_bit) {
shifter_value = raw_bits - dev->value_bit;
- analog_value = analog_value >> shifter_value;
+ analog_value = analog_value >> shifter_value;
} else {
shifter_value = dev->value_bit - raw_bits;
analog_value = analog_value << shifter_value;
free(dev);
}
- return(MRAA_SUCCESS);
+ return (MRAA_SUCCESS);
}
mraa_result_t
{
mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
size_t len = 100;
- char *line = malloc(len);
- FILE *fh = fopen("/proc/cpuinfo", "r");
+ char* line = malloc(len);
+ FILE* fh = fopen("/proc/cpuinfo", "r");
if (fh != NULL) {
while (getline(&line, &len, fh) != -1) {
if (strncmp(line, "Hardware", 8) == 0) {
}
free(line);
- switch(platform_type) {
+ switch (platform_type) {
case MRAA_RASPBERRY_PI:
plat = mraa_raspberry_pi();
break;
#define PLATFORM_RASPBERRY_PI_A_PLUS_REV_1 6
#define PLATFORM_RASPBERRY_PI2_B_REV_1 7
#define MMAP_PATH "/dev/mem"
-#define BCM2835_PERI_BASE 0x20000000
-#define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000)
-#define BCM2836_PERI_BASE 0x3f000000
-#define BCM2836_GPIO_BASE (BCM2836_PERI_BASE + 0x200000)
-#define BCM2835_BLOCK_SIZE (4*1024)
-#define BCM2836_BLOCK_SIZE (4*1024)
-#define BCM283X_GPSET0 0x001c
-#define BCM283X_GPCLR0 0x0028
-#define BCM2835_GPLEV0 0x0034
+#define BCM2835_PERI_BASE 0x20000000
+#define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000)
+#define BCM2836_PERI_BASE 0x3f000000
+#define BCM2836_GPIO_BASE (BCM2836_PERI_BASE + 0x200000)
+#define BCM2835_BLOCK_SIZE (4 * 1024)
+#define BCM2836_BLOCK_SIZE (4 * 1024)
+#define BCM283X_GPSET0 0x001c
+#define BCM283X_GPCLR0 0x0028
+#define BCM2835_GPLEV0 0x0034
#define MAX_SIZE 64
-//MMAP
-static uint8_t *mmap_reg = NULL;
+// MMAP
+static uint8_t* mmap_reg = NULL;
static int mmap_fd = 0;
static int mmap_size;
static unsigned int mmap_count = 0;
static int platform_detected = 0;
mraa_result_t
-mraa_raspberry_pi_spi_init_pre(int index) {
+mraa_raspberry_pi_spi_init_pre(int index)
+{
char devpath[MAX_SIZE];
sprintf(devpath, "/dev/spidev%u.0", plat->spi_bus[index].bus_id);
if (!mraa_file_exist(devpath)) {
syslog(LOG_ERR, "spi: Device not initialized");
- syslog(LOG_ERR, "spi: If you run a kernel >=3.18 then you will have to add dtparam=spi=on to /boot/config.txt and reboot");
+ syslog(LOG_ERR, "spi: If you run a kernel >=3.18 then you will have to add dtparam=spi=on "
+ "to /boot/config.txt and reboot");
syslog(LOG_INFO, "spi: trying modprobe for spi-bcm2708");
system("modprobe spi-bcm2708 >/dev/null 2>&1");
system("modprobe spi_bcm2708 >/dev/null 2>&1");
}
mraa_result_t
-mraa_raspberry_pi_i2c_init_pre(unsigned int bus) {
+mraa_raspberry_pi_i2c_init_pre(unsigned int bus)
+{
char devpath[MAX_SIZE];
sprintf(devpath, "/dev/i2c-%u", bus);
if (!mraa_file_exist(devpath)) {
if (!mraa_file_exist(devpath)) {
syslog(LOG_ERR, "i2c: Device not initialized");
if (platform_detected == PLATFORM_RASPBERRY_PI_B_REV_1) {
- syslog(LOG_ERR, "i2c: If you run a kernel >=3.18 then you will have to add dtparam=i2c0=on to /boot/config.txt and reboot");
- }
- else {
- syslog(LOG_ERR, "i2c: If you run a kernel >=3.18 then you will have to add dtparam=i2c1=on to /boot/config.txt and reboot");
+ syslog(LOG_ERR, "i2c: If you run a kernel >=3.18 then you will have to add "
+ "dtparam=i2c0=on to /boot/config.txt and reboot");
+ } else {
+ syslog(LOG_ERR, "i2c: If you run a kernel >=3.18 then you will have to add "
+ "dtparam=i2c1=on to /boot/config.txt and reboot");
}
return MRAA_ERROR_NO_RESOURCES;
}
mraa_result_t
mraa_raspberry_pi_mmap_write(mraa_gpio_context dev, int value)
{
- volatile uint32_t *addr;
+ volatile uint32_t* addr;
if (value) {
- *(volatile uint32_t *) (mmap_reg + BCM283X_GPSET0 + (dev->pin / 32) * 4) =
- (uint32_t) (1 << (dev->pin % 32));
- }
- else {
- *(volatile uint32_t *) (mmap_reg + BCM283X_GPCLR0 + (dev->pin / 32) * 4) =
- (uint32_t) (1 << (dev->pin % 32));
+ *(volatile uint32_t*) (mmap_reg + BCM283X_GPSET0 + (dev->pin / 32) * 4) =
+ (uint32_t)(1 << (dev->pin % 32));
+ } else {
+ *(volatile uint32_t*) (mmap_reg + BCM283X_GPCLR0 + (dev->pin / 32) * 4) =
+ (uint32_t)(1 << (dev->pin % 32));
}
return MRAA_SUCCESS;
}
mraa_raspberry_pi_mmap_read(mraa_gpio_context dev)
{
uint32_t value = *(volatile uint32_t*) (mmap_reg + BCM2835_GPLEV0 + (dev->pin / 32) * 4);
- if (value&(uint32_t)(1 << (dev->pin % 32))) {
+ if (value & (uint32_t)(1 << (dev->pin % 32))) {
return 1;
}
return 0;
return MRAA_ERROR_INVALID_PARAMETER;
}
- //Might need to make some elements of this thread safe.
- //For example only allow one thread to enter the following block
- //to prevent mmap'ing twice.
+ // Might need to make some elements of this thread safe.
+ // For example only allow one thread to enter the following block
+ // to prevent mmap'ing twice.
if (mmap_reg == NULL) {
if ((mmap_fd = open(MMAP_PATH, O_RDWR)) < 0) {
syslog(LOG_ERR, "raspberry map: unable to open resource0 file");
return MRAA_ERROR_INVALID_HANDLE;
}
- if (platform_detected==PLATFORM_RASPBERRY_PI2_B_REV_1) {
- mmap_reg = (uint8_t*) mmap(NULL, BCM2836_BLOCK_SIZE,
- PROT_READ | PROT_WRITE,
- MAP_FILE | MAP_SHARED,
- mmap_fd, BCM2836_GPIO_BASE);
- }
- else {
- mmap_reg = (uint8_t*) mmap(NULL, BCM2835_BLOCK_SIZE,
- PROT_READ | PROT_WRITE,
- MAP_FILE | MAP_SHARED,
- mmap_fd, BCM2835_GPIO_BASE);
+ if (platform_detected == PLATFORM_RASPBERRY_PI2_B_REV_1) {
+ mmap_reg = (uint8_t*) mmap(NULL, BCM2836_BLOCK_SIZE, PROT_READ | PROT_WRITE,
+ MAP_FILE | MAP_SHARED, mmap_fd, BCM2836_GPIO_BASE);
+ } else {
+ mmap_reg = (uint8_t*) mmap(NULL, BCM2835_BLOCK_SIZE, PROT_READ | PROT_WRITE,
+ MAP_FILE | MAP_SHARED, mmap_fd, BCM2835_GPIO_BASE);
}
if (mmap_reg == MAP_FAILED) {
syslog(LOG_ERR, "raspberry mmap: failed to mmap");
return MRAA_SUCCESS;
}
-mraa_board_t *
-mraa_raspberry_pi() {
- mraa_board_t *b = (mraa_board_t *) malloc(sizeof(mraa_board_t));
+mraa_board_t*
+mraa_raspberry_pi()
+{
+ mraa_board_t* b = (mraa_board_t*) malloc(sizeof(mraa_board_t));
if (b == NULL) {
return NULL;
}
size_t len = 100;
- char *line = malloc(len);
+ char* line = malloc(len);
- FILE *fh = fopen("/proc/cpuinfo", "r");
+ FILE* fh = fopen("/proc/cpuinfo", "r");
if (fh != NULL) {
while (getline(&line, &len, fh) != -1) {
if (strncmp(line, "Revision", 8) == 0) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
- }
- else if (strstr(line, "0004") || strstr(line, "0005") || strstr(line, "0006") \
- || strstr(line, "000d") || strstr(line, "000e") || strstr(line, "000f")) {
+ } else if (strstr(line, "0004") || strstr(line, "0005") || strstr(line, "0006") ||
+ strstr(line, "000d") || strstr(line, "000e") || strstr(line, "000f")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
- }
- else if (strstr(line, "0007") || strstr(line, "0008") || strstr(line, "0009")) {
+ } else if (strstr(line, "0007") || strstr(line, "0008") || strstr(line, "0009")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2;
platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
- }
- else if (strstr(line, "0010")) {
+ } else if (strstr(line, "0010")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_PLUS_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
- }
- else if (strstr(line, "0011")) {
+ } else if (strstr(line, "0011")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT;
- }
- else if (strstr(line, "0012")) {
+ } else if (strstr(line, "0012")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
- }
- else if (strstr(line, "a01041")) {
+ } else if (strstr(line, "a01041")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
- }
- else {
+ } else {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
b->pwm_max_period = 2147483;
b->pwm_min_period = 1;
- b->pins = (mraa_pininfo_t *) malloc(sizeof(mraa_pininfo_t) * b->phy_pin_count);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * b->phy_pin_count);
advance_func->spi_init_pre = &mraa_raspberry_pi_spi_init_pre;
advance_func->i2c_init_pre = &mraa_raspberry_pi_i2c_init_pre;
advance_func->gpio_mmap_setup = &mraa_raspberry_pi_mmap_setup;
strncpy(b->pins[0].name, "INVALID", 8);
- b->pins[0].capabilites = (mraa_pincapabilities_t) {0, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[0].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[1].name, "3V3", 8);
- b->pins[1].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[2].name, "5V", 8);
- b->pins[2].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[3].name, "SDA0", 8);
- b->pins[3].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 1, 0, 0};
+ b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[3].gpio.pinmap = 2;
b->pins[3].gpio.mux_total = 0;
b->pins[3].i2c.pinmap = 0;
b->pins[3].i2c.mux_total = 0;
strncpy(b->pins[4].name, "5V", 8);
- b->pins[4].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[5].name, "SCL0", 8);
- b->pins[5].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 1, 0, 0};
+ b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[5].gpio.pinmap = 3;
b->pins[5].gpio.mux_total = 0;
b->pins[5].i2c.pinmap = 0;
b->pins[5].i2c.mux_total = 0;
strncpy(b->pins[6].name, "GND", 8);
- b->pins[6].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[7].name, "GPIO4", 8);
- b->pins[7].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 4;
b->pins[7].gpio.mux_total = 0;
strncpy(b->pins[8].name, "UART_TX", 8);
- b->pins[8].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 1};
+ b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[8].gpio.pinmap = 14;
b->pins[8].gpio.mux_total = 0;
b->pins[8].uart.parent_id = 0;
b->pins[8].uart.mux_total = 0;
strncpy(b->pins[9].name, "GND", 8);
- b->pins[9].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[10].name, "UART_RX", 8);
- b->pins[10].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 1};
+ b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[10].gpio.pinmap = 15;
b->pins[10].gpio.mux_total = 0;
b->pins[10].uart.parent_id = 0;
b->pins[10].uart.mux_total = 0;
strncpy(b->pins[11].name, "GPIO17", 8);
- b->pins[11].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[11].gpio.pinmap = 17;
b->pins[11].gpio.mux_total = 0;
strncpy(b->pins[12].name, "GPIO18", 8);
- b->pins[12].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[12].gpio.pinmap = 18;
b->pins[12].gpio.mux_total = 0;
strncpy(b->pins[13].name, "GPIO27", 8);
b->pins[13].gpio.pinmap = 27;
}
- b->pins[13].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[13].gpio.mux_total = 0;
strncpy(b->pins[14].name, "GND", 8);
- b->pins[14].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[15].name, "GPIO22", 8);
- b->pins[15].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[15].gpio.pinmap = 22;
b->pins[15].gpio.mux_total = 0;
strncpy(b->pins[16].name, "GPIO23", 8);
- b->pins[16].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[16].gpio.pinmap = 23;
b->pins[16].gpio.mux_total = 0;
strncpy(b->pins[17].name, "3V3", 8);
- b->pins[17].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[18].name, "GPIO24", 8);
- b->pins[18].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[18].gpio.pinmap = 24;
b->pins[18].gpio.mux_total = 0;
strncpy(b->pins[19].name, "SPI_MOSI", 8);
- b->pins[19].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 1, 0, 0, 0};
+ b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[19].gpio.pinmap = 10;
b->pins[19].gpio.mux_total = 0;
b->pins[19].spi.pinmap = 0;
b->pins[19].spi.mux_total = 0;
strncpy(b->pins[20].name, "GND", 8);
- b->pins[20].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[20].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[21].name, "SPI_MISO", 8);
- b->pins[21].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 1, 0, 0, 0};
+ b->pins[21].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[21].gpio.pinmap = 9;
b->pins[21].gpio.mux_total = 0;
b->pins[21].spi.pinmap = 0;
b->pins[21].spi.mux_total = 0;
strncpy(b->pins[22].name, "GPIO25", 8);
- b->pins[22].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[22].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[22].gpio.pinmap = 25;
b->pins[22].gpio.mux_total = 0;
strncpy(b->pins[23].name, "SPI_CLK", 8);
- b->pins[23].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 1, 0, 0, 0};
+ b->pins[23].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[23].gpio.pinmap = 11;
b->pins[23].gpio.mux_total = 0;
b->pins[23].spi.pinmap = 0;
b->pins[23].spi.mux_total = 0;
strncpy(b->pins[24].name, "SPI_CS0", 8);
- b->pins[24].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 1, 0, 0, 0};
+ b->pins[24].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[24].gpio.pinmap = 8;
b->pins[24].gpio.mux_total = 0;
b->pins[24].spi.pinmap = 0;
b->pins[24].spi.mux_total = 0;
strncpy(b->pins[25].name, "GND", 8);
- b->pins[25].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[25].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[26].name, "SPI_CS1", 8);
- b->pins[26].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 1, 0, 0, 0};
+ b->pins[26].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[26].gpio.pinmap = 7;
b->pins[26].gpio.mux_total = 0;
b->pins[26].spi.pinmap = 0;
b->pins[26].spi.mux_total = 0;
- if ((platform_detected == PLATFORM_RASPBERRY_PI_A_REV_2) || \
+ if ((platform_detected == PLATFORM_RASPBERRY_PI_A_REV_2) ||
(platform_detected == PLATFORM_RASPBERRY_PI_B_REV_2)) {
strncpy(b->pins[27].name, "5V", 8);
- b->pins[27].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[28].name, "3V3", 8);
- b->pins[28].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[29].name, "GPIO8", 8);
- b->pins[29].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].gpio.pinmap = 8;
b->pins[29].gpio.mux_total = 0;
strncpy(b->pins[30].name, "GPIO9", 8);
- b->pins[30].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[30].gpio.pinmap = 9;
b->pins[30].gpio.mux_total = 0;
strncpy(b->pins[31].name, "GPIO10", 8);
- b->pins[31].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].gpio.pinmap = 10;
b->pins[31].gpio.mux_total = 0;
strncpy(b->pins[32].name, "GPIO11", 8);
b->pins[32].gpio.pinmap = 11;
b->pins[32].gpio.mux_total = 0;
- b->pins[32].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[33].name, "GND", 8);
- b->pins[33].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[34].name, "GND", 8);
- b->pins[34].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
-
+ b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
}
- //BUS DEFINITIONS
+ // BUS DEFINITIONS
b->i2c_bus_count = 1;
b->def_i2c_bus = 0;
if (platform_detected == PLATFORM_RASPBERRY_PI_B_REV_1)
- b->i2c_bus[0].bus_id = 0;
+ b->i2c_bus[0].bus_id = 0;
else
- b->i2c_bus[0].bus_id = 1;
+ b->i2c_bus[0].bus_id = 1;
b->i2c_bus[0].sda = 3;
b->i2c_bus[0].scl = 5;
b->uart_dev[0].rx = 10;
b->uart_dev[0].tx = 8;
- if ((platform_detected == PLATFORM_RASPBERRY_PI_A_PLUS_REV_1) || \
- (platform_detected == PLATFORM_RASPBERRY_PI_B_PLUS_REV_1) || \
+ if ((platform_detected == PLATFORM_RASPBERRY_PI_A_PLUS_REV_1) ||
+ (platform_detected == PLATFORM_RASPBERRY_PI_B_PLUS_REV_1) ||
(platform_detected == PLATFORM_RASPBERRY_PI2_B_REV_1)) {
strncpy(b->pins[27].name, "ID_SD", 8);
- b->pins[27].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[28].name, "ID_SC", 8);
- b->pins[28].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[29].name, "GPIO05", 8);
- b->pins[29].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].gpio.pinmap = 5;
b->pins[29].gpio.mux_total = 0;
strncpy(b->pins[30].name, "GND", 8);
- b->pins[30].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[31].name, "GPIO06", 8);
- b->pins[31].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].gpio.pinmap = 6;
b->pins[31].gpio.mux_total = 0;
strncpy(b->pins[32].name, "GPIO12", 8);
- b->pins[32].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[32].gpio.pinmap = 12;
b->pins[32].gpio.mux_total = 0;
strncpy(b->pins[33].name, "GPIO13", 8);
- b->pins[33].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[33].gpio.pinmap = 13;
b->pins[33].gpio.mux_total = 0;
strncpy(b->pins[34].name, "GND", 8);
- b->pins[34].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[35].name, "GPIO19", 8);
- b->pins[35].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[35].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[35].gpio.pinmap = 19;
b->pins[35].gpio.mux_total = 0;
strncpy(b->pins[36].name, "GPIO16", 8);
- b->pins[36].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[36].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[36].gpio.pinmap = 16;
b->pins[36].gpio.mux_total = 0;
strncpy(b->pins[37].name, "GPIO26", 8);
- b->pins[37].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[37].gpio.pinmap = 26;
b->pins[37].gpio.mux_total = 0;
strncpy(b->pins[38].name, "GPIO20", 8);
- b->pins[38].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[38].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[38].gpio.pinmap = 20;
b->pins[38].gpio.mux_total = 0;
strncpy(b->pins[39].name, "GND", 8);
- b->pins[39].capabilites = (mraa_pincapabilities_t) {1, 0, 0, 0, 0, 0, 0, 0};
+ b->pins[39].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[40].name, "GPIO21", 8);
- b->pins[40].capabilites = (mraa_pincapabilities_t) {1, 1, 0, 0, 0, 0, 0, 0};
+ b->pins[40].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[40].gpio.pinmap = 21;
b->pins[40].gpio.mux_total = 0;
}
- b->gpio_count=0;
+ b->gpio_count = 0;
int i;
- for (i=0; i < b->phy_pin_count; i++) {
+ for (i = 0; i < b->phy_pin_count; i++) {
if (b->pins[i].capabilites.gpio) {
b->gpio_count++;
}
return NULL;
}
length = snprintf(bu, sizeof(bu), "%d", dev->pin);
- if (write(export, bu, length*sizeof(char)) == -1) {
+ if (write(export, bu, length * sizeof(char)) == -1) {
syslog(LOG_ERR, "gpio: Failed to write %d to export", dev->pin);
close(export);
free(dev);
pfd.events = POLLPRI;
// do an initial read to clear interrupt
- lseek (fd, 0, SEEK_SET);
- read (fd, &c, 1);
+ lseek(fd, 0, SEEK_SET);
+ read(fd, &c, 1);
// Wait for it forever or until pthread_cancel
// poll is a cancelable point like sleep()
- int x = poll (&pfd, 1, -1);
+ int x = poll(&pfd, 1, -1);
// do a final read to clear interrupt
- read (fd, &c, 1);
+ read(fd, &c, 1);
return MRAA_SUCCESS;
}
// nessecary but especially if doing IO (like print()) python will segfault
// if we do not hold a lock on the GIL
PyGILState_STATE gilstate = PyGILState_Ensure();
- PyObject *arglist;
- PyObject *ret;
+ PyObject* arglist;
+ PyObject* ret;
arglist = Py_BuildValue("(i)", dev->isr_args);
if (arglist == NULL) {
syslog(LOG_ERR, "gpio: Py_BuildValue NULL");
} else {
- ret = PyEval_CallObject((PyObject*)dev->isr, arglist);
+ ret = PyEval_CallObject((PyObject*) dev->isr, arglist);
if (ret == NULL) {
syslog(LOG_ERR, "gpio: PyEval_CallObject failed");
} else {
Py_DECREF(arglist);
}
- PyGILState_Release (gilstate);
+ PyGILState_Release(gilstate);
#else
dev->isr(dev->isr_args);
#endif
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
} else {
- // we must have got an error code so die nicely
+ // we must have got an error code so die nicely
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
close(dev->isr_value_fp);
dev->isr_value_fp = -1;
mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode)
{
if (dev->value_fp != -1) {
- close(dev->value_fp);
- dev->value_fp = -1;
+ close(dev->value_fp);
+ dev->value_fp = -1;
}
char filepath[MAX_SIZE];
char bu[MAX_SIZE];
int length;
- switch(mode) {
+ switch (mode) {
case MRAA_GPIO_EDGE_NONE:
length = snprintf(bu, sizeof(bu), "none");
break;
close(edge);
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
- if (write(edge, bu, length*sizeof(char)) == -1) {
+ if (write(edge, bu, length * sizeof(char)) == -1) {
syslog(LOG_ERR, "gpio: Failed to write to edge");
close(edge);
return MRAA_ERROR_INVALID_RESOURCE;
}
mraa_result_t
-mraa_gpio_isr(mraa_gpio_context dev, gpio_edge_t mode, void (*fptr)(void *), void * args)
+mraa_gpio_isr(mraa_gpio_context dev, gpio_edge_t mode, void (*fptr)(void*), void* args)
{
// we only allow one isr per mraa_gpio_context
if (dev->thread_id != 0) {
dev->isr = fptr;
dev->isr_args = args;
- pthread_create (&dev->thread_id, NULL, mraa_gpio_interrupt_handler, (void *) dev);
+ pthread_create(&dev->thread_id, NULL, mraa_gpio_interrupt_handler, (void*) dev);
return MRAA_SUCCESS;
}
// close the filehandle in case it's still open
if (dev->isr_value_fp != -1) {
- if (close(dev->isr_value_fp) != 0) {
- ret = MRAA_ERROR_INVALID_PARAMETER;
- }
+ if (close(dev->isr_value_fp) != 0) {
+ ret = MRAA_ERROR_INVALID_PARAMETER;
+ }
}
#ifdef SWIGPYTHON
mraa_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode)
{
if (advance_func->gpio_mode_replace != NULL)
- return advance_func->gpio_mode_replace(dev,mode);
+ return advance_func->gpio_mode_replace(dev, mode);
if (advance_func->gpio_mode_pre != NULL) {
- mraa_result_t pre_ret = (advance_func->gpio_mode_pre(dev,mode));
- if(pre_ret != MRAA_SUCCESS)
+ mraa_result_t pre_ret = (advance_func->gpio_mode_pre(dev, mode));
+ if (pre_ret != MRAA_SUCCESS)
return pre_ret;
}
if (dev->value_fp != -1) {
- close(dev->value_fp);
- dev->value_fp = -1;
+ close(dev->value_fp);
+ dev->value_fp = -1;
}
char filepath[MAX_SIZE];
char bu[MAX_SIZE];
int length;
- switch(mode) {
+ switch (mode) {
case MRAA_GPIO_STRONG:
length = snprintf(bu, sizeof(bu), "strong");
break;
close(drive);
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
- if (write(drive, bu, length*sizeof(char)) == -1) {
+ if (write(drive, bu, length * sizeof(char)) == -1) {
syslog(LOG_ERR, "gpio: Failed to write to drive mode");
close(drive);
return MRAA_ERROR_INVALID_RESOURCE;
-
}
close(drive);
if (advance_func->gpio_mode_post != NULL)
- return advance_func->gpio_mode_post(dev,mode);
+ return advance_func->gpio_mode_post(dev, mode);
return MRAA_SUCCESS;
}
mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir)
{
if (advance_func->gpio_dir_replace != NULL) {
- return advance_func->gpio_dir_replace(dev,dir);
+ return advance_func->gpio_dir_replace(dev, dir);
}
if (advance_func->gpio_dir_pre != NULL) {
- mraa_result_t pre_ret = (advance_func->gpio_dir_pre(dev,dir));
+ mraa_result_t pre_ret = (advance_func->gpio_dir_pre(dev, dir));
if (pre_ret != MRAA_SUCCESS) {
return pre_ret;
}
return MRAA_ERROR_INVALID_HANDLE;
}
if (dev->value_fp != -1) {
- close(dev->value_fp);
- dev->value_fp = -1;
+ close(dev->value_fp);
+ dev->value_fp = -1;
}
char filepath[MAX_SIZE];
snprintf(filepath, MAX_SIZE, SYSFS_CLASS_GPIO "/gpio%d/direction", dev->pin);
char bu[MAX_SIZE];
int length;
- switch(dir) {
+ switch (dir) {
case MRAA_GPIO_OUT:
length = snprintf(bu, sizeof(bu), "out");
break;
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
- if (write(direction, bu, length*sizeof(char)) == -1) {
+ if (write(direction, bu, length * sizeof(char)) == -1) {
close(direction);
return MRAA_ERROR_INVALID_RESOURCE;
}
close(direction);
if (advance_func->gpio_dir_post != NULL)
- return advance_func->gpio_dir_post(dev,dir);
+ return advance_func->gpio_dir_post(dev, dir);
return MRAA_SUCCESS;
}
syslog(LOG_ERR, "gpio: Failed to get value file pointer");
return -1;
}
- }
- else {
+ } else {
// if value_fp is new this is pointless
lseek(dev->value_fp, 0, SEEK_SET);
}
char bu[2];
- if (read(dev->value_fp, bu, 2*sizeof(char)) != 2) {
+ if (read(dev->value_fp, bu, 2 * sizeof(char)) != 2) {
syslog(LOG_ERR, "gpio: Failed to read a sensible value from sysfs");
return -1;
}
return MRAA_ERROR_INVALID_HANDLE;
if (dev->mmap_write != NULL)
- return dev->mmap_write(dev,value);
+ return dev->mmap_write(dev, value);
if (advance_func->gpio_write_pre != NULL) {
- mraa_result_t pre_ret = (advance_func->gpio_write_pre(dev,value));
- if(pre_ret != MRAA_SUCCESS)
+ mraa_result_t pre_ret = (advance_func->gpio_write_pre(dev, value));
+ if (pre_ret != MRAA_SUCCESS)
return pre_ret;
}
char bu[MAX_SIZE];
int length = snprintf(bu, sizeof(bu), "%d", value);
- if (write(dev->value_fp, bu, length*sizeof(char)) == -1) {
+ if (write(dev->value_fp, bu, length * sizeof(char)) == -1) {
return MRAA_ERROR_INVALID_HANDLE;
}
if (advance_func->gpio_write_post != NULL)
- return advance_func->gpio_write_post(dev,value);
+ return advance_func->gpio_write_post(dev, value);
return MRAA_SUCCESS;
}
char bu[MAX_SIZE];
int length = snprintf(bu, sizeof(bu), "%d", dev->pin);
- if (write(unexport, bu, length*sizeof(char)) == -1) {
+ if (write(unexport, bu, length * sizeof(char)) == -1) {
syslog(LOG_ERR, "gpio: Failed to write to unexport");
close(unexport);
return MRAA_ERROR_INVALID_RESOURCE;
static mraa_result_t
mraa_gpio_unexport(mraa_gpio_context dev)
{
- if(dev->owner) {
+ if (dev->owner) {
return mraa_gpio_unexport_force(dev);
}
return MRAA_ERROR_INVALID_RESOURCE;
mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap_en)
{
if (advance_func->gpio_mmap_setup != NULL) {
- return advance_func->gpio_mmap_setup(dev,mmap_en);
+ return advance_func->gpio_mmap_setup(dev, mmap_en);
}
syslog(LOG_ERR, "gpio: mmap not implemented on this platform");
#include <sys/ioctl.h>
#include "linux/i2c-dev.h"
-typedef union i2c_smbus_data_union
-{
- uint8_t byte; ///< data byte
+typedef union i2c_smbus_data_union {
+ uint8_t byte; ///< data byte
unsigned short word; ///< data short word
uint8_t block[I2C_SMBUS_BLOCK_MAX + 2];
///< block[0] is used for length and one more for PEC
} i2c_smbus_data_t;
-typedef struct i2c_smbus_ioctl_data_struct
-{
- uint8_t read_write; ///< operation direction
- uint8_t command; ///< ioctl command
- int size; ///< data size
- i2c_smbus_data_t *data; ///< data
+typedef struct i2c_smbus_ioctl_data_struct {
+ uint8_t read_write; ///< operation direction
+ uint8_t command; ///< ioctl command
+ int size; ///< data size
+ i2c_smbus_data_t* data; ///< data
} i2c_smbus_ioctl_data_t;
int
-mraa_i2c_smbus_access(int fh, uint8_t read_write, uint8_t command, int size,
- i2c_smbus_data_t *data)
+mraa_i2c_smbus_access(int fh, uint8_t read_write, uint8_t command, int size, i2c_smbus_data_t* data)
{
- i2c_smbus_ioctl_data_t args;
+ i2c_smbus_ioctl_data_t args;
- args.read_write = read_write;
- args.command = command;
- args.size = size;
- args.data = data;
+ args.read_write = read_write;
+ args.command = command;
+ args.size = size;
+ args.data = data;
- return ioctl(fh, I2C_SMBUS, &args);
+ return ioctl(fh, I2C_SMBUS, &args);
}
mraa_i2c_context
{
i2c_smbus_data_t d;
- if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, I2C_NOCMD,
- I2C_SMBUS_BYTE, &d) < 0) {
+ if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, I2C_NOCMD, I2C_SMBUS_BYTE, &d) < 0) {
syslog(LOG_ERR, "i2c: Failed to write");
return 0;
}
{
i2c_smbus_data_t d;
- if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, command,
- I2C_SMBUS_BYTE_DATA, &d) < 0) {
+ if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, command, I2C_SMBUS_BYTE_DATA, &d) < 0) {
syslog(LOG_ERR, "i2c: Failed to write");
return 0;
}
{
i2c_smbus_data_t d;
- if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, command,
- I2C_SMBUS_WORD_DATA, &d) < 0) {
+ if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, command, I2C_SMBUS_WORD_DATA, &d) < 0) {
syslog(LOG_ERR, "i2c: Failed to write");
return 0;
}
uint8_t command = data[0];
data = &data[1];
- length = length-1;
+ length = length - 1;
if (length > I2C_SMBUS_I2C_BLOCK_MAX) {
length = I2C_SMBUS_I2C_BLOCK_MAX;
}
- for (i=1; i<=length; i++) {
- d.block[i] = data[i-1];
+ for (i = 1; i <= length; i++) {
+ d.block[i] = data[i - 1];
}
d.block[0] = length;
- return mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command,
- I2C_SMBUS_I2C_BLOCK_DATA, &d);
+ return mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_I2C_BLOCK_DATA, &d);
}
mraa_result_t
mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data)
{
- if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, data,
- I2C_SMBUS_BYTE, NULL) < 0) {
+ if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, data, I2C_SMBUS_BYTE, NULL) < 0) {
syslog(LOG_ERR, "i2c: Failed to write");
return MRAA_ERROR_INVALID_HANDLE;
}
}
mraa_result_t
-mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data,
- const uint8_t command)
+mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command)
{
i2c_smbus_data_t d;
d.byte = data;
- if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command,
- I2C_SMBUS_BYTE_DATA, &d) < 0) {
+ if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_BYTE_DATA, &d) < 0) {
syslog(LOG_ERR, "i2c: Failed to write");
return MRAA_ERROR_INVALID_HANDLE;
}
}
mraa_result_t
-mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data,
- const uint8_t command)
+mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command)
{
i2c_smbus_data_t d;
d.word = data;
- if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command,
- I2C_SMBUS_WORD_DATA, &d) < 0) {
+ if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_WORD_DATA, &d) < 0) {
syslog(LOG_ERR, "i2c: Failed to write");
return MRAA_ERROR_INVALID_HANDLE;
}
static mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
mraa_adv_func_t* advance_func;
-const char *
+const char*
mraa_get_version()
{
return gVERSION;
}
uid_t proc_euid = geteuid();
- struct passwd *proc_user = getpwuid(proc_euid);
+ struct passwd* proc_user = getpwuid(proc_euid);
#ifdef DEBUG
setlogmask(LOG_UPTO(LOG_DEBUG));
#endif
openlog("libmraa", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
- syslog(LOG_NOTICE,
- "libmraa version %s initialised by user '%s' with EUID %d",
- mraa_get_version(),
- (proc_user != NULL) ? proc_user->pw_name : "<unknown>",
- proc_euid);
+ syslog(LOG_NOTICE, "libmraa version %s initialised by user '%s' with EUID %d",
+ mraa_get_version(), (proc_user != NULL) ? proc_user->pw_name : "<unknown>", proc_euid);
#ifdef SWIGPYTHON
// Initialise python threads, this allows use to grab the GIL when we are
// Use runtime ARM platform detection
platform_type = mraa_arm_platform();
#else
- #error mraa_ARCH NOTHING
+#error mraa_ARCH NOTHING
#endif
if (plat == NULL) {
return MRAA_ERROR_PLATFORM_NOT_INITIALISED;
}
- syslog(LOG_INFO,
- "libmraa initialised for platform '%s' of type %d",
- mraa_get_platform_name(),
- platform_type);
+ syslog(LOG_INFO, "libmraa initialised for platform '%s' of type %d", mraa_get_platform_name(), platform_type);
return MRAA_SUCCESS;
}
memset(&sched_s, 0, sizeof(struct sched_param));
if (priority > sched_get_priority_max(SCHED_RR)) {
sched_s.sched_priority = sched_get_priority_max(SCHED_RR);
- }
- else {
+ } else {
sched_s.sched_priority = priority;
}
if (plat == NULL)
return 0;
}
- if (pin > (plat->phy_pin_count -1) || pin < 0)
+ if (pin > (plat->phy_pin_count - 1) || pin < 0)
return 0;
- switch(mode) {
+ switch (mode) {
case MRAA_PIN_VALID:
if (plat->pins[pin].capabilites.valid == 1)
return 1;
break;
case MRAA_PIN_GPIO:
- if (plat->pins[pin].capabilites.gpio ==1)
+ if (plat->pins[pin].capabilites.gpio == 1)
return 1;
break;
case MRAA_PIN_PWM:
- if (plat->pins[pin].capabilites.pwm ==1)
+ if (plat->pins[pin].capabilites.pwm == 1)
return 1;
break;
case MRAA_PIN_FAST_GPIO:
- if (plat->pins[pin].capabilites.fast_gpio ==1)
+ if (plat->pins[pin].capabilites.fast_gpio == 1)
return 1;
break;
case MRAA_PIN_SPI:
- if (plat->pins[pin].capabilites.spi ==1)
+ if (plat->pins[pin].capabilites.spi == 1)
return 1;
break;
case MRAA_PIN_I2C:
- if (plat->pins[pin].capabilites.i2c ==1)
+ if (plat->pins[pin].capabilites.i2c == 1)
return 1;
break;
case MRAA_PIN_AIO:
- if (plat->pins[pin].capabilites.aio ==1)
+ if (plat->pins[pin].capabilites.aio == 1)
return 1;
break;
case MRAA_PIN_UART:
return 0;
}
-mraa_platform_t mraa_get_platform_type()
+mraa_platform_t
+mraa_get_platform_type()
{
return platform_type;
}
}
mraa_boolean_t
-mraa_file_exist(char *filename) {
+mraa_file_exist(char* filename)
+{
glob_t results;
results.gl_pathc = 0;
glob(filename, 0, NULL, &results);
if (plat == NULL) {
return NULL;
}
- if (pin > (plat->phy_pin_count -1) || pin < 0)
+ if (pin > (plat->phy_pin_count - 1) || pin < 0)
return NULL;
return (char*) plat->pins[pin].name;
}
char*
-mraa_file_unglob(char *filename) {
+mraa_file_unglob(char* filename)
+{
glob_t results;
- char *res = NULL;
+ char* res = NULL;
results.gl_pathc = 0;
glob(filename, 0, NULL, &results);
if (results.gl_pathc == 1)
}
mraa_boolean_t
-mraa_link_targets(char *filename,char *targetname) {
+mraa_link_targets(char* filename, char* targetname)
+{
int size = 100;
int nchars = 0;
- char *buffer = NULL;
- while (nchars == 0)
- {
- buffer = (char *) realloc(buffer,size);
+ char* buffer = NULL;
+ while (nchars == 0) {
+ buffer = (char*) realloc(buffer, size);
if (buffer == NULL)
return 0;
- nchars = readlink(filename,buffer,size);
- if (nchars < 0 ) {
+ nchars = readlink(filename, buffer, size);
+ if (nchars < 0) {
free(buffer);
return 0;
}
if (nchars >= size) {
- size *=2;
- nchars=0;
+ size *= 2;
+ nchars = 0;
}
}
- if (strstr(buffer,targetname)) {
+ if (strstr(buffer, targetname)) {
free(buffer);
return 1;
- }
- else {
+ } else {
free(buffer);
return 0;
}
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);
+ snprintf(bu, MAX_SIZE, "/sys/class/pwm/pwmchip%d/pwm%d/duty_cycle", dev->chipid, dev->pin);
dev->duty_fp = open(bu, O_RDWR);
if (dev->duty_fp == -1) {
mraa_pwm_write_period(mraa_pwm_context dev, int period)
{
if (advance_func->pwm_period_replace != NULL) {
- mraa_result_t result = advance_func->pwm_period_replace(dev,period);
+ mraa_result_t result = advance_func->pwm_period_replace(dev, period);
if (result == MRAA_SUCCESS) {
dev->period = period;
}
return result;
}
char bu[MAX_SIZE];
- snprintf(bu,MAX_SIZE ,"/sys/class/pwm/pwmchip%d/pwm%d/period", dev->chipid, dev->pin);
+ 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) {
}
char out[MAX_SIZE];
int length = snprintf(out, MAX_SIZE, "%d", period);
- if (write(period_f, out, length*sizeof(char)) == -1) {
+ if (write(period_f, out, length * sizeof(char)) == -1) {
close(period_f);
return MRAA_ERROR_INVALID_RESOURCE;
}
{
char bu[MAX_SIZE];
char output[MAX_SIZE];
- snprintf(bu,MAX_SIZE, "/sys/class/pwm/pwmchip%d/pwm%d/period", dev->chipid, dev->pin);
+ 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) {
return -1;
}
- char *endptr;
+ char* endptr;
long int ret = strtol(output, &endptr, 10);
if ('\0' != *endptr && '\n' != *endptr) {
syslog(LOG_ERR, "pwm: Error in string conversion");
return -1;
- }
- else if (ret > INT_MAX || ret < INT_MIN) {
+ } else if (ret > INT_MAX || ret < INT_MIN) {
syslog(LOG_ERR, "pwm: Number is invalid");
return -1;
}
- dev->period = (int)ret;
+ dev->period = (int) ret;
return (int) ret;
}
off_t size = lseek(dev->duty_fp, 0, SEEK_END);
lseek(dev->duty_fp, 0, SEEK_SET);
char output[MAX_SIZE];
- ssize_t rb = read(dev->duty_fp, output, size+1);
+ ssize_t rb = read(dev->duty_fp, output, size + 1);
if (rb < 0) {
syslog(LOG_ERR, "pwm: Error in reading duty");
return -1;
}
- char *endptr;
+ char* endptr;
long int ret = strtol(output, &endptr, 10);
if ('\0' != *endptr && '\n' != *endptr) {
syslog(LOG_ERR, "pwm: Error in string converstion");
return -1;
- }
- else if (ret > INT_MAX || ret < INT_MIN) {
+ } else if (ret > INT_MAX || ret < INT_MIN) {
syslog(LOG_ERR, "pwm: Number is invalid");
return -1;
}
int pinn = plat->pins[pin].pwm.pinmap;
if (advance_func->pwm_init_post != NULL) {
- mraa_pwm_context pret = mraa_pwm_init_raw(chip,pinn);
+ mraa_pwm_context pret = mraa_pwm_init_raw(chip, pinn);
mraa_result_t ret = advance_func->pwm_init_post(pret);
if (ret != MRAA_SUCCESS) {
free(pret);
}
return pret;
}
- return mraa_pwm_init_raw(chip,pinn);
+ return mraa_pwm_init_raw(chip, pinn);
}
mraa_pwm_context
char out[MAX_SIZE];
int size = snprintf(out, MAX_SIZE, "%d", dev->pin);
- if (write(export_f, out, size*sizeof(char)) == -1) {
+ if (write(export_f, out, size * sizeof(char)) == -1) {
syslog(LOG_WARNING, "pwm: Failed to write to export! Potentially already enabled");
close(export_f);
free(dev);
{
int period = mraa_pwm_read_period(dev);
if (period > 0) {
- return (mraa_pwm_read_duty(dev) / (float) period);
+ return (mraa_pwm_read_duty(dev) / (float) period);
}
return 0.0f;
}
mraa_result_t
mraa_pwm_period(mraa_pwm_context dev, float seconds)
{
- return mraa_pwm_period_ms(dev, seconds*1000);
+ return mraa_pwm_period_ms(dev, seconds * 1000);
}
mraa_result_t
mraa_pwm_period_ms(mraa_pwm_context dev, int ms)
{
- return mraa_pwm_period_us(dev, ms*1000);
+ return mraa_pwm_period_us(dev, ms * 1000);
}
mraa_result_t
mraa_pwm_period_us(mraa_pwm_context dev, int us)
{
- if (us < plat->pwm_min_period ||
- us > plat->pwm_max_period) {
+ if (us < plat->pwm_min_period || us > plat->pwm_max_period) {
syslog(LOG_ERR, "pwm: period value outside platform range");
return MRAA_ERROR_INVALID_PARAMETER;
}
- return mraa_pwm_write_period(dev, us*1000);
+ return mraa_pwm_write_period(dev, us * 1000);
}
mraa_result_t
mraa_pwm_pulsewidth(mraa_pwm_context dev, float seconds)
{
- return mraa_pwm_pulsewidth_ms(dev, seconds*1000);
+ return mraa_pwm_pulsewidth_ms(dev, seconds * 1000);
}
mraa_result_t
mraa_pwm_pulsewidth_ms(mraa_pwm_context dev, int ms)
{
- return mraa_pwm_pulsewidth_us(dev, ms*1000);
+ return mraa_pwm_pulsewidth_us(dev, ms * 1000);
}
mraa_result_t
mraa_pwm_pulsewidth_us(mraa_pwm_context dev, int us)
{
- return mraa_pwm_write_duty(dev, us*1000);
+ return mraa_pwm_write_duty(dev, us * 1000);
}
mraa_result_t
status = enable;
}
char bu[MAX_SIZE];
- snprintf(bu,MAX_SIZE, "/sys/class/pwm/pwmchip%d/pwm%d/enable", dev->chipid, dev->pin);
+ snprintf(bu, MAX_SIZE, "/sys/class/pwm/pwmchip%d/pwm%d/enable", dev->chipid, dev->pin);
int enable_f = open(bu, O_RDWR);
char out[MAX_SIZE];
int size = snprintf(out, MAX_SIZE, "%d", dev->pin);
- if (write(unexport_f, out, size*sizeof(char)) == -1) {
+ if (write(unexport_f, out, size * sizeof(char)) == -1) {
syslog(LOG_ERR, "pwm: Failed to write to unexport");
close(unexport_f);
return MRAA_ERROR_INVALID_RESOURCE;
}
mraa_result_t
-mraa_pwm_config_ms(mraa_pwm_context dev, int ms ,float ms_float)
+mraa_pwm_config_ms(mraa_pwm_context dev, int ms, float ms_float)
{
int old_dutycycle, old_period, status;
old_dutycycle = mraa_pwm_read_duty(dev);
old_period = mraa_pwm_read_period(dev);
- status = mraa_pwm_period_us(dev, ms*1000);
+ status = mraa_pwm_period_us(dev, ms * 1000);
if (status != MRAA_SUCCESS) {
mraa_pwm_write_duty(dev, old_dutycycle);
return status;
if (status != MRAA_SUCCESS) {
return status;
}
- status = mraa_pwm_pulsewidth_us(dev, ms_float*1000);
+ status = mraa_pwm_pulsewidth_us(dev, ms_float * 1000);
if (status != MRAA_SUCCESS) {
mraa_pwm_write_duty(dev, old_dutycycle);
mraa_pwm_write_period(dev, old_period);
}
mraa_result_t
-mraa_pwm_config_percent(mraa_pwm_context dev, int ms ,float percentage)
+mraa_pwm_config_percent(mraa_pwm_context dev, int ms, float percentage)
{
int old_dutycycle, old_period, status;
old_dutycycle = mraa_pwm_read_duty(dev);
old_period = mraa_pwm_read_period(dev);
- status = mraa_pwm_period_us(dev, ms*1000);
+ status = mraa_pwm_period_us(dev, ms * 1000);
if (status != MRAA_SUCCESS) {
mraa_pwm_write_duty(dev, old_dutycycle);
return status;
if (status != MRAA_SUCCESS) {
return status;
}
- status = mraa_pwm_pulsewidth_us(dev, (ms*1000)*percentage);
+ status = mraa_pwm_pulsewidth_us(dev, (ms * 1000) * percentage);
if (status != MRAA_SUCCESS) {
mraa_pwm_write_duty(dev, old_dutycycle);
mraa_pwm_write_period(dev, old_period);
*/
struct _spi {
/*@{*/
- int devfd; /**< File descriptor to SPI Device */
- uint32_t mode; /**< Spi mode see spidev.h */
- int clock; /**< clock to run transactions at */
+ int devfd; /**< File descriptor to SPI Device */
+ uint32_t mode; /**< Spi mode see spidev.h */
+ int clock; /**< clock to run transactions at */
mraa_boolean_t lsb; /**< least significant bit mode */
- unsigned int bpw; /**< Bits per word */
+ unsigned int bpw; /**< Bits per word */
/*@}*/
};
int speed = 0;
if ((ioctl(dev->devfd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) != -1) && (speed < 4000000)) {
dev->clock = speed;
- }
- else {
+ } else {
dev->clock = 4000000;
}
break;
}
- if (ioctl (dev->devfd, SPI_IOC_WR_MODE, &spi_mode) < 0) {
+ if (ioctl(dev->devfd, SPI_IOC_WR_MODE, &spi_mode) < 0) {
syslog(LOG_ERR, "spi: Failed to set spi mode");
return MRAA_ERROR_INVALID_RESOURCE;
}
mraa_spi_lsbmode(mraa_spi_context dev, mraa_boolean_t lsb)
{
uint8_t lsb_mode = (uint8_t) lsb;
- if (ioctl (dev->devfd, SPI_IOC_WR_LSB_FIRST, &lsb_mode) < 0) {
+ if (ioctl(dev->devfd, SPI_IOC_WR_LSB_FIRST, &lsb_mode) < 0) {
syslog(LOG_ERR, "spi: Failed to set bit order");
return MRAA_ERROR_INVALID_RESOURCE;
}
- if (ioctl (dev->devfd, SPI_IOC_RD_LSB_FIRST, &lsb_mode) < 0) {
+ if (ioctl(dev->devfd, SPI_IOC_RD_LSB_FIRST, &lsb_mode) < 0) {
syslog(LOG_ERR, "spi: Failed to set bit order");
return MRAA_ERROR_INVALID_RESOURCE;
}
}
uint16_t*
-mraa_spi_write_buf_word(mraa_spi_context dev, uint16_t *data, int length)
+mraa_spi_write_buf_word(mraa_spi_context dev, uint16_t* data, int length)
{
uint16_t* recv = malloc(sizeof(uint16_t) * length);
b->platform_name = PLATFORM_NAME;
b->phy_pin_count = 18;
- //b->gpio_count = 14;
+ // b->gpio_count = 14;
b->aio_count = 0;
b->adc_raw = 0;
b->adc_supported = 0;
b->pwm_max_period = 2147483;
b->pwm_min_period = 1;
- b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t)*MRAA_INTEL_DE3815_PINCOUNT);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * MRAA_INTEL_DE3815_PINCOUNT);
if (b->pins == NULL) {
goto error;
}
strncpy(b->pins[0].name, "1.8v", 8);
- b->pins[0].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[1].name, "GND", 8);
- b->pins[1].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[2].name, "HDMIcec", 8);
- b->pins[2].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[3].name, "DMICclk", 8);
- b->pins[3].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[4].name, "3.3v", 8);
- b->pins[4].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[5].name, "DMICda", 8);
- b->pins[5].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[6].name, "Key", 8);
- b->pins[6].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[7].name, "SMB-A", 8);
- b->pins[7].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[8].name, "5v", 8);
- b->pins[8].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[9].name, "SCI", 8);
- b->pins[9].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[10].name, "PWM0", 8);
- b->pins[10].capabilites = (mraa_pincapabilities_t) {1,0,1,0,0,0,0,0};
+ b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[10].pwm.pinmap = 0;
b->pins[10].pwm.parent_id = 0;
b->pins[10].pwm.mux_total = 0;
strncpy(b->pins[11].name, "PWM1", 8);
- b->pins[11].capabilites = (mraa_pincapabilities_t) {1,0,1,0,0,0,0,0};
+ b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[11].pwm.pinmap = 0;
b->pins[11].pwm.parent_id = 1;
b->pins[11].pwm.mux_total = 0;
strncpy(b->pins[12].name, "I2C0SCL", 8);
- b->pins[12].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,1,0,0};
+ b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[12].i2c.pinmap = 1;
b->pins[12].i2c.mux_total = 0;
strncpy(b->pins[13].name, "I2C0SDA", 8);
- b->pins[13].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,1,0,0};
+ b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[13].i2c.pinmap = 1;
b->pins[13].i2c.mux_total = 0;
strncpy(b->pins[14].name, "I2C1SCL", 8);
- b->pins[14].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,1,0,0};
+ b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[14].i2c.pinmap = 1;
b->pins[14].i2c.mux_total = 0;
strncpy(b->pins[15].name, "I2C1SDA", 8);
- b->pins[15].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,1,0,0};
+ b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[15].i2c.pinmap = 1;
b->pins[15].i2c.mux_total = 0;
strncpy(b->pins[16].name, "SMB_CLK", 8);
- b->pins[16].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[17].name, "SMB_SDA", 8);
- b->pins[17].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- //BUS DEFINITIONS
+ // BUS DEFINITIONS
b->i2c_bus_count = 2;
b->def_i2c_bus = 0;
b->i2c_bus[0].bus_id = 0;
static mraa_gpio_context tristate;
static mraa_intel_edison_pinmodes_t pinmodes[MRAA_INTEL_EDISON_PINCOUNT];
-static unsigned int outputen[] = {248,249,250,251,252,253,254,255,256,257,258,259,260,261,232,233,234,235,236,237};
-static mraa_gpio_context agpioOutputen[sizeof(outputen)/sizeof(outputen[0])];
+static unsigned int outputen[] = { 248, 249, 250, 251, 252, 253, 254, 255, 256, 257,
+ 258, 259, 260, 261, 232, 233, 234, 235, 236, 237 };
+static mraa_gpio_context agpioOutputen[sizeof(outputen) / sizeof(outputen[0])];
-static unsigned int pullup_map[] = {216,217,218,219,220,221,222,223,224,225,226,227,228,229,208,209,210,211,212,213};
+static unsigned int pullup_map[] = { 216, 217, 218, 219, 220, 221, 222, 223, 224, 225,
+ 226, 227, 228, 229, 208, 209, 210, 211, 212, 213 };
static int miniboard = 0;
-//MMAP
-static uint8_t *mmap_reg = NULL;
+// MMAP
+static uint8_t* mmap_reg = NULL;
static int mmap_fd = 0;
static int mmap_size;
static unsigned int mmap_count = 0;
static mraa_result_t
mraa_intel_edison_pinmode_change(int sysfs, int mode)
{
- if (mode < 0 ) {
+ if (mode < 0) {
return MRAA_SUCCESS;
}
char buffer[MAX_SIZE];
- snprintf(buffer, MAX_SIZE, SYSFS_PINMODE_PATH "%i/current_pinmux",sysfs);
+ snprintf(buffer, MAX_SIZE, SYSFS_PINMODE_PATH "%i/current_pinmux", sysfs);
int modef = open(buffer, O_WRONLY);
if (modef == -1) {
syslog(LOG_ERR, "edison: Failed to open SoC pinmode for opening");
mraa_result_t ret = MRAA_SUCCESS;
char mode_buf[MAX_MODE_SIZE];
- int length = sprintf(mode_buf, "mode%u",mode);
- if (write(modef, mode_buf, length*sizeof(char)) == -1) {
+ int length = sprintf(mode_buf, "mode%u", mode);
+ if (write(modef, mode_buf, length * sizeof(char)) == -1) {
ret = MRAA_ERROR_INVALID_RESOURCE;
}
close(modef);
mraa_gpio_write(tristate, 1);
} else {
- if(bus != 6 && bus != 1) {
+ if (bus != 6 && bus != 1) {
syslog(LOG_ERR, "edison: You can't use that bus, switching to bus 6");
bus = 6;
}
mraa_result_t
mraa_intel_edison_aio_get_fp(mraa_aio_context dev)
{
- char file_path[64]= "";
+ char file_path[64] = "";
- snprintf(file_path, 64, "/sys/bus/iio/devices/iio:device1/in_voltage%d_raw",
- dev->channel );
+ snprintf(file_path, 64, "/sys/bus/iio/devices/iio:device1/in_voltage%d_raw", dev->channel);
dev->adc_in_fp = open(file_path, O_RDONLY);
if (dev->adc_in_fp == -1) {
syslog(LOG_ERR, "edison: Failed to open Analog input raw file %s for "
- "reading!", file_path);
+ "reading!",
+ file_path);
return MRAA_ERROR_INVALID_RESOURCE;
}
mraa_intel_edison_gpio_mode_replace(mraa_gpio_context dev, gpio_mode_t mode)
{
if (dev->value_fp != -1) {
- if (close(dev->value_fp) != 0) {
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- dev->value_fp = -1;
+ if (close(dev->value_fp) != 0) {
+ return MRAA_ERROR_INVALID_RESOURCE;
+ }
+ dev->value_fp = -1;
}
mraa_gpio_context pullup_e;
}
int value = -1;
- switch(mode) {
+ switch (mode) {
case MRAA_GPIO_STRONG:
break;
case MRAA_GPIO_PULLUP:
mraa_gpio_close(pullup_e);
return MRAA_ERROR_INVALID_RESOURCE;
}
- if (mraa_gpio_write(pullup_e, value)!= MRAA_SUCCESS) {
+ if (mraa_gpio_write(pullup_e, value) != MRAA_SUCCESS) {
syslog(LOG_ERR, "edison: Error setting pullup");
mraa_gpio_close(pullup_e);
return MRAA_ERROR_INVALID_RESOURCE;
mraa_intel_edsion_mb_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode)
{
if (dev->value_fp != -1) {
- if (close(dev->value_fp) != 0) {
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- dev->value_fp = -1;
+ if (close(dev->value_fp) != 0) {
+ return MRAA_ERROR_INVALID_RESOURCE;
+ }
+ dev->value_fp = -1;
}
char filepath[MAX_SIZE];
- snprintf(filepath, MAX_SIZE,
- SYSFS_PINMODE_PATH "%d/current_pullmode", dev->pin);
+ snprintf(filepath, MAX_SIZE, SYSFS_PINMODE_PATH "%d/current_pullmode", dev->pin);
int drive = open(filepath, O_WRONLY);
if (drive == -1) {
char bu[MAX_SIZE];
int length;
- switch(mode) {
+ switch (mode) {
case MRAA_GPIO_STRONG:
close(drive);
return MRAA_SUCCESS;
close(drive);
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
- if (write(drive, bu, length*sizeof(char)) == -1) {
+ if (write(drive, bu, length * sizeof(char)) == -1) {
syslog(LOG_ERR, "edison: Failed to write to drive mode");
close(drive);
return MRAA_ERROR_INVALID_RESOURCE;
mraa_gpio_close(io1_pullup);
}
mraa_result_t ret;
- ret = mraa_intel_edison_pinmode_change(130,1); //IO0 RX
- ret = mraa_intel_edison_pinmode_change(131,1); //IO1 TX
+ ret = mraa_intel_edison_pinmode_change(130, 1); // IO0 RX
+ ret = mraa_intel_edison_pinmode_change(131, 1); // IO1 TX
return ret;
}
valoff = 0x4c;
}
- *(volatile uint32_t*) (mmap_reg + offset + valoff) =
- (uint32_t)(1 << (dev->pin % 32));
+ *(volatile uint32_t*) (mmap_reg + offset + valoff) = (uint32_t)(1 << (dev->pin % 32));
return MRAA_SUCCESS;
}
uint8_t offset = ((dev->pin / 32) * sizeof(uint32_t));
uint32_t value;
- value = *(volatile uint32_t*) (mmap_reg +0x04+ offset);
- if (value&(uint32_t)(1 << (dev->pin % 32))) {
+ value = *(volatile uint32_t*) (mmap_reg + 0x04 + offset);
+ if (value & (uint32_t)(1 << (dev->pin % 32))) {
return 1;
}
return 0;
return MRAA_ERROR_INVALID_PARAMETER;
}
- //Might need to make some elements of this thread safe.
- //For example only allow one thread to enter the following block
- //to prevent mmap'ing twice.
+ // Might need to make some elements of this thread safe.
+ // For example only allow one thread to enter the following block
+ // to prevent mmap'ing twice.
if (mmap_reg == NULL) {
if ((mmap_fd = open(MMAP_PATH, O_RDWR)) < 0) {
syslog(LOG_ERR, "edison map: unable to open resource0 file");
fstat(mmap_fd, &fd_stat);
mmap_size = fd_stat.st_size;
- mmap_reg = (uint8_t*) mmap(NULL, fd_stat.st_size,
- PROT_READ | PROT_WRITE,
- MAP_FILE | MAP_SHARED,
- mmap_fd, 0);
+ mmap_reg =
+ (uint8_t*) mmap(NULL, fd_stat.st_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, mmap_fd, 0);
if (mmap_reg == MAP_FAILED) {
syslog(LOG_ERR, "edison mmap: failed to mmap");
mmap_reg = NULL;
close(sysnode);
return MRAA_ERROR_INVALID_PARAMETER;
}
- if (write(sysnode, bu, length*sizeof(char)) == -1) {
+ if (write(sysnode, bu, length * sizeof(char)) == -1) {
close(sysnode);
return MRAA_ERROR_INVALID_RESOURCE;
}
b->pwm_max_period = 218453;
b->pwm_min_period = 1;
- b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t)*56);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * 56);
if (b->pins == NULL) {
return MRAA_ERROR_UNSPECIFIED;
}
int pos = 0;
strncpy(b->pins[pos].name, "J17-1", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 182;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 2;
pos++;
strncpy(b->pins[pos].name, "J17-2", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-3", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-4", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-5", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 135;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J17-6", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-7", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 27;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 1;
pos++;
strncpy(b->pins[pos].name, "J17-8", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 20;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 1;
pos++;
strncpy(b->pins[pos].name, "J17-9", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 28;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 1;
pos++;
strncpy(b->pins[pos].name, "J17-10", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 111;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
pos++;
strncpy(b->pins[pos].name, "J17-11", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 109;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
pos++;
strncpy(b->pins[pos].name, "J17-12", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 115;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
b->pins[pos].spi.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J17-13", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-14", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 128;
b->pins[pos].gpio.parent_id = 0;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-1", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 13;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 1;
pos++;
strncpy(b->pins[pos].name, "J18-2", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 165;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-3", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J18-4", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J18-5", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J18-6", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 19;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 1;
pos++;
strncpy(b->pins[pos].name, "J18-7", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 12;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 0;
pos++;
strncpy(b->pins[pos].name, "J18-8", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 183;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 3;
b->pins[pos].pwm.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-9", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J18-10", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 110;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
b->pins[pos].spi.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-11", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 114;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
pos++;
strncpy(b->pins[pos].name, "J18-12", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 129;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-13", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,1};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 130;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
pos++;
strncpy(b->pins[pos].name, "J18-14", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-1", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-2", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-3", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-4", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 44;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-5", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 46;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-6", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 48;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-7", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-8", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,1};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 131;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
pos++;
strncpy(b->pins[pos].name, "J19-9", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 14;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-10", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 40;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-11", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 43;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-12", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 77;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-13", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 82;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-14", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 83;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-1", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J20-2", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J20-3", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,0,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J20-4", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 45;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-5", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 47;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-6", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 49;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-7", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 15;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-8", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 84;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-9", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 42;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-10", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 41;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-11", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 78;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-12", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 79;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-13", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 80;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-14", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 81;
b->pins[pos].gpio.mux_total = 0;
pos++;
- //BUS DEFINITIONS
+ // BUS DEFINITIONS
b->i2c_bus_count = 9;
b->def_i2c_bus = 6;
int ici;
advance_func->uart_init_post = &mraa_intel_edison_uart_init_post;
advance_func->gpio_mmap_setup = &mraa_intel_edison_mmap_setup;
- b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t)*MRAA_INTEL_EDISON_PINCOUNT);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * MRAA_INTEL_EDISON_PINCOUNT);
if (b->pins == NULL) {
goto error;
}
b->pwm_min_period = 1;
strncpy(b->pins[0].name, "IO0", 8);
- b->pins[0].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,1};
+ b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[0].gpio.pinmap = 130;
b->pins[0].gpio.parent_id = 0;
b->pins[0].gpio.mux_total = 0;
b->pins[0].uart.mux_total = 0;
strncpy(b->pins[1].name, "IO1", 8);
- b->pins[1].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,1};
+ b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[1].gpio.pinmap = 131;
b->pins[1].gpio.parent_id = 0;
b->pins[1].gpio.mux_total = 0;
b->pins[1].uart.mux_total = 0;
strncpy(b->pins[2].name, "IO2", 8);
- b->pins[2].capabilites = (mraa_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 = 128;
b->pins[2].gpio.parent_id = 0;
b->pins[2].gpio.mux_total = 0;
strncpy(b->pins[3].name, "IO3", 8);
- b->pins[3].capabilites = (mraa_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 = 12;
b->pins[3].gpio.parent_id = 0;
b->pins[3].gpio.mux_total = 0;
b->pins[3].pwm.mux_total = 0;
strncpy(b->pins[4].name, "IO4", 8);
- b->pins[4].capabilites = (mraa_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 = 129;
b->pins[4].gpio.parent_id = 0;
b->pins[4].gpio.mux_total = 0;
strncpy(b->pins[5].name, "IO5", 8);
- b->pins[5].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0,0};
+ b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[5].gpio.pinmap = 13;
b->pins[5].gpio.parent_id = 0;
b->pins[5].gpio.mux_total = 0;
b->pins[5].pwm.mux_total = 0;
strncpy(b->pins[6].name, "IO6", 8);
- b->pins[6].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0,0};
+ b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].gpio.pinmap = 182;
b->pins[6].gpio.parent_id = 0;
b->pins[6].gpio.mux_total = 0;
b->pins[6].pwm.mux_total = 0;
strncpy(b->pins[7].name, "IO7", 8);
- b->pins[7].capabilites = (mraa_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 = 48;
b->pins[7].gpio.parent_id = 0;
b->pins[7].gpio.mux_total = 0;
strncpy(b->pins[8].name, "IO8", 8);
- b->pins[8].capabilites = (mraa_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 = 49;
b->pins[8].gpio.parent_id = 0;
b->pins[8].gpio.mux_total = 0;
strncpy(b->pins[9].name, "IO9", 8);
- b->pins[9].capabilites = (mraa_pincapabilities_t) {1,1,1,0,0,0,0,0};
+ b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].gpio.pinmap = 183;
b->pins[9].gpio.parent_id = 0;
b->pins[9].gpio.mux_total = 0;
b->pins[9].pwm.mux_total = 0;
strncpy(b->pins[10].name, "IO10", 8);
- b->pins[10].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[10].gpio.pinmap = 41;
b->pins[10].gpio.parent_id = 0;
b->pins[10].gpio.mux_total = 2;
b->pins[10].spi.mux[1].value = 1;
strncpy(b->pins[11].name, "IO11", 8);
- b->pins[11].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[11].gpio.pinmap = 43;
b->pins[11].gpio.parent_id = 0;
b->pins[11].gpio.mux_total = 2;
b->pins[11].spi.mux[1].value = 1;
strncpy(b->pins[12].name, "IO12", 8);
- b->pins[12].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[12].gpio.pinmap = 42;
b->pins[12].gpio.parent_id = 0;
b->pins[12].gpio.mux_total = 1;
b->pins[12].spi.mux[0].value = 1;
strncpy(b->pins[13].name, "IO13", 8);
- b->pins[13].capabilites = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].gpio.pinmap = 40;
b->pins[13].gpio.parent_id = 0;
b->pins[13].gpio.mux_total = 1;
b->pins[13].spi.mux[0].value = 1;
strncpy(b->pins[14].name, "A0", 8);
- b->pins[14].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1,0};
+ b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].aio.pinmap = 0;
b->pins[14].aio.mux_total = 1;
b->pins[14].aio.mux[0].pin = 200;
b->pins[14].gpio.mux[0].value = 0;
strncpy(b->pins[15].name, "A1", 8);
- b->pins[15].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1,0};
+ b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].aio.pinmap = 1;
b->pins[15].aio.mux_total = 1;
b->pins[15].aio.mux[0].pin = 201;
b->pins[15].gpio.mux[0].value = 0;
strncpy(b->pins[16].name, "A2", 8);
- b->pins[16].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1,0};
+ b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].aio.pinmap = 2;
b->pins[16].aio.mux_total = 1;
b->pins[16].aio.mux[0].pin = 202;
b->pins[16].gpio.mux[0].value = 0;
strncpy(b->pins[17].name, "A3", 8);
- b->pins[17].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1,0};
+ b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].aio.pinmap = 3;
b->pins[17].aio.mux_total = 1;
b->pins[17].aio.mux[0].pin = 203;
b->pins[17].gpio.mux[0].value = 0;
strncpy(b->pins[18].name, "A4", 8);
- b->pins[18].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,1,0};
+ b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].i2c.pinmap = 1;
b->pins[18].i2c.mux_total = 1;
b->pins[18].i2c.mux[0].pin = 204;
b->pins[18].gpio.mux[0].value = 0;
strncpy(b->pins[19].name, "A5", 8);
- b->pins[19].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,1,0};
+ b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].i2c.pinmap = 1;
b->pins[19].i2c.mux_total = 1;
b->pins[19].i2c.mux[0].pin = 205;
b->pins[19].gpio.mux[0].pin = 205;
b->pins[19].gpio.mux[0].value = 0;
- //BUS DEFINITIONS
+ // BUS DEFINITIONS
b->i2c_bus_count = 9;
b->def_i2c_bus = 6;
int ici;
b->uart_dev[0].device_path = UART_DEV_PATH;
int il;
- for (il =0; il < MRAA_INTEL_EDISON_PINCOUNT; il++) {
+ for (il = 0; il < MRAA_INTEL_EDISON_PINCOUNT; il++) {
pinmodes[il].gpio.sysfs = -1;
pinmodes[il].gpio.mode = -1;
pinmodes[il].pwm.sysfs = -1;
pinmodes[6].pwm.sysfs = 182;
pinmodes[6].pwm.mode = 1;
- //7 and 8 are provided by something on i2c, very simplepinmodes[3].gpio.sysfs = 12;
+ // 7 and 8 are provided by something on i2c, very simplepinmodes[3].gpio.sysfs = 12;
pinmodes[9].gpio.sysfs = 183;
pinmodes[9].gpio.mode = 0;
pinmodes[9].pwm.sysfs = 183;
pinmodes[13].gpio.mode = 0;
pinmodes[13].spi.sysfs = 109; // Different pin provides, switched at mux level.
pinmodes[13].spi.mode = 1;
- //Everything else but A4 A5 LEAVE
+ // Everything else but A4 A5 LEAVE
pinmodes[18].gpio.sysfs = 14;
pinmodes[18].gpio.mode = 0;
pinmodes[18].i2c.sysfs = 28;
#define UIO_PATH "/dev/uio0"
#define PLATFORM_NAME "Intel Galileo Gen 1"
-static uint8_t *mmap_reg = NULL;
+static uint8_t* mmap_reg = NULL;
static int mmap_fd = 0;
static int mmap_size = 0x1000;
static unsigned int mmap_count = 0;
{
int bitpos = plat->pins[dev->phy_pin].mmap.bit_pos;
if (value) {
- *((unsigned *)mmap_reg) |= (1<<bitpos);
+ *((unsigned*) mmap_reg) |= (1 << bitpos);
return MRAA_SUCCESS;
}
- *((unsigned *)mmap_reg) &= ~(1<<bitpos);
+ *((unsigned*) mmap_reg) &= ~(1 << bitpos);
return MRAA_SUCCESS;
}
syslog(LOG_ERR, "galileo1: Unable to open UIO device");
return MRAA_ERROR_INVALID_RESOURCE;
}
- mmap_reg = mmap(NULL, mmap_size, PROT_READ|PROT_WRITE,
- MAP_SHARED, mmap_fd, 0);
+ mmap_reg = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, mmap_fd, 0);
if (mmap_reg == MAP_FAILED) {
syslog(LOG_ERR, "galileo1: Mmap failed to mmap");
return MRAA_ERROR_NO_RESOURCES;
}
}
- if (mraa_setup_mux_mapped(plat->pins[dev->phy_pin].mmap.gpio)
- != MRAA_SUCCESS) {
+ if (mraa_setup_mux_mapped(plat->pins[dev->phy_pin].mmap.gpio) != MRAA_SUCCESS) {
syslog(LOG_ERR, "galileo1: Unable to setup required multiplexers for mmap");
return MRAA_ERROR_INVALID_RESOURCE;
}
advance_func->gpio_mmap_setup = &mraa_intel_galileo_g1_mmap_setup;
- b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t)*MRAA_INTEL_GALILEO_REV_D_PINCOUNT);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * MRAA_INTEL_GALILEO_REV_D_PINCOUNT);
if (b->pins == NULL) {
goto error;
}
- //GPIO IO0 - IO10
+ // GPIO IO0 - IO10
strncpy(b->pins[0].name, "IO0", 8);
- b->pins[0].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,1};
+ b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[0].gpio.pinmap = 50;
b->pins[0].gpio.parent_id = 0;
b->pins[0].gpio.mux_total = 1;
b->pins[0].uart.mux[0].value = 0;
strncpy(b->pins[1].name, "IO1", 8);
- b->pins[1].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,1};
+ b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[1].gpio.pinmap = 51;
b->pins[1].gpio.mux_total = 1;
b->pins[1].gpio.mux[0].pin = 41;
b->pins[1].uart.mux[0].value = 0;
strncpy(b->pins[2].name, "IO2", 8);
- b->pins[2].capabilites = (mraa_pincapabilities_t) {1,1,0,1,0,0,0,0};
+ b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,1,1,0,0,0,0};
+ b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,1,0,0,0,0,0};
+ b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,1,0,0,0,0,0};
+ b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,0,0,0,0,0,0};
+ b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,1,0,0,0,0,0};
+ b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,1,0,1,0,0,0};
+ b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,1,0,1,0,0,0};
+ b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,0,0,1,0,0,0};
+ b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 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 = (mraa_pincapabilities_t) {1,1,0,0,0,0,1,0};
+ b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
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 = (mraa_pincapabilities_t) {1,1,0,0,0,0,1,0};
+ b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
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 = (mraa_pincapabilities_t) {1,1,0,0,0,0,1,0};
+ b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
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 = (mraa_pincapabilities_t) {1,1,0,0,0,0,1,0};
+ b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
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 = (mraa_pincapabilities_t) {1,1,0,0,0,1,1,0};
+ b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
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 = (mraa_pincapabilities_t) {1,1,0,0,0,1,1,0};
+ b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].gpio.pinmap = 49;
b->pins[19].gpio.mux_total = 2;
b->pins[19].gpio.mux[0].pin = 29;
b->pins[19].aio.mux[1].pin = 20;
b->pins[19].aio.mux[1].value = 0;
- //BUS DEFINITIONS
+ // BUS DEFINITIONS
b->i2c_bus_count = 1;
b->def_i2c_bus = 0;
b->i2c_bus[0].bus_id = 0;
#define UIO_PATH "/dev/uio0"
-static uint8_t *mmap_reg = NULL;
+static uint8_t* mmap_reg = NULL;
static int mmap_fd = 0;
static int mmap_size = 0x1000;
static unsigned int mmap_count = 0;
-static unsigned int pullup_map[] = {33,29,35,17,37,19,21,39,41,23,27,25,43,31,49,51,53,55,57,59};
+static unsigned int pullup_map[] = { 33, 29, 35, 17, 37, 19, 21, 39, 41, 23,
+ 27, 25, 43, 31, 49, 51, 53, 55, 57, 59 };
static mraa_gpio_context agpioOutputen[MRAA_INTEL_GALILEO_GEN_2_PINCOUNT];
mraa_result_t
mraa_intel_galileo_gen2_i2c_init_pre(unsigned int bus)
{
- mraa_gpio_context io18 = mraa_gpio_init_raw(57);
+ mraa_gpio_context io18 = mraa_gpio_init_raw(57);
int status = 0;
if (io18 == NULL) {
mraa_intel_galileo_gen2_pwm_period_replace(mraa_pwm_context dev, int period)
{
char bu[MAX_SIZE];
- snprintf(bu,MAX_SIZE ,"/sys/class/pwm/pwmchip%d/device/pwm_period", dev->chipid);
+ snprintf(bu, MAX_SIZE, "/sys/class/pwm/pwmchip%d/device/pwm_period", dev->chipid);
int period_f = open(bu, O_RDWR);
if (period_f == -1) {
}
char out[MAX_SIZE];
int length = snprintf(out, MAX_SIZE, "%d", period);
- if (write(period_f, out, length*sizeof(char)) == -1) {
+ if (write(period_f, out, length * sizeof(char)) == -1) {
close(period_f);
return MRAA_ERROR_INVALID_RESOURCE;
}
mraa_intel_galileo_gen2_gpio_mode_replace(mraa_gpio_context dev, gpio_mode_t mode)
{
if (dev->value_fp != -1) {
- close(dev->value_fp);
- dev->value_fp = -1;
+ close(dev->value_fp);
+ dev->value_fp = -1;
}
mraa_gpio_context pullup_e;
char bu[MAX_SIZE];
int length;
int value = -1;
- switch(mode) {
+ switch (mode) {
case MRAA_GPIO_STRONG:
length = snprintf(bu, sizeof(bu), "hiz");
break;
close(drive);
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
- if (write(drive, bu, length*sizeof(char)) == -1) {
+ if (write(drive, bu, length * sizeof(char)) == -1) {
syslog(LOG_ERR, "galileo2: Failed to write to drive mode");
close(drive);
mraa_gpio_close(pullup_e);
{
int bitpos = plat->pins[dev->phy_pin].mmap.bit_pos;
if (value) {
- *((unsigned *)mmap_reg) |= (1<<bitpos);
+ *((unsigned*) mmap_reg) |= (1 << bitpos);
return MRAA_SUCCESS;
}
- *((unsigned *)mmap_reg) &= ~(1<<bitpos);
+ *((unsigned*) mmap_reg) &= ~(1 << bitpos);
return MRAA_SUCCESS;
}
syslog(LOG_ERR, "mmap: Unable to open UIO device");
return MRAA_ERROR_INVALID_RESOURCE;
}
- mmap_reg = mmap(NULL, mmap_size, PROT_READ|PROT_WRITE,
- MAP_SHARED, mmap_fd, 0);
+ mmap_reg = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, mmap_fd, 0);
if (mmap_reg == MAP_FAILED) {
syslog(LOG_ERR, "mmap: failed to mmap");
return MRAA_ERROR_NO_RESOURCES;
}
}
- if (mraa_setup_mux_mapped(plat->pins[dev->phy_pin].mmap.gpio)
- != MRAA_SUCCESS) {
+ if (mraa_setup_mux_mapped(plat->pins[dev->phy_pin].mmap.gpio) != MRAA_SUCCESS) {
syslog(LOG_ERR, "mmap: unable to setup required multiplexers");
return MRAA_ERROR_INVALID_RESOURCE;
}
advance_func->uart_init_pre = &mraa_intel_galileo_gen2_uart_init_pre;
advance_func->gpio_mmap_setup = &mraa_intel_galileo_g2_mmap_setup;
- b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t)*MRAA_INTEL_GALILEO_GEN_2_PINCOUNT);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * MRAA_INTEL_GALILEO_GEN_2_PINCOUNT);
if (b->pins == NULL) {
goto error;
}
strncpy(b->pins[0].name, "IO0", 8);
- b->pins[0].capabilites = (mraa_pincapabilities_t) {1,1,0,1,0,0,0,1};
+ b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 1 };
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 = (mraa_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;
b->pins[0].mmap.gpio.pinmap = 11;
b->pins[0].uart.mux_total = 0;
strncpy(b->pins[1].name, "IO1", 8);
- b->pins[1].capabilites = (mraa_pincapabilities_t) {1,1,0,1,0,0,0,1};
+ b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 1 };
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 = (mraa_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;
b->pins[1].mmap.gpio.pinmap = 12;
b->pins[1].uart.mux[0].value = 1;
strncpy(b->pins[2].name, "IO2", 8);
- b->pins[2].capabilites = (mraa_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 = 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 = (mraa_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;
b->pins[2].mmap.gpio.pinmap = 13;
b->pins[2].mmap.bit_pos = 5;
strncpy(b->pins[3].name, "IO3", 8);
- b->pins[3].capabilites = (mraa_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 = 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 = (mraa_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;
b->pins[3].mmap.bit_pos = 6;
strncpy(b->pins[4].name, "IO4", 8);
- b->pins[4].capabilites = (mraa_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 = (mraa_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 = (mraa_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 = (mraa_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 = 3;
b->pins[5].pwm.mux[1].value = 0;
strncpy(b->pins[6].name, "IO6", 8);
- b->pins[6].capabilites = (mraa_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 = (mraa_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 = (mraa_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 = (mraa_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 = (mraa_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 = (mraa_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 = (mraa_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 = (mraa_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 = (mraa_pincapabilities_t) {1,1,1,1,1,0,0};
+ b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 1, 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 = (mraa_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].spi.mux[0].value = 0;
strncpy(b->pins[11].name, "IO11", 8);
- b->pins[11].capabilites = (mraa_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 = (mraa_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].spi.mux[2].value = 0;
strncpy(b->pins[12].name, "IO12", 8);
- b->pins[12].capabilites = (mraa_pincapabilities_t) {1,1,0,1,1,0,0};
+ b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 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 = (mraa_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;
b->pins[12].mmap.bit_pos = 7;
strncpy(b->pins[13].name, "IO13", 8);
- b->pins[13].capabilites = (mraa_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 = (mraa_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;
b->pins[13].spi.mux[1].pin = 30;
b->pins[13].spi.mux[1].value = 0;
- //ANALOG
+ // ANALOG
strncpy(b->pins[14].name, "A0", 8);
- b->pins[14].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1};
- b->pins[14].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 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 = 1;
b->pins[14].gpio.mux_total = 0;
strncpy(b->pins[15].name, "A1", 8);
- b->pins[15].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1};
- b->pins[15].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 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[0].pin = 51;
b->pins[15].gpio.mux_total = 0;
strncpy(b->pins[16].name, "A2", 8);
- b->pins[16].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1};
- b->pins[16].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 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 = 1;
b->pins[16].gpio.mux_total = 0;
strncpy(b->pins[17].name, "A3", 8);
- b->pins[17].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,0,1};
- b->pins[17].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 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 = 1;
b->pins[17].gpio.mux_total = 0;
strncpy(b->pins[18].name, "A4", 8);
- b->pins[18].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,1};
- b->pins[18].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 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].gpio.mux[1].value = 1;
strncpy(b->pins[19].name, "A5", 8);
- b->pins[19].capabilites = (mraa_pincapabilities_t) {1,1,0,0,0,1,1};
- b->pins[19].gpio.complex_cap = (mraa_pin_cap_complex_t) {1,0,0,1,1};
+ b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 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;
b->pins[19].gpio.mux[1].pin = 79;
b->pins[19].gpio.mux[1].value = 1;
- //BUS DEFINITIONS
+ // BUS DEFINITIONS
b->i2c_bus_count = 1;
b->def_i2c_bus = 0;
b->i2c_bus[0].bus_id = 0;
int arch_nr_gpios_adjust = 0x100;
mraa_result_t
-mraa_set_pininfo(mraa_board_t* board, int mraa_index, char *name, mraa_pincapabilities_t caps, int sysfs_pin)
+mraa_set_pininfo(mraa_board_t* board, int mraa_index, char* name, mraa_pincapabilities_t caps, int sysfs_pin)
{
if (mraa_index < board->phy_pin_count) {
// adjust mraa_index for ARCH_NR_GPIOS value
}
mraa_result_t
-mraa_get_pin_index(mraa_board_t* board, char *name, int* pin_index) {
+mraa_get_pin_index(mraa_board_t* board, char* name, int* pin_index)
+{
int i;
for (i = 0; i < board->phy_pin_count; ++i) {
if (strcmp(name, board->pins[i].name) == 0) {
b->adc_raw = 0;
b->adc_supported = 0;
- b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t)*MRAA_INTEL_MINNOW_MAX_PINCOUNT);
+ b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * MRAA_INTEL_MINNOW_MAX_PINCOUNT);
if (b->pins == NULL) {
goto error;
}
* they start at 512 and number down, at some point this is going to change again when
* GPIO moves to a radix.
*/
- if (uname_major <= 3 && uname_minor <= 17 ) {
+ if (uname_major <= 3 && uname_minor <= 17) {
arch_nr_gpios_adjust = 0;
}
- mraa_set_pininfo(b, 0, "INVALID", (mraa_pincapabilities_t){0,0,0,0,0,0,0,0}, -1 );
- mraa_set_pininfo(b, 1, "GND", (mraa_pincapabilities_t){0,0,0,0,0,0,0,0}, -1 );
- mraa_set_pininfo(b, 2, "GND", (mraa_pincapabilities_t){0,0,0,0,0,0,0,0}, -1 );
- mraa_set_pininfo(b, 3, "5v", (mraa_pincapabilities_t){0,0,0,0,0,0,0,0}, -1 );
- mraa_set_pininfo(b, 4, "3.3v", (mraa_pincapabilities_t){1,0,0,0,0,0,0,0}, -1 );
- mraa_set_pininfo(b, 5, "SPI_CS", (mraa_pincapabilities_t){1,0,0,0,1,0,0,0}, 220);
- mraa_set_pininfo(b, 6, "UART1TX", (mraa_pincapabilities_t){1,0,0,0,0,0,0,1}, 225);
- mraa_set_pininfo(b, 7, "SPIMISO", (mraa_pincapabilities_t){1,0,0,0,1,0,0,0}, 221);
- mraa_set_pininfo(b, 8, "UART1RX", (mraa_pincapabilities_t){1,0,0,0,0,0,0,1}, 224);
- mraa_set_pininfo(b, 9, "SPIMOSI", (mraa_pincapabilities_t){1,0,0,0,1,0,0,0}, 222);
- mraa_set_pininfo(b, 10, "UART1CT", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 227);
- mraa_set_pininfo(b, 11, "SPI_CLK", (mraa_pincapabilities_t){1,0,0,0,0,0,0,1}, 223);
- mraa_set_pininfo(b, 12, "UART1RT", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 226);
- mraa_set_pininfo(b, 13, "I2C_SCL", (mraa_pincapabilities_t){1,0,0,0,0,1,0,0}, 243);
- mraa_set_pininfo(b, 14, "I2S_CLK", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 216);
- mraa_set_pininfo(b, 15, "I2C_SDA", (mraa_pincapabilities_t){1,0,0,0,0,1,0,0}, 242);
- mraa_set_pininfo(b, 16, "I2S_FRM", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 217);
- mraa_set_pininfo(b, 17, "UART2TX", (mraa_pincapabilities_t){1,0,0,0,0,0,0,1}, 229);
- mraa_set_pininfo(b, 18, "I2S_DO", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 219);
- mraa_set_pininfo(b, 19, "UART2RX", (mraa_pincapabilities_t){1,0,0,0,0,0,0,1}, 228);
- mraa_set_pininfo(b, 20, "I2S_DI", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 218);
- mraa_set_pininfo(b, 21, "S5_0", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 82 );
- mraa_set_pininfo(b, 22, "PWM0", (mraa_pincapabilities_t){1,0,1,0,0,0,0,0}, 248); // Assume BIOS configured for PWM
- mraa_set_pininfo(b, 23, "S5_1", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 83 );
- mraa_set_pininfo(b, 24, "PWM1", (mraa_pincapabilities_t){1,0,1,0,0,0,0,0}, 249); // Assume BIOS configured for PWM
- mraa_set_pininfo(b, 25, "S5_4", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 84 );
- mraa_set_pininfo(b, 26, "IBL8254", (mraa_pincapabilities_t){1,1,0,0,0,0,0,0}, 208);
+ mraa_set_pininfo(b, 0, "INVALID", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1);
+ mraa_set_pininfo(b, 1, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1);
+ mraa_set_pininfo(b, 2, "GND", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1);
+ mraa_set_pininfo(b, 3, "5v", (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 }, -1);
+ mraa_set_pininfo(b, 4, "3.3v", (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 }, -1);
+ mraa_set_pininfo(b, 5, "SPI_CS", (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 }, 220);
+ mraa_set_pininfo(b, 6, "UART1TX", (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 }, 225);
+ mraa_set_pininfo(b, 7, "SPIMISO", (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 }, 221);
+ mraa_set_pininfo(b, 8, "UART1RX", (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 }, 224);
+ mraa_set_pininfo(b, 9, "SPIMOSI", (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 }, 222);
+ mraa_set_pininfo(b, 10, "UART1CT", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 227);
+ mraa_set_pininfo(b, 11, "SPI_CLK", (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 }, 223);
+ mraa_set_pininfo(b, 12, "UART1RT", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 226);
+ mraa_set_pininfo(b, 13, "I2C_SCL", (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 }, 243);
+ mraa_set_pininfo(b, 14, "I2S_CLK", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 216);
+ mraa_set_pininfo(b, 15, "I2C_SDA", (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 }, 242);
+ mraa_set_pininfo(b, 16, "I2S_FRM", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 217);
+ mraa_set_pininfo(b, 17, "UART2TX", (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 }, 229);
+ mraa_set_pininfo(b, 18, "I2S_DO", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 219);
+ mraa_set_pininfo(b, 19, "UART2RX", (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 }, 228);
+ mraa_set_pininfo(b, 20, "I2S_DI", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 218);
+ mraa_set_pininfo(b, 21, "S5_0", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 82);
+ mraa_set_pininfo(b, 22, "PWM0", (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 },
+ 248); // Assume BIOS configured for PWM
+ mraa_set_pininfo(b, 23, "S5_1", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 83);
+ mraa_set_pininfo(b, 24, "PWM1", (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 },
+ 249); // Assume BIOS configured for PWM
+ mraa_set_pininfo(b, 25, "S5_4", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 84);
+ mraa_set_pininfo(b, 26, "IBL8254", (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }, 208);
// Set number of i2c adaptors
// Got this from running 'i2cdetect -l'
mraa_x86_platform()
{
mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
- char *line = NULL;
+ char* line = NULL;
// let getline allocate memory for *line
size_t len = 0;
- FILE *fh = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
+ FILE* fh = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
if (fh != NULL) {
if (getline(&line, &len, fh) != -1) {
if (strncmp(line, "GalileoGen2", 11) == 0) {