-//GoodFET ChipCon Debugging Application
-//by Travis Goodspeed
-//<travis at radiantmachines.com>
+/*! \file chipcon.c
+ \author Travis Goodspeed
+ \brief Chipcon 8051 debugging.
+*/
//This is like SPI, except that you read or write, not both.
-/** N.B. The READ verb performs a write of all (any) supplied data,
+/* N.B. The READ verb performs a write of all (any) supplied data,
then reads a single byte reply from the target. The WRITE verb
only writes.
*/
#include <iomacros.h>
-/** Concerning clock rates,
+/* Concerning clock rates,
the maximimum clock rates are defined on page 4 of the spec.
They vary, but are roughly 30MHz. Raising this clock rate might
allow for clock glitching, but the GoodFET isn't sufficient fast for that.
//This could be more accurate.
//Does it ever need to be?
-#define CCSPEED 0
+#define CCSPEED 3
#define CCDELAY(x) delay(x)
#define SETMOSI P5OUT|=MOSI
//! Handles a monitor command.
void cchandle(unsigned char app,
unsigned char verb,
- unsigned char len){
+ unsigned long len){
+ //Always init. Might help with buggy lines.
+ ccdebuginit();
+
switch(verb){
//CC_PEEK and CC_POKE will come later.
case READ: //Write a command and return 1-byte reply.
unsigned char c){
unsigned char cmd=0x54+(len&0x3);//(len&0x3);
CCWRITE;
+ cctrans8(0xFF);//resync
+ cctrans8(0xFF);//resync
+ cctrans8(0xFF);//resync
+ cctrans8(0xFF);//resync
+ cctrans8(0xFF);//resync
cctrans8(cmd);
if(len--)
cctrans8(a);