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.");
96 //Todo, make word or byte.
97 memorybyte[cmddataword[0]] = cmddata[2];
98 cmddata[0] = memorybyte[cmddataword[0]];
100 debugstr("Monitor pokes are unsupported on this platform.");
106 //Set the program counter to cmdword[0];
107 cmddataword[0]=fncall(cmddataword[0]);
112 //Execute the argument as code from RAM.
113 cmddataword[0]=fncall((u16) cmddataword);
117 case MONITOR_SIZEBUF:
118 //TODO make the data length target-specific, varying by ram.
119 cmddataword[0]=0x100;
123 case MONITOR_CHANGE_BAUD:
124 //This command, and ONLY this command, does not reply.
126 //txdata(app,verb,0);
129 case MONITOR_RAM_PATTERN:
130 monitor_ram_pattern();//reboots, will never return
133 case MONITOR_RAM_DEPTH:
134 cmddataword[0]=monitor_ram_depth();
141 debugstr("Command deprecated.");
150 case MONITOR_CONNECTED:
152 msp430_init_dco_done();
159 //! Overwrite all of RAM with 0xBEEF, then reboot.
160 void monitor_ram_pattern()
165 for(a=(int*)0x1100;a<(int*)0x2500;a++)
166 {//TODO get these from the linker.
171 #if (platform == tilaunchpad)
172 longjmp(warmstart,1);
181 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
182 unsigned int monitor_ram_depth()
185 register int count=0;
186 for(a=0x1100;a<0x2500;a+=2)
187 if(*((int*)a)==0xBEEF) count+=2;
192 //! Call a function by address.
193 int fncall(unsigned int adr)
196 machfn = (int (*)()) adr;