2 \author Travis Goodspeed
3 \brief Local debug monitor.
10 //! Call a function by address.
11 int fncall(unsigned int adr){
12 //TODO replace this with portable C.
13 //Preprocessor definition might help.
14 __asm__("call r15"); //r12 on IAR
17 //! Handles a monitor command.
18 void monitorhandle(unsigned char app,
23 cmddata[0]=memorybyte[cmddataword[0]];
27 //Todo, make word or byte.
28 memorybyte[cmddataword[0]]=cmddata[2];
29 cmddata[0]=memorybyte[cmddataword[0]];
33 //Set the program counter to cmdword[0];
34 cmddataword[0]=fncall(cmddataword[0]);
38 //Execute the argument as code from RAM.
39 cmddataword[0]=fncall((u16) cmddataword);
43 //TODO make the data length target-specific, varying by ram.
47 case MONITOR_CHANGE_BAUD:
48 //This command, and ONLY this command, does not reply.
52 case MONITOR_RAM_PATTERN:
53 monitor_ram_pattern();//reboots, will never return
55 case MONITOR_RAM_DEPTH:
56 cmddataword[0]=monitor_ram_depth();
78 //! Overwrite all of RAM with 0xBEEF, then reboot.
79 void monitor_ram_pattern(){
83 for(a=(int*)0x1100;a<(int*)0x2500;a++){//TODO get these from the linker.
92 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
93 unsigned int monitor_ram_depth(){
96 for(a=0x1100;a<0x2500;a+=2)
97 if(*((int*)a)==0xBEEF) count+=2;