Improve documentation of Stack Checking
This commit is contained in:
@@ -72,6 +72,9 @@ enum analog_value_monitor {
|
||||
|
||||
#define WATCHDOG_PRESCALER 8
|
||||
|
||||
/**
|
||||
* @brief Minimum number of bytes that have to be free on the stack. If this is not the case, an error is detected
|
||||
*/
|
||||
#define SAFETY_MIN_STACK_FREE 0x100
|
||||
|
||||
#define PID_CONTROLLER_ERR_CAREMASK (ERR_FLAG_STACK | ERR_FLAG_AMON_UC_TEMP | ERR_FLAG_AMON_VREF | \
|
||||
|
@@ -25,8 +25,16 @@
|
||||
|
||||
#define STACK_CHECK_MIN_HEAP_GAP 16UL
|
||||
|
||||
/**
|
||||
* @brief Get usage of the stack
|
||||
* @return Usage of the stack in bytes
|
||||
*/
|
||||
int32_t stack_check_get_usage();
|
||||
|
||||
/**
|
||||
* @brief Get free stack space
|
||||
* @return free stack space in bytes. If negative, a stack overflow occured
|
||||
*/
|
||||
int32_t stack_check_get_free();
|
||||
|
||||
static inline int stack_check_collision()
|
||||
@@ -50,8 +58,32 @@ static inline uint32_t read_stack_pointer()
|
||||
return stack_pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Init the stack corruption detection area.
|
||||
*
|
||||
* This function initializes the memory area between heap and stack with random values generated by the
|
||||
* STM's random number generator. A 32 bit CRC generated by the CRC unit of the STM is appended for verification of the
|
||||
* area.
|
||||
*
|
||||
*
|
||||
* @return 0 if successful, else an error has occured in generating a random number. This should never happen
|
||||
* @note This function turns on the CRC unit but does not disable it afterwards. Therefore, the CRC unit does not have
|
||||
* to be explicitly initialized before calling @ref stack_check_corruption_detect_area.
|
||||
*/
|
||||
int stack_check_init_corruption_detect_area(void);
|
||||
|
||||
/**
|
||||
* @brief Check the CRC of the stack corruption detection area
|
||||
*
|
||||
* This function checks the stack corruption detection area, which must be initialized by
|
||||
* @ref stack_check_init_corruption_detect_area beforehand.
|
||||
*
|
||||
* The CRC unit must be enabled for this function to work properly.
|
||||
* After calling @stack_check_init_corruption_detect_area, this is the case.
|
||||
*
|
||||
* @return 0 if no error is detected, all other values are an error.
|
||||
* @note Make sure CRC unit is enabled.
|
||||
*/
|
||||
int stack_check_corruption_detect_area(void);
|
||||
|
||||
#endif /* __STACK_CHECK_H__ */
|
||||
|
Reference in New Issue
Block a user