Utilities
Utility functions for various cases. These function are used across entire middleware and can also be used by application.
- group LWESP_UTILS
Utilities.
Defines
-
LWESP_ASSERT(c)
Assert an input parameter if in valid range.
Note
Since this is a macro, it may only be used on a functions where return status is of type lwespr_t enumeration
- Parameters
c – [in] Condition to test
-
LWESP_ASSERT0(c)
Assert an input parameter if in valid range, return 0 from function on failure.
Note
Since this is a macro, it may only be used on a functions where return status is of type lwespr_t enumeration
- Parameters
c – [in] Condition to test
-
LWESP_MEM_ALIGN(x)
Align
x
value to specific number of bytes, provided by LWESP_CFG_MEM_ALIGNMENT configuration.- Parameters
x – [in] Input value to align
- Returns
Input value aligned to specific number of bytes
-
LWESP_MIN(x, y)
Get minimal value between
x
andy
inputs.- Parameters
x – [in] First input to test
y – [in] Second input to test
- Returns
Minimal value between
x
andy
parameters
-
LWESP_MAX(x, y)
Get maximal value between
x
andy
inputs.- Parameters
x – [in] First input to test
y – [in] Second input to test
- Returns
Maximal value between
x
andy
parameters
-
LWESP_ARRAYSIZE(x)
Get size of statically declared array.
- Parameters
x – [in] Input array
- Returns
Number of array elements
-
LWESP_UNUSED(x)
Unused argument in a function call.
Note
Use this on all parameters in a function which are not used to prevent compiler warnings complaining about “unused variables”
- Parameters
x – [in] Variable which is not used
-
LWESP_U32(x)
Get input value casted to
unsigned 32-bit
value.- Parameters
x – [in] Input value
-
LWESP_U16(x)
Get input value casted to
unsigned 16-bit
value.- Parameters
x – [in] Input value
-
LWESP_U8(x)
Get input value casted to
unsigned 8-bit
value.- Parameters
x – [in] Input value
-
LWESP_I32(x)
Get input value casted to
signed 32-bit
value.- Parameters
x – [in] Input value
-
LWESP_I16(x)
Get input value casted to
signed 16-bit
value.- Parameters
x – [in] Input value
-
LWESP_I8(x)
Get input value casted to
signed 8-bit
value.- Parameters
x – [in] Input value
-
LWESP_SZ(x)
Get input value casted to
size_t
value.- Parameters
x – [in] Input value
-
lwesp_u32_to_str(num, out)
Convert
unsigned 32-bit
number to string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
- Returns
Pointer to output variable
-
lwesp_u32_to_hex_str(num, out, w)
Convert
unsigned 32-bit
number to HEX string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
w – [in] Width of output string. When number is shorter than width, leading
0
characters will apply
- Returns
Pointer to output variable
-
lwesp_i32_to_str(num, out)
Convert
signed 32-bit
number to string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
- Returns
Pointer to output variable
-
lwesp_u16_to_str(num, out)
Convert
unsigned 16-bit
number to string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
- Returns
Pointer to output variable
-
lwesp_u16_to_hex_str(num, out, w)
Convert
unsigned 16-bit
number to HEX string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
w – [in] Width of output string. When number is shorter than width, leading
0
characters will apply.
- Returns
Pointer to output variable
-
lwesp_i16_to_str(num, out)
Convert
signed 16-bit
number to string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
- Returns
Pointer to output variable
-
lwesp_u8_to_str(num, out)
Convert
unsigned 8-bit
number to string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
- Returns
Pointer to output variable
-
lwesp_u8_to_hex_str(num, out, w)
Convert
unsigned 16-bit
number to HEX string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
w – [in] Width of output string. When number is shorter than width, leading
0
characters will apply.
- Returns
Pointer to output variable
-
lwesp_i8_to_str(num, out)
Convert
signed 8-bit
number to string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
- Returns
Pointer to output variable
Functions
-
char *lwesp_u32_to_gen_str(uint32_t num, char *out, uint8_t is_hex, uint8_t padding)
Convert
unsigned 32-bit
number to string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
is_hex – [in] Set to
1
to output hex, 0 otherwisewidth – [in] Width of output string. When number is shorter than width, leading
0
characters will apply. This parameter is valid only when formatting hex numbers
- Returns
Pointer to output variable
-
char *lwesp_i32_to_gen_str(int32_t num, char *out)
Convert
signed 32-bit
number to string.- Parameters
num – [in] Number to convert
out – [out] Output variable to save string
- Returns
Pointer to output variable
-
LWESP_ASSERT(c)