mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
cc253x: Add stack monitoring helpers
This commit is contained in:
parent
780e62d7e8
commit
9a63e8c027
@ -52,3 +52,33 @@ soc_init()
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,4 +61,7 @@
|
||||
|
||||
void soc_init();
|
||||
|
||||
void cc253x_stack_poison(void);
|
||||
uint8_t cc253x_get_max_stack(void);
|
||||
|
||||
#endif /* __SOC_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user