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();
163 //! Overwrite all of RAM with 0xBEEF, then reboot.
164 void monitor_ram_pattern()
169 for(a=(int*)0x1100;a<(int*)0x2500;a++)
170 {//TODO get these from the linker.
175 #if (platform == tilaunchpad)
176 longjmp(warmstart,1);
185 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
186 unsigned int monitor_ram_depth()
189 register int count=0;
190 for(a=0x1100;a<0x2500;a+=2)
191 if(*((int*)a)==0xBEEF) count+=2;
196 //! Call a function by address.
197 int fncall(unsigned int adr)
200 machfn = (int (*)()) adr;