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);
81 cmddata[0]=memorybyte[cmddataword[0]];
86 //Todo, make word or byte.
87 memorybyte[cmddataword[0]] = cmddata[2];
88 cmddata[0] = memorybyte[cmddataword[0]];
93 //Set the program counter to cmdword[0];
94 cmddataword[0]=fncall(cmddataword[0]);
99 //Execute the argument as code from RAM.
100 cmddataword[0]=fncall((u16) cmddataword);
104 case MONITOR_SIZEBUF:
105 //TODO make the data length target-specific, varying by ram.
106 cmddataword[0]=0x100;
110 case MONITOR_CHANGE_BAUD:
111 //This command, and ONLY this command, does not reply.
113 //txdata(app,verb,0);
116 case MONITOR_RAM_PATTERN:
117 monitor_ram_pattern();//reboots, will never return
120 case MONITOR_RAM_DEPTH:
121 cmddataword[0]=monitor_ram_depth();
145 case MONITOR_CONNECTED:
146 msp430_init_dco_done();
152 //! Overwrite all of RAM with 0xBEEF, then reboot.
153 void monitor_ram_pattern()
158 for(a=(int*)0x1100;a<(int*)0x2500;a++)
159 {//TODO get these from the linker.
170 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
171 unsigned int monitor_ram_depth()
174 register int count=0;
175 for(a=0x1100;a<0x2500;a+=2)
176 if(*((int*)a)==0xBEEF) count+=2;
181 //! Call a function by address.
182 int fncall(unsigned int adr)
185 machfn = (int (*)()) adr;