Wirepas SDK
util.h File Reference

Detailed Description

Comparison functions

Comparison functions include comparison for 8, 16, and 32-bit integers (Util_cmpUint8, Util_cmpUint16, Util_cmpUint32). The functions compare two values, and return the comparison result in UTIL_CMP_XXX value. For convenience, the following macros have been defined:

  • Util_isLtUint{8,16,32}(a,b)
  • Util_isGtUint{8,16,32}(a,b)
  • Util_isEqUint{8,16,32}(a,b)
  • Util_isLtOrEqUint{8,16,32}(a,b)
  • Util_isGtOrEqUint{8,16,32}(a,b)

For example:

if (Util_isLtUint8(1, 2))
{
// The preceding macro will return true ->
// this code will be executed.
}

Low-resolution timer

Low-resolution timers have a granularity of one second. Timers can be added with Util_addTimer(). When a timer is created, the user defines whether the timer is an application timer or not. The application timers generate App_timer() event, other timers must be checked with Util_checkTimer(). A timer can be modified and/or removed with Util_setTimer() function.

Definition in file util.h.

Go to the source code of this file.

Functions

bool Util_isLtUint32 (uint32_t a, uint32_t b)
 
bool Util_isSmallest (const uint32_t a, const uint32_t b, const uint32_t c)
 
bool Util_inBetween (const uint32_t a, const uint32_t b, const uint32_t c)
 
uint8_t Util_bitCountU8 (uint8_t value)
 Calculate the '1' bits in 8-bit value. More...
 

Macros

#define Util_isLtUint8(a, b)   ((int8_t)((a) - (b)) < 0)
 
#define Util_isGtOrEqUint8(a, b)   ((int8_t)((a) - (b)) >= 0)
 
#define Util_isLtUint16(a, b)   ((int16_t)((a) - (b)) < 0)
 
#define Util_isGtOrEqUint16(a, b)   ((int16_t)((a) - (b)) >= 0)
 
#define Util_isGtOrEqUint32(a, b)   !Util_isLtUint32(a, b)
 
#define Util_isGtUint8(a, b)   (!Util_isGtOrEqUint8(b, a))
 
#define Util_isGtUint16(a, b)   (!Util_isGtOrEqUint16(b, a))
 
#define Util_isGtUint32(a, b)   (!Util_isGtOrEqUint32(b, a))
 
#define SA_MEMBERNAME(line)   align ## line
 
#define SA_BASE(prev_type, size, line)
 
#define STRUCT_ALIGN_4(prev_type)   SA_BASE(prev_type, 4, __LINE__)
 
#define STRUCT_ALIGN_2(prev_type)   SA_BASE(prev_type, 2, __LINE__)
 

Function Documentation

◆ Util_bitCountU8()

uint8_t Util_bitCountU8 ( uint8_t  value)

Calculate the '1' bits in 8-bit value.

Parameters
valueInput value from where the amount of '1' bits is calculated
Returns
Amount of bits that are 1

◆ Util_inBetween()

bool Util_inBetween ( const uint32_t  a,
const uint32_t  b,
const uint32_t  c 
)

Compares a, b, and c.

Returns
Returns true, if a<=b<=c.
Precondition
a<=c

◆ Util_isLtUint32()

bool Util_isLtUint32 ( uint32_t  a,
uint32_t  b 
)

◆ Util_isSmallest()

bool Util_isSmallest ( const uint32_t  a,
const uint32_t  b,
const uint32_t  c 
)

Compares a, b, and c.

Returns
Returns true, if a<=b and a<=c.

Macro Definition Documentation

◆ SA_BASE

#define SA_BASE (   prev_type,
  size,
  line 
)
Value:
uint8_t SA_MEMBERNAME(line) \
[sizeof(prev_type)%size ? size-(sizeof(prev_type)%size) : 0]

Definition at line 119 of file util.h.

◆ SA_MEMBERNAME

#define SA_MEMBERNAME (   line)    align ## line

Definition at line 118 of file util.h.

◆ STRUCT_ALIGN_2

#define STRUCT_ALIGN_2 (   prev_type)    SA_BASE(prev_type, 2, __LINE__)

Definition at line 125 of file util.h.

◆ STRUCT_ALIGN_4

#define STRUCT_ALIGN_4 (   prev_type)    SA_BASE(prev_type, 4, __LINE__)

Definition at line 123 of file util.h.

◆ Util_isGtOrEqUint16

#define Util_isGtOrEqUint16 (   a,
 
)    ((int16_t)((a) - (b)) >= 0)

Definition at line 52 of file util.h.

◆ Util_isGtOrEqUint32

#define Util_isGtOrEqUint32 (   a,
 
)    !Util_isLtUint32(a, b)

Definition at line 53 of file util.h.

◆ Util_isGtOrEqUint8

#define Util_isGtOrEqUint8 (   a,
 
)    ((int8_t)((a) - (b)) >= 0)

Definition at line 50 of file util.h.

◆ Util_isGtUint16

#define Util_isGtUint16 (   a,
 
)    (!Util_isGtOrEqUint16(b, a))

Definition at line 58 of file util.h.

◆ Util_isGtUint32

#define Util_isGtUint32 (   a,
 
)    (!Util_isGtOrEqUint32(b, a))

Definition at line 59 of file util.h.

◆ Util_isGtUint8

#define Util_isGtUint8 (   a,
 
)    (!Util_isGtOrEqUint8(b, a))

Definition at line 57 of file util.h.

◆ Util_isLtUint16

#define Util_isLtUint16 (   a,
 
)    ((int16_t)((a) - (b)) < 0)

Definition at line 51 of file util.h.

◆ Util_isLtUint8

#define Util_isLtUint8 (   a,
 
)    ((int8_t)((a) - (b)) < 0)

Definition at line 49 of file util.h.

SA_MEMBERNAME
#define SA_MEMBERNAME(line)
Definition: util.h:118
Util_isLtUint8
#define Util_isLtUint8(a, b)
Definition: util.h:49