4.26. Utils
4.26.1. Module Files
4.26.1.1. Driver
src/app/driver/foxmath/utils.csrc/app/driver/foxmath/utils.h
4.26.1.2. Configuration
none
4.26.1.3. Unit Test
tests/unit/app/driver/foxmath/test_utils.ctests/unit/bootloader/driver/foxmath/test_utils.c
4.26.2. Description
This module contains generic helper functionality used by several driver and application modules.
Implemented functionality:
String-to-integer packing via
UTIL_ExtractCharactersFromString()Pseudo-random number generation via
UTIL_SeedRandomNumber()andUTIL_GetPseudoRandomNumber()
4.26.2.1. String Character Extraction
UTIL_ExtractCharactersFromString() packs a selected substring into a
uint64_t.
Each extracted character is appended by shifting the current result by one byte
and adding the next ASCII value.
The routine:
checks all input arguments with
FAS_ASSERTlimits extraction to
stringLengthsupports extraction of up to 8 characters (size of
uint64_t)
4.26.2.2. Pseudo-Random Number Utility
The pseudo-random number utility is based on an internal state variable.
UTIL_SeedRandomNumber() initializes this state.
UTIL_GetPseudoRandomNumber() then updates it using a linear congruential
step and the current system tick (OS_GetTickCount()) as increment.
The returned value is derived from the updated state by shifting and masking to 15 bits.
Note
This routine is intended for lightweight pseudo-random behavior and not for cryptographic use cases.