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.
67 debugstr("About to monitor echo.");
71 case MONITOR_LIST_APPS:
72 // transmit firmware build date
73 txstring(app, verb, build_date);
75 // transmit app descriptions
76 for(i = 0; i < num_apps; i++)
78 txstring(app, verb, apps[i]->name);
79 // if full list, then add in description
81 txstring(app, verb, apps[i]->desc);
88 cmddata[0]=memorybyte[cmddataword[0]];
90 debugstr("Monitor peeks are unsupported on this platform.");
91 debughex(cmddataword[0]);
99 //Todo, make word or byte.
100 memorybyte[cmddataword[0]] = cmddata[2];
101 cmddata[0] = memorybyte[cmddataword[0]];
103 debugstr("Monitor pokes are unsupported on this platform.");
104 debughex(cmddataword[0]);
111 //Set the program counter to cmdword[0];
112 cmddataword[0]=fncall(cmddataword[0]);
117 //Execute the argument as code from RAM.
118 cmddataword[0]=fncall((u16) cmddataword);
122 case MONITOR_SIZEBUF:
123 //TODO make the data length target-specific, varying by ram.
124 cmddataword[0]=0x100;
128 case MONITOR_CHANGE_BAUD:
129 //This command, and ONLY this command, does not reply.
131 //txdata(app,verb,0);
134 case MONITOR_RAM_PATTERN:
135 monitor_ram_pattern();//reboots, will never return
138 case MONITOR_RAM_DEPTH:
139 cmddataword[0]=monitor_ram_depth();
146 debugstr("Command deprecated.");
155 case MONITOR_CONNECTED:
157 msp430_init_dco_done();
164 //! Overwrite all of RAM with 0xBEEF, then reboot.
165 void monitor_ram_pattern()
170 for(a=(int*)0x1100;a<(int*)0x2500;a++)
171 {//TODO get these from the linker.
176 #if (platform == tilaunchpad)
177 longjmp(warmstart,1);
186 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.
187 unsigned int monitor_ram_depth()
190 register int count=0;
191 for(a=0x1100;a<0x2500;a+=2)
192 if(*((int*)a)==0xBEEF) count+=2;
197 //! Call a function by address.
198 int fncall(unsigned int adr)
201 machfn = (int (*)()) adr;