COMMON - Common Utilities#

General purpose utilities and cross-compiler support.

This SDK supports the following compilers/IDEs:

  • Simplicity Studio

  • IAR Embedded Workbench

  • Keil uVision IDE

  • Plain armgcc

Certain compiler features such as alignment is implemented differently in the tools. Therefore, macros such as SL_ALIGN are provided to enable compiler independent code.

Note

  • RAM code macros are implemented in RAMFUNC. Cross-compiler RAM code support needs extended documentation and it is therefore implemented as a separate module.

Functions#

uint32_t
SL_CTZ(uint32_t value)

Count trailing number of zeros.

uint32_t
SL_RBIT(uint32_t value)

Reverse the bits.

uint16_t
SL_RBIT16(uint16_t value)

Reverse the bits.

uint8_t
SL_RBIT8(uint8_t value)

Reverse the bits.

uint32_t
SL_Log2ToDiv(uint32_t log2)

Convert logarithm of 2 to division factor.

Macros#

#define
_CONCAT_2 (first, second)

Macros to concatenate.

#define
SL_CONCAT_PASTER_2 (first, second)

sl concat paster 2.

#define
_CONCAT_3 (first, second, third)
#define
SL_CONCAT_PASTER_3 (first, second, third)

sl concat paster 3.

#define
_CONCAT_4 (first, second, third, fourth)
#define
SL_CONCAT_PASTER_4 (first, second, third, fourth)

sl concat paster 4.

#define
SL_CEILING (n, i)

Round n up to closest interval of i.

#define
SL_FLOOR (n, i)

Round n down to closest interval of i.

#define

Stringify X.

#define

Macros for giving the compiler hints about the likelihood of a branch.

#define
SL_MIN (a, b)

A macro for getting the minimum value.

#define
SL_MAX (a, b)

A macro for getting the maximum value.

#define
SL_ATTRIBUTE_PACKED __attribute__ ((packed))

A GCC style macro for handling packed structures.

#define

A macro for handling packed structures.

#define

A macro for handling packed structures.

#define

GCC style macro for aligning a variable.

#define

A macro for aligning a variable.

#define
SL_WEAK __attribute__ ((weak))

A macro for defining a weak symbol.

#define
SL_NORETURN __attribute__ ((noreturn))

A macro for handling non-returning functions.

#define

A macro for placing a variable in a section.

#define

A macro for notifying the compiler of an intended switch case fallthrough.

#define

A macro for notifying the compiler to ignore type limit check.

#define

A MACRO to notify the compiler, limit END.

Function Documentation#

SL_CTZ#

uint32_t SL_CTZ (uint32_t value)

Count trailing number of zeros.

Parameters
[in]value

Data value to check for number of trailing zero bits.

Use CLZ instruction if available.

Returns

  • A number of trailing zeros in value.


Definition at line 298 of file platform/common/inc/sl_common.h

SL_RBIT#

uint32_t SL_RBIT (uint32_t value)

Reverse the bits.

Parameters
[in]value

Data value to reverse.

Use the RBIT instruction if available, else process.

Returns

  • A reversed value.


Definition at line 330 of file platform/common/inc/sl_common.h

SL_RBIT16#

uint16_t SL_RBIT16 (uint16_t value)

Reverse the bits.

Parameters
[in]value

16-bit data value to reverse.

Use the RBIT instruction if available, else process.

Returns

  • A 16-bit reversed value.


Definition at line 360 of file platform/common/inc/sl_common.h

SL_RBIT8#

uint8_t SL_RBIT8 (uint8_t value)

Reverse the bits.

Parameters
[in]value

8-bit data value to reverse.

Use the RBIT instruction if available, else process.

Returns

  • A 8-bit reversed value.


Definition at line 375 of file platform/common/inc/sl_common.h

SL_Log2ToDiv#

uint32_t SL_Log2ToDiv (uint32_t log2)

Convert logarithm of 2 to division factor.

Parameters
[in]log2

Logarithm of 2.

Returns

  • Dividend.


Definition at line 390 of file platform/common/inc/sl_common.h

Macro Definition Documentation#

_CONCAT_2#

#define _CONCAT_2
Value:
(first, second)

Macros to concatenate.


Definition at line 76 of file platform/common/inc/sl_common.h

SL_CONCAT_PASTER_2#

#define SL_CONCAT_PASTER_2
Value:
(first, second)

sl concat paster 2.


Definition at line 77 of file platform/common/inc/sl_common.h

_CONCAT_3#

#define _CONCAT_3
Value:
(first, second, third)

Definition at line 78 of file platform/common/inc/sl_common.h

SL_CONCAT_PASTER_3#

