HRI board firmware  v2.1
Microcontroller firmware of the board used during the HRI labs.
Macros | Functions
Lib / Utils

Utility functions and constants. More...

Macros

#define CPU_TRAPS_ENABLED   1
 utils_TrapCpu() will be block forever if 1, or return immediately if 0. More...
 
#define SECOND_TO_MICROSECOND   1000000.0f
 
#define MICROSECOND_TO_SECOND   (1.0f/SECOND_TO_MICROSECOND)
 

Functions

void utils_TrapCpu (void)
 Endless loop function to stop the execution of the program here. More...
 
void utils_DelayUs (uint32_t duration)
 "Busy wait" delay function More...
 
void utils_DelayMs (uint32_t duration)
 "Busy wait" delay function More...
 
void utils_SaturateF (float32_t *val, float32_t min, float32_t max)
 Saturate a float number between two bounds. More...
 
void utils_SaturateU (uint32_t *val, uint32_t min, uint32_t max)
 Saturate an integer number between two bounds. More...
 
float32_t utils_Mean (float32_t *array, int size)
 Compute the mean of the array values. More...
 

Detailed Description

Utility functions and constants.

This module provides functions and constants that may be used at many places in the code.

Macro Definition Documentation

◆ CPU_TRAPS_ENABLED

#define CPU_TRAPS_ENABLED   1

utils_TrapCpu() will be block forever if 1, or return immediately if 0.

◆ MICROSECOND_TO_SECOND

#define MICROSECOND_TO_SECOND   (1.0f/SECOND_TO_MICROSECOND)

◆ SECOND_TO_MICROSECOND

#define SECOND_TO_MICROSECOND   1000000.0f

Function Documentation

◆ utils_DelayMs()

void utils_DelayMs ( uint32_t  duration)

"Busy wait" delay function

Parameters
durationDelay time in [ms] (approximative value based on a 168MHz core clock).
Note
This delay is approximative, and may last longer if there are many interrupts.

◆ utils_DelayUs()

void utils_DelayUs ( uint32_t  duration)

"Busy wait" delay function

Parameters
durationDelay time in [us] (approximative value based on a 168MHz core clock)

◆ utils_Mean()

float32_t utils_Mean ( float32_t *  array,
int  size 
)

Compute the mean of the array values.

Parameters
arrayarray of float number to get the mean from.
sizesize of the array.
Return values
themean of the array values.

◆ utils_SaturateF()

void utils_SaturateF ( float32_t *  val,
float32_t  min,
float32_t  max 
)

Saturate a float number between two bounds.

Parameters
valvalue to constrain between two limits.
minminimum
maxmaximum
Return values
None.

◆ utils_SaturateU()

void utils_SaturateU ( uint32_t *  val,
uint32_t  min,
uint32_t  max 
)

Saturate an integer number between two bounds.

Parameters
valvalue to constrain between the two limits.
minlower limit.
maxupper limit.
Return values
None.

◆ utils_TrapCpu()

void utils_TrapCpu ( void  )

Endless loop function to stop the execution of the program here.

Note
This function does nothing if CPU_TRAPS_ENABLED is set to zero.