1 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
4 * 2019/7/20 - ROBIN KRENS
6 * Display some system information, calculate
7 * the amount of SRAM available
15 #include <sys/robsys.h>
18 #include <lib/tinyprintf.h>
19 #include <lib/regfunc.h>
22 uint32_t get_msp(void);
26 uint32_t tmp = *MCU_ID;
27 printf("SYSTEM LOADING...\n\n");
31 printf("H. DENSITY\n");
40 printf("REVISION A\n");
43 printf("REVISION Z\n");
46 printf("REVISION 1/2/3/X/Y\n");
52 extern char _endofbss;
54 uint32_t current_stack = get_msp();
55 uint32_t stack_usage = (SRAM_OFFSET + SRAM_SIZE) - current_stack;
56 uint32_t data_bss = (uint32_t) &_endofbss - SRAM_OFFSET;
57 uint32_t mem_free = SRAM_SIZE - stack_usage - data_bss;
59 extern uint32_t KHEAP_SIZE;
61 printf("TOTAL MEM: %#x\n", SRAM_SIZE);
62 printf("FREE MEM: %#x\n", mem_free);
63 printf("STACK USE: %#x\n", stack_usage);
64 printf("HEAP_SIZE: %#x\n\n", &KHEAP_SIZE);
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) );