COMMON - Common Utilities

Description

General purpose utilities and cross-compiler support.

This SDK supports the following compilers/IDEs:

  • Simplicity Studio
  • IAR Embedded Workbench
  • Keil µVision 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 a separate module RAMFUNC - RAM Function Support . 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.
uint32_t SL_RBIT16 (uint32_t value)
Reverse the bits.
uint32_t SL_Log2ToDiv (uint32_t log2)
Convert logarithm of 2 to division factor.

Macros

#define SL_CEILING (n, i)   ((((n) + (i) - 1U) / (i)) * (i))
Round n up to closest interval of i.
#define SL_FLOOR (n, i)   ((n / i) * i)
Round n down to closest interval of i.
#define STRINGIZE (X)   #X
Stringify X.
#define SL_MIN (a, b)   __extension__({ __typeof__(a)_a = (a); __typeof__(b)_b = (b); _a < _b ? _a : _b; })
A macro for getting the minimum value.
#define SL_MAX (a, b)   __extension__({ __typeof__(a)_a = (a); __typeof__(b)_b = (b); _a > _b ? _a : _b; })
A macro for getting the maximum value.
#define SL_ATTRIBUTE_PACKED __attribute__ ((packed))