2020-02-21 21:22:01 +01:00
|
|
|
/* Reflow Oven Controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*
|
|
|
|
* This file is part of the Reflow Oven Controller Project.
|
|
|
|
*
|
|
|
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* GDSII-Converter is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with the reflow oven controller project.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __STACK_CHECK_H__
|
|
|
|
#define __STACK_CHECK_H__
|
|
|
|
|
2020-02-21 23:01:04 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#define STACK_CHECK_MIN_HEAP_GAP 16UL
|
|
|
|
|
|
|
|
int32_t stack_check_get_usage();
|
|
|
|
|
|
|
|
int32_t stack_check_get_free();
|
|
|
|
|
2020-04-23 00:09:44 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-02-21 23:01:04 +01:00
|
|
|
static inline uint32_t read_stack_pointer()
|
|
|
|
{
|
|
|
|
uint32_t stack_pointer;
|
|
|
|
|
|
|
|
__asm__ __volatile__ ("mov %0, sp\n\t" : "=r"(stack_pointer) : : );
|
|
|
|
|
|
|
|
return stack_pointer;
|
|
|
|
}
|
|
|
|
|
2020-02-21 21:22:01 +01:00
|
|
|
#endif /* __STACK_CHECK_H__ */
|