45 #include "dev/watchdog.h" 49 #define LOG_MODULE "Stack" 50 #define LOG_LEVEL LOG_LEVEL_MAIN 54 extern uint8_t _stack;
56 #if STACK_CHECK_PERIODIC_CHECKS 57 PROCESS(stack_check_process,
"Stack check");
61 #define STACK_FILL 0xcd 65 #define GET_STACK_ORIGIN() STACK_ORIGIN 68 extern int _stack_origin;
69 #define GET_STACK_ORIGIN() (&_stack_origin) 78 static void *stack_top;
84 while(p < (uint8_t *)stack_top) {
88 #if STACK_CHECK_PERIODIC_CHECKS 105 while(*p != STACK_FILL && p < (uint8_t *)GET_STACK_ORIGIN()) {
110 while(*p == STACK_FILL && p < (uint8_t *)GET_STACK_ORIGIN()) {
117 if(p >= (uint8_t*)GET_STACK_ORIGIN()) {
122 return (uint8_t *)GET_STACK_ORIGIN() - p;
128 return (uint8_t *)GET_STACK_ORIGIN() - &_stack;
131 #if STACK_CHECK_PERIODIC_CHECKS 142 uint16_t actual, allowed;
148 if(actual > allowed) {
149 LOG_ERR(
"Check failed: %u vs. %u\n", actual, allowed);
151 LOG_DBG(
"Check ok: %u vs. %u\n", actual, allowed);
#define PROCESS(name, strname)
Declare a process.
uint16_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.
uint16_t stack_check_get_reserved_size(void)
Calculate the maximal permitted stack usage.
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.
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.