1 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
4 * 2019/7/20 - ROBIN KRENS
13 #include <sys/robsys.h>
16 #include <lib/tinyprintf.h>
17 #include <lib/regfunc.h>
20 uint32_t get_msp(void);
24 uint32_t tmp = *MCU_ID;
25 printf("# DEVICE ID: ");
28 printf("HIGH DENSITY\n");
34 printf("# REVISION: ");
37 printf("REVISION A\n");
40 printf("REVISION Z\n");
43 printf("REVISION 1/2/3/X/Y\n");
49 extern char _endofbss;
51 uint32_t current_stack = get_msp();
52 uint32_t stack_usage = (SRAM_OFFSET + SRAM_SIZE) - current_stack;
53 uint32_t data_bss = &_endofbss - SRAM_OFFSET;
54 uint32_t mem_free = SRAM_SIZE - stack_usage - data_bss;
56 printf("# TOTAL MEMORY: %#x\n", SRAM_SIZE);
57 // cputs(regtohex(SRAM_SIZE));
59 printf("# FREE MEMORY: %#x\n", mem_free);
60 // cputs(regtohex(mem_free));
62 printf("# STACK USAGE: %#x\n", stack_usage);
63 // cputs(regtohex(stack_usage));
68 /* Get the master stack pointer's position
69 * Here we use a so-called naked function,
70 * that doesn't automatically push and pop */
72 uint32_t get_msp(void) __attribute__( ( naked ) );
73 uint32_t get_msp(void)
76 __asm__ volatile ("mrs %0, msp\n\t"
78 "bx lr \n\t" : "=r" (msp) );