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
SL_CONCAT_PASTER_2 (first, second)

Macros to concatenate.

#define
SL_CONCAT_PASTER_3 (first, second, third)

sl concat paster 3.

#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
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 281 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 313 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 343 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 358 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 373 of file platform/common/inc/sl_common.h

Macro Definition Documentation#

SL_CONCAT_PASTER_2#

#define SL_CONCAT_PASTER_2
Value:
(first, second)

Macros to concatenate.

sl concat paster 2.


Definition at line 76 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 77 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 78 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 81 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 84 of file platform/common/inc/sl_common.h

STRINGIZE#

#define STRINGIZE
Value:
(X)

Stringify X.


Definition at line 87 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 155 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 158 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 161 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 168 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 175 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 178 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 186 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 189 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 192 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 198 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 205 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 216 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 217 of file platform/common/inc/sl_common.h