45 #include "dev/watchdog.h" 50 #define LOG_MODULE "Stack" 51 #define LOG_LEVEL LOG_LEVEL_MAIN 55 extern uint8_t _stack;
57 #if STACK_CHECK_PERIODIC_CHECKS 58 PROCESS(stack_check_process,
"Stack check");
62 #define STACK_FILL 0xcd 66 #define GET_STACK_ORIGIN() STACK_ORIGIN 69 extern int _stack_origin;
70 #define GET_STACK_ORIGIN() (&_stack_origin) 79 static void *stack_top;
85 while(p < (uint8_t *)stack_top) {
89 #if STACK_CHECK_PERIODIC_CHECKS 106 while(*p != STACK_FILL && p < (uint8_t *)GET_STACK_ORIGIN()) {
111 while(*p == STACK_FILL && p < (uint8_t *)GET_STACK_ORIGIN()) {
118 if(p >= (uint8_t*)GET_STACK_ORIGIN()) {
123 return (uint8_t *)GET_STACK_ORIGIN() - p;
129 return (uint8_t *)GET_STACK_ORIGIN() - &_stack;
132 #if STACK_CHECK_PERIODIC_CHECKS 143 int32_t actual, allowed;
149 if(actual < 0 || allowed < 0) {
150 LOG_ERR(
"Check in inconsistent state: %" PRId32
" vs. %" PRId32
"\n", actual, allowed);
151 }
else if(actual > allowed) {
152 LOG_ERR(
"Check failed: %" PRId32
" vs. %" PRId32
"\n", actual, allowed);
154 LOG_DBG(
"Check ok: %" PRId32
" vs. %" PRId32
"\n", actual, allowed);
#define PROCESS(name, strname)
Declare a process.
int32_t stack_check_get_usage(void)
Calculate the maximal stack usage so far.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_END()
Define the end of a process.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
int etimer_expired(struct etimer *et)
Check if an event timer has expired.
void stack_check_init(void)
Initialize the stack area with a known pattern.
Stack checker library header file.
int32_t stack_check_get_reserved_size(void)
Calculate the maximal permitted stack usage.
void watchdog_periodic(void)
Writes the WDT clear sequence.
PROCESS_THREAD(cc2538_rf_process, ev, data)
Implementation of the cc2538 RF driver process.
void etimer_reset(struct etimer *et)
Reset an event timer with the same interval as was previously set.
Header file for the logging system
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
void process_start(struct process *p, process_data_t data)
Start a process.