-//! Handles unique MSP430 JTAG commands. Forwards others to JTAG.
-void jtag430handle(unsigned char app,
- unsigned char verb,
- unsigned char len){
- unsigned char i;
+//! Grab the core ID.
+unsigned int jtag430_coreid(){
+ jtag_ir_shift8(IR_COREIP_ID);
+ return jtag_dr_shift16(0);
+}
+
+//! Grab the device ID.
+unsigned long jtag430_deviceid(){
+ jtag_ir_shift8(IR_DEVICE_ID);
+ return jtag_dr_shift20(0);
+}
+
+
+
+
+//! Handles classic MSP430 JTAG commands. Forwards others to JTAG.
+void jtag430_handle_fn(uint8_t const app,
+ uint8_t const verb,
+ uint32_t const len)
+{
+ unsigned long at, l;
+ unsigned int i, val;
+
+
+ /* FIXME
+ * Sometimes JTAG doesn't init correctly.
+ * This restarts the connection if the masked-rom
+ * chip ID cannot be read. Should print warning
+ * for testing server.
+ */
+ while((i=jtag430_readmem(0xff0))==0xFFFF){
+ debugstr("Reconnecting to target MSP430.");
+ jtag430x2_start();
+ PLEDOUT^=PLEDPIN;
+ }
+ PLEDOUT&=~PLEDPIN;
+
+