2 \author Travis Goodspeed
3 \brief Local debug monitor.
10 //! Call a function by address.
11 int fncall(unsigned int adr){
13 machfn= (int (*)()) adr;
17 //! Handles a monitor command.
18 void monitorhandle(unsigned char app,
23 debugstr("ERROR: Command unsupported by debug monitor.");
26 cmddata[0]=memorybyte[cmddataword[0]];
30 //Todo, make word or byte.
31 memorybyte[cmddataword[0]]=cmddata[2];
32 cmddata[0]=memorybyte[cmddataword[0]];
36 //Set the program counter to cmdword[0];
37 cmddataword[0]=fncall(cmddataword[0]);
41 //Execute the argument as code from RAM.
42 cmddataword[0]=fncall((u16) cmddataword);
46 //TODO make the data length target-specific, varying by ram.
50 case MONITOR_CHANGE_BAUD:
51 //This command, and ONLY this command, does not reply.
55 case MONITOR_RAM_PATTERN:
56 monitor_ram_pattern();//reboots, will never return
58 case MONITOR_RAM_DEPTH:
59 cmddataword[0]=monitor_ram_depth();
78 case MONITOR_CONNECTED:
79 msp430_init_dco_done();
85 //! Overwrite all of RAM with 0xBEEF, then reboot.
86 void monitor_ram_pattern(){
90 for(a=(int*)0x1100;a<(int*)0x2500;a++){//TODO get these from the linker.
101 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
102 unsigned int monitor_ram_depth(){
104 register int count=0;
105 for(a=0x1100;a<0x2500;a+=2)
106 if(*((int*)a)==0xBEEF) count+=2;