2 \author Travis Goodspeed
3 \brief Local debug monitor.
10 #if (platform == tilaunchpad)
12 extern jmp_buf warmstart;
18 //! Handles a monitor command.
19 void monitor_handle_fn(uint8_t const app,
23 //! Overwrite all of RAM with 0xBEEF, then reboot.
24 void monitor_ram_pattern();
26 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
27 unsigned int monitor_ram_depth();
29 //! Call a function by address.
30 int fncall(unsigned int adr);
33 // define the monitor app's app_t
34 app_t const monitor_app = {
46 "\tThe monitor app handles basic operations on the MSP430\n"
47 "\tsuch as peeking and poking memory, calling functions and\n"
48 "\tmanaging the baud rate.\n"
52 //! Handles a monitor command.
53 void monitor_handle_fn(uint8_t const app,
62 debugstr("ERROR: Command unsupported by debug monitor.");
66 //Echo back the same buffer.
70 case MONITOR_LIST_APPS:
71 // transmit firmware build date
72 txstring(app, verb, build_date);
74 // transmit app descriptions
75 for(i = 0; i < num_apps; i++)
77 txstring(app, verb, apps[i]->name);
78 // if full list, then add in description
80 txstring(app, verb, apps[i]->desc);
87 cmddata[0]=memorybyte[cmddataword[0]];
89 debugstr("Monitor peeks are unsupported on this platform.");
90 debughex(cmddataword[0]);
98 //Todo, make word or byte.
99 memorybyte[cmddataword[0]] = cmddata[2];
100 cmddata[0] = memorybyte[cmddataword[0]];
102 debugstr("Monitor pokes are unsupported on this platform.");
103 debughex(cmddataword[0]);
110 //Set the program counter to cmdword[0];
111 cmddataword[0]=fncall(cmddataword[0]);
116 //Execute the argument as code from RAM.
117 cmddataword[0]=fncall((u16) cmddataword);
121 case MONITOR_SIZEBUF:
122 //TODO make the data length target-specific, varying by ram.
123 cmddataword[0]=0x100;
127 case MONITOR_CHANGE_BAUD:
128 //This command, and ONLY this command, does not reply.
130 //txdata(app,verb,0);
133 case MONITOR_RAM_PATTERN:
134 monitor_ram_pattern();//reboots, will never return
137 case MONITOR_RAM_DEPTH:
138 cmddataword[0]=monitor_ram_depth();
145 debugstr("Command deprecated.");
154 case MONITOR_CONNECTED:
156 msp430_init_dco_done();
161 case MONITOR_LEDTEST:
162 //debugstr("Enter LEDTEST.");
183 cmddata[0] = i; //Return number of LEDs that we flashed.
190 //! Overwrite all of RAM with 0xBEEF, then reboot.
191 void monitor_ram_pattern()
196 for(a=(int*)0x1100;a<(int*)0x2500;a++)
197 {//TODO get these from the linker.
202 #if (platform == tilaunchpad)
203 longjmp(warmstart,1);
212 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
213 unsigned int monitor_ram_depth()
216 register int count=0;
217 for(a=0x1100;a<0x2500;a+=2)
218 if(*((int*)a)==0xBEEF) count+=2;
223 //! Call a function by address.
224 int fncall(unsigned int adr)
227 machfn = (int (*)()) adr;