2 \author Travis Goodspeed
3 \brief Local debug monitor.
13 //! Handles a monitor command.
14 void monitor_handle_fn(uint8_t const app,
18 //! Overwrite all of RAM with 0xBEEF, then reboot.
19 void monitor_ram_pattern();
21 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
22 unsigned int monitor_ram_depth();
24 //! Call a function by address.
25 int fncall(unsigned int adr);
28 // define the monitor app's app_t
29 app_t const monitor_app = {
41 "\tThe monitor app handles basic operations on the MSP430\n"
42 "\tsuch as peeking and poking memory, calling functions and\n"
43 "\tmanaging the baud rate.\n"
47 //! Handles a monitor command.
48 void monitor_handle_fn(uint8_t const app,
57 debugstr("ERROR: Command unsupported by debug monitor.");
61 //Echo back the same buffer.
65 case MONITOR_LIST_APPS:
66 // transmit firmware build date
67 txstring(app, verb, build_date);
69 // transmit app descriptions
70 for(i = 0; i < num_apps; i++)
72 txstring(app, verb, apps[i]->name);
73 // if full list, then add in description
75 txstring(app, verb, apps[i]->desc);
82 cmddata[0]=memorybyte[cmddataword[0]];
84 debugstr("Monitor peeks are unsupported on this platform.");
91 //Todo, make word or byte.
92 memorybyte[cmddataword[0]] = cmddata[2];
93 cmddata[0] = memorybyte[cmddataword[0]];
95 debugstr("Monitor pokes are unsupported on this platform.");
101 //Set the program counter to cmdword[0];
102 cmddataword[0]=fncall(cmddataword[0]);
107 //Execute the argument as code from RAM.
108 cmddataword[0]=fncall((u16) cmddataword);
112 case MONITOR_SIZEBUF:
113 //TODO make the data length target-specific, varying by ram.
114 cmddataword[0]=0x100;
118 case MONITOR_CHANGE_BAUD:
119 //This command, and ONLY this command, does not reply.
121 //txdata(app,verb,0);
124 case MONITOR_RAM_PATTERN:
125 monitor_ram_pattern();//reboots, will never return
128 case MONITOR_RAM_DEPTH:
129 cmddataword[0]=monitor_ram_depth();
135 debugstr("Command deprecated.");
141 debugstr("Command deprecated.");
147 debugstr("Command deprecated.");
156 case MONITOR_CONNECTED:
158 msp430_init_dco_done();
165 //! Overwrite all of RAM with 0xBEEF, then reboot.
166 void monitor_ram_pattern()
171 for(a=(int*)0x1100;a<(int*)0x2500;a++)
172 {//TODO get these from the linker.
183 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
184 unsigned int monitor_ram_depth()
187 register int count=0;
188 for(a=0x1100;a<0x2500;a+=2)
189 if(*((int*)a)==0xBEEF) count+=2;
194 //! Call a function by address.
195 int fncall(unsigned int adr)
198 machfn = (int (*)()) adr;