sbgECom Library  4.0.1987-stable
C library to interface SBG Systems IMU/AHRS/INS
sbgDefines.h File Reference

Header file that contains all common definitions. More...

#include <assert.h>
#include <errno.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "sbgConfig.h"

Go to the source code of this file.

Macros

#define SBG_COMMON_LIB_API
 
#define SBG_CONST_CAST_AA(x)   x
 
#define __BASE_FILE__   __FILE__
 
#define SBG_INLINE   static inline
 
#define SBG_UNUSED_PARAMETER(x)   (void)(x)
 
#define SBG_FALLTHROUGH
 
#define SBG_DEPRECATED(func)   func
 
#define SBG_DEPRECATED_MACRO(func)   func
 
#define SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES   (1)
 
#define SBG_DEPRECATED_TYPEDEF(decl)   decl
 
#define sbgAbs(x)   (((x) < 0) ? -(x) : (x))
 
#define sbgMax(a, b)   (((a) > (b)) ? (a) : (b))
 
#define sbgMin(a, b)   (((a) < (b)) ? (a) : (b))
 
#define sbgClamp(value, minValue, maxValue)   (((value) < (minValue))?(minValue): ((value) > (maxValue)?maxValue:value))
 
#define sbgDivCeil(n, d)   (((n) + (d) - 1) / (d))
 

Functions

SBG_INLINE double sbgRadToDegd (double angle)
 
SBG_INLINE double sbgDegToRadd (double angle)
 
SBG_INLINE float sbgRadToDegf (float angle)
 
SBG_INLINE float sbgDegToRadf (float angle)
 
SBG_INLINE bool sbgAlmostEqualsFloat (float leftValue, float rightValue)
 
SBG_INLINE bool sbgAlmostEqualsDouble (double leftValue, double rightValue)
 

Detailed Description

Header file that contains all common definitions.

Author
SBG Systems
Date
17 March 2015
License

The MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Macro Definition Documentation

◆ SBG_COMMON_LIB_API

#define SBG_COMMON_LIB_API

Macro used to handle export and import methods of the sbgCommon library

◆ SBG_CONST_CAST_AA

#define SBG_CONST_CAST_AA (   x)    x

GCC typeof C extension

XXX Visual C (not C++) doesn't provide anything to implement typeof(). As a result, this macro is private and shouldn't be relied on.

◆ __BASE_FILE__

#define __BASE_FILE__   __FILE__

BASE_FILE is gcc specific

◆ SBG_INLINE

#define SBG_INLINE   static inline

Macro used to abstract the compiler specific inline keyword.

◆ SBG_UNUSED_PARAMETER

#define SBG_UNUSED_PARAMETER (   x)    (void)(x)

Macro used to avoid compiler warning when a variable is not used.

◆ SBG_FALLTHROUGH

#define SBG_FALLTHROUGH

Compiler independent switch/case fallthrough attribute

The fallthrough attribute is used to avoid compiler warning in swith case statements when an intentional break is missing

◆ SBG_DEPRECATED

#define SBG_DEPRECATED (   func )    func

Compiler independent struct members packing attribute

This macro is used to define a new section of packed structures. All structures defined after this macro will be packed.

Compiler independent struct members packing attribute

This macro is used to specify that a structure is packed.

Compiler independent struct members packing attribute

This macro is used to close the section of packed structures and return to the default packing.

Macro used to indicate that a function is deprecated.

◆ SBG_DEPRECATED_MACRO

#define SBG_DEPRECATED_MACRO (   func)    func

Macro used to indicate that a macro is deprecated.

◆ SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES

#define SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES   (1)

Set the default value of SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES.

◆ SBG_DEPRECATED_TYPEDEF

#define SBG_DEPRECATED_TYPEDEF (   decl)    decl

Macro used to indicate that a type definition is deprecated.

XXX In order to avoid excessive noise caused by deprecation warnings, the attribute may currently be disabled by defining SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES to 0.

◆ sbgAbs

#define sbgAbs (   x)    (((x) < 0) ? -(x) : (x))

Returns the absolute value of x.

Parameters
[in]xSigned integer value.
Returns
The absolute value of x.

◆ sbgMax

#define sbgMax (   a,
 
)    (((a) > (b)) ? (a) : (b))

Returns the maximum between a and b

Parameters
[in]aFirst operand.
[in]bSecond operand.
Returns
The maximum between a and b.

◆ sbgMin

#define sbgMin (   a,
 
)    (((a) < (b)) ? (a) : (b))

Returns the minimum between a and b

Parameters
[in]aFirst operand.
[in]bSecond operand.
Returns
The minimum between a and b.

◆ sbgClamp

#define sbgClamp (   value,
  minValue,
  maxValue 
)    (((value) < (minValue))?(minValue): ((value) > (maxValue)?maxValue:value))

Clamp a value between minValue and maxValue ie minValue <= value <= maxValue

Parameters
[in]valueFirst operand.
[in]minValueFirst operand.
[in]maxValueSecond operand.
Returns
The clamped value.

◆ sbgDivCeil

#define sbgDivCeil (   n,
 
)    (((n) + (d) - 1) / (d))

Integer division with a result rounded up.

Parameters
[in]nDividend.
[in]dDivisor.
Returns
Rounded division

Function Documentation

◆ sbgRadToDegd()

SBG_INLINE double sbgRadToDegd ( double  angle)

Convert an angle from radians to degrees using double precision.

Parameters
[in]angleThe angle to convert in radians.
Returns
The converted angle in degrees.

◆ sbgDegToRadd()

SBG_INLINE double sbgDegToRadd ( double  angle)

Convert an angle from degrees to radians using double precision.

Parameters
[in]angleThe angle to convert in degrees.
Returns
The converted angle in radians.

◆ sbgRadToDegf()

SBG_INLINE float sbgRadToDegf ( float  angle)

Convert an angle from radians to degrees using single (float) precision.

Parameters
[in]angleThe angle to convert in radians.
Returns
The converted angle in degrees.

◆ sbgDegToRadf()

SBG_INLINE float sbgDegToRadf ( float  angle)

Convert an angle from degrees to radians using single (float) precision.

Parameters
[in]angleThe angle to convert in degrees.
Returns
The converted angle in radians.

◆ sbgAlmostEqualsFloat()

SBG_INLINE bool sbgAlmostEqualsFloat ( float  leftValue,
float  rightValue 
)

Test if two floating single-point numbers are equals or not.

Parameters
[in]leftValueThe first operand to test for equality.
[in]rightValueThe second operand to test for equality.
Returns
true if both left and right operands are almost equal.

◆ sbgAlmostEqualsDouble()

SBG_INLINE bool sbgAlmostEqualsDouble ( double  leftValue,
double  rightValue 
)

Test if two floating double-point numbers are equals or not using the epsilon technique

Parameters
[in]leftValueThe first operand to test for equality.
[in]rightValueThe second operand to test for equality.
Returns
true if both left and right operands are almost equal.