cc253x: Add stack monitoring helpers

This commit is contained in:
Philippe Rétornaz 2012-08-23 16:16:04 +02:00 committed by George Oikonomou
parent 780e62d7e8
commit 9a63e8c027
2 changed files with 33 additions and 0 deletions

View file

@ -52,3 +52,33 @@ soc_init()
ENABLE_INTERRUPTS(); ENABLE_INTERRUPTS();
} }
#ifndef STACK_POISON
#define STACK_POISON 0xAA
#endif
void
cc253x_stack_poison(void)
{
__asm
mov r1, _SP
poison_loop:
inc r1
mov @r1, #STACK_POISON
cjne r1, #0xFF, poison_loop
__endasm;
}
uint8_t
cc253x_get_max_stack(void)
{
__data uint8_t * sp = (__data uint8_t *) 0xff;
uint8_t free = 0;
while(*sp-- == STACK_POISON) {
free++;
}
return 0xff - free;
}

View file

@ -61,4 +61,7 @@
void soc_init(); void soc_init();
void cc253x_stack_poison(void);
uint8_t cc253x_get_max_stack(void);
#endif /* __SOC_H__ */ #endif /* __SOC_H__ */