#define SL_CONCAT_PASTER_3
Value:
(first, second, third)

sl concat paster 3.


Definition at line 79 of file platform/common/inc/sl_common.h

_CONCAT_4#

#define _CONCAT_4
Value:
(first, second, third, fourth)

Definition at line 80 of file platform/common/inc/sl_common.h

SL_CONCAT_PASTER_4#

#define SL_CONCAT_PASTER_4
Value:
(first, second, third, fourth)

sl concat paster 4.


Definition at line 81 of file platform/common/inc/sl_common.h

SL_CEILING#

#define SL_CEILING
Value:
(n, i)

Round n up to closest interval of i.


Definition at line 84 of file platform/common/inc/sl_common.h

SL_FLOOR#

#define SL_FLOOR
Value:
(n, i)

Round n down to closest interval of i.


Definition at line 87 of file platform/common/inc/sl_common.h

STRINGIZE#

#define STRINGIZE
Value:
(X)

Stringify X.


Definition at line 90 of file platform/common/inc/sl_common.h

SL_BRANCH_LIKELY#

#define SL_BRANCH_LIKELY
Value:
(x)

Macros for giving the compiler hints about the likelihood of a branch.


Definition at line 162 of file platform/common/inc/sl_common.h

SL_BRANCH_UNLIKELY#

#define SL_BRANCH_UNLIKELY
Value:
(x)

Definition at line 163 of file platform/common/inc/sl_common.h

SL_MIN#

#define SL_MIN
Value:
(a, b)

A macro for getting the minimum value.

No side-effects, a and b are evaluated one time only.


Definition at line 166 of file platform/common/inc/sl_common.h

SL_MAX#

#define SL_MAX
Value:
(a, b)

A macro for getting the maximum value.

No side-effects, a and b are evaluated one time only.


Definition at line 169 of file platform/common/inc/sl_common.h

SL_ATTRIBUTE_PACKED#

#define SL_ATTRIBUTE_PACKED
Value:
__attribute__ ((packed))

A GCC style macro for handling packed structures.


Definition at line 172 of file platform/common/inc/sl_common.h

SL_PACK_START#

#define SL_PACK_START

A macro for handling packed structures.


Use this macro before the structure definition.
X denotes the maximum alignment of structure members. X is not supported with GCC. GCC always uses 1 byte maximum alignment.


Definition at line 179 of file platform/common/inc/sl_common.h

SL_PACK_END#

#define SL_PACK_END

A macro for handling packed structures.


Use this macro after the structure definition.
With GCC, add SL_ATTRIBUTE_PACKED after the closing curly braces of the structure definition.


Definition at line 186 of file platform/common/inc/sl_common.h

SL_ATTRIBUTE_ALIGN#

#define SL_ATTRIBUTE_ALIGN
Value:
(X)

GCC style macro for aligning a variable.


Definition at line 189 of file platform/common/inc/sl_common.h

SL_ALIGN#

#define SL_ALIGN

A macro for aligning a variable.


Use this macro before the variable definition.
X denotes the storage alignment value in bytes.
To be GCC-compatible, use SL_ATTRIBUTE_ALIGN(X) before the semicolon on normal variables. Use SL_ATTRIBUTE_ALIGN(X) before the opening curly brace on structure variables.


Definition at line 197 of file platform/common/inc/sl_common.h

SL_WEAK#

#define SL_WEAK
Value:
__attribute__ ((weak))

A macro for defining a weak symbol.


Definition at line 200 of file platform/common/inc/sl_common.h

SL_NORETURN#

#define SL_NORETURN
Value:
__attribute__ ((noreturn))

A macro for handling non-returning functions.


Definition at line 203 of file platform/common/inc/sl_common.h

SL_ATTRIBUTE_SECTION#

#define SL_ATTRIBUTE_SECTION
Value:
(X)

A macro for placing a variable in a section.


Use this macro after the variable definition, before the equal sign or a semicolon.
X denotes the section to place the variable in.


Definition at line 209 of file platform/common/inc/sl_common.h

SL_FALLTHROUGH#

#define SL_FALLTHROUGH

A macro for notifying the compiler of an intended switch case fallthrough.


Definition at line 216 of file platform/common/inc/sl_common.h

SL_IGNORE_TYPE_LIMIT_BEGIN#

#define SL_IGNORE_TYPE_LIMIT_BEGIN

A macro for notifying the compiler to ignore type limit check.


Definition at line 227 of file platform/common/inc/sl_common.h

SL_IGNORE_TYPE_LIMIT_END#

#define SL_IGNORE_TYPE_LIMIT_END

A MACRO to notify the compiler, limit END.


Definition at line 228 of file platform/common/inc/sl_common.h