Permalink
Browse files

clang-format: run clang-format on C/C++ code

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
  • Loading branch information...
arfoll committed Mar 23, 2015
1 parent 2174ee1 commit ffcf3d7d07dd46f7027e28778a9a760f6ff88264
View
@@ -0,0 +1,50 @@
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
View
@@ -27,7 +27,8 @@
#include <stdexcept>
#include "aio.h"
namespace mraa {
namespace mraa
{
/**
* @brief API to Analog IO
@@ -36,63 +37,73 @@ namespace mraa {
*
* @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;
};
}
View
@@ -30,7 +30,8 @@
/**
* @namespace mraa namespace
*/
namespace mraa {
namespace mraa
{
/**
* @file
@@ -50,7 +51,8 @@ namespace mraa {
*
* @return Result of operation
*/
inline mraa_result_t init()
inline mraa_result_t
init()
{
return mraa_init();
}
@@ -60,7 +62,8 @@ inline mraa_result_t 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;
@@ -75,7 +78,8 @@ inline std::string getVersion()
* @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);
}
@@ -85,7 +89,8 @@ inline int setPriority(const unsigned int priority)
*
* @return mraa_platform_t Platform type enum
*/
inline mraa_platform_t getPlatformType()
inline mraa_platform_t
getPlatformType()
{
return mraa_get_platform_type();
}
@@ -95,7 +100,8 @@ inline mraa_platform_t getPlatformType()
*
* @param result the result to print
*/
inline void printError(mraa_result_t result)
inline void
printError(mraa_result_t result)
{
mraa_result_print(result);
}
@@ -107,17 +113,19 @@ inline void printError(mraa_result_t 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);
}
/**
* Check the board's bit size when reading the value
*
* @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();
}
@@ -127,7 +135,8 @@ inline unsigned int adcRawBits()
*
* @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();
}
@@ -137,7 +146,8 @@ inline unsigned int adcSupportedBits()
*
* @return platform name
*/
inline std::string getPlatformName()
inline std::string
getPlatformName()
{
std::string ret_val(mraa_get_platform_name());
return ret_val;
@@ -148,7 +158,8 @@ inline std::string getPlatformName()
*
* @return uint of physical pins.
*/
inline unsigned int getPinCount()
inline unsigned int
getPinCount()
{
return mraa_get_pin_count();
}
@@ -160,7 +171,8 @@ inline unsigned int getPinCount()
*
* @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;
@@ -173,9 +185,9 @@ inline std::string getPinName(int pin)
* @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);
}
}
View
@@ -59,30 +59,30 @@ typedef struct _gpio* mraa_gpio_context;
* Gpio Output modes
*/
typedef enum {
MRAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
MRAA_GPIO_PULLUP = 1, /**< Resistive High */
MRAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
MRAA_GPIO_HIZ = 3 /**< High Z State */
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;
/**
@@ -120,7 +120,7 @@ mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode);
* @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
Oops, something went wrong.

0 comments on commit ffcf3d7

Please sign in to comment.