From b9a38549dceb2dc709dc10a6f740947e0d31c759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Thu, 23 Apr 2020 00:09:44 +0200 Subject: [PATCH] Add stack_check_collision() function --- stm-firmware/include/reflow-controller/stack-check.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stm-firmware/include/reflow-controller/stack-check.h b/stm-firmware/include/reflow-controller/stack-check.h index f73dd29..8e0e290 100644 --- a/stm-firmware/include/reflow-controller/stack-check.h +++ b/stm-firmware/include/reflow-controller/stack-check.h @@ -29,6 +29,18 @@ int32_t stack_check_get_usage(); int32_t stack_check_get_free(); +static inline int stack_check_collision() +{ + int ret = 0; + int32_t free_space = stack_check_get_free(); + + if ((unsigned int)free_space < STACK_CHECK_MIN_HEAP_GAP) { + ret = -1; + } + + return ret; +} + static inline uint32_t read_stack_pointer() { uint32_t stack_pointer;