2 \author Travis Goodspeed
3 \brief Local debug monitor.
12 #if (platform == tilaunchpad)
14 extern jmp_buf warmstart;
20 //! Handles a monitor command.
21 void monitor_handle_fn(uint8_t const app,
25 //! Overwrite all of RAM with 0xBEEF, then reboot.
26 void monitor_ram_pattern();
28 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
29 unsigned int monitor_ram_depth();
31 //! Call a function by address.
32 int fncall(unsigned int adr);
35 // define the monitor app's app_t
36 app_t const monitor_app = {
48 "\tThe monitor app handles basic operations on the MSP430\n"
49 "\tsuch as peeking and poking memory, calling functions and\n"
50 "\tmanaging the baud rate.\n"
54 //! Handles a monitor command.
55 void monitor_handle_fn(uint8_t const app,
64 debugstr("ERROR: Command unsupported by debug monitor.");
68 //Echo back the same buffer.
72 case MONITOR_LIST_APPS:
73 // transmit firmware build date
74 txstring(app, verb, build_date);
76 // transmit app descriptions
77 for(i = 0; i < num_apps; i++)
79 txstring(app, verb, apps[i]->name);
80 // if full list, then add in description
82 txstring(app, verb, apps[i]->desc);
89 cmddata[0]=memorybyte[cmddataword[0]];
91 debugstr("Monitor peeks are unsupported on this platform.");
92 debughex(cmddataword[0]);
100 //Todo, make word or byte.
101 memorybyte[cmddataword[0]] = cmddata[2];
102 cmddata[0] = memorybyte[cmddataword[0]];
104 debugstr("Monitor pokes are unsupported on this platform.");
105 debughex(cmddataword[0]);
112 //Set the program counter to cmdword[0];
113 cmddataword[0]=fncall(cmddataword[0]);
118 //Execute the argument as code from RAM.
119 cmddataword[0]=fncall((u16) cmddataword);
123 case MONITOR_SIZEBUF:
124 //TODO make the data length target-specific, varying by ram.
125 cmddataword[0]=0x100;
129 case MONITOR_CHANGE_BAUD:
130 //This command, and ONLY this command, does not reply.
132 //txdata(app,verb,0);
135 case MONITOR_RAM_PATTERN:
136 monitor_ram_pattern();//reboots, will never return
139 case MONITOR_RAM_DEPTH:
140 cmddataword[0]=monitor_ram_depth();
147 debugstr("Command deprecated.");
156 case MONITOR_CONNECTED:
158 msp430_init_dco_done();
163 case MONITOR_LEDTEST:
164 //debugstr("Enter LEDTEST.");
185 cmddata[0] = i; //Return number of LEDs that we flashed.
192 //! Overwrite all of RAM with 0xBEEF, then reboot.
193 void monitor_ram_pattern()
198 for(a=(int*)0x1100;a<(int*)0x2500;a++)
199 {//TODO get these from the linker.
204 #if (platform == tilaunchpad)
205 longjmp(warmstart,1);
214 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
215 unsigned int monitor_ram_depth()
218 register int count=0;
219 for(a=0x1100;a<0x2500;a+=2)
220 if(*((int*)a)==0xBEEF) count+=2;
225 //! Call a function by address.
226 int fncall(unsigned int adr)
230 machfn = (int (*)()) adr;
233 debugstr("fncall() not supported on this platform.");