/*
* jtag.c - basic jtag stuff (good excercise!)
*
+ * build: gcc -Wall jtag.c -o jtag
* author: hackbard@hackdaworld.org
*
*/
memset(p,0,bitlen+7/8);
count=0;
+ printf(" <- ");
while(bitlen) {
in=jtag_clock(0,0);
p[count/8]|=((in&1)<<(count%8));
+ printf("%d",p[count/8]&(1<<(count%8))?1:0);
count+=1;
bitlen-=1;
}
+ printf("\n");
return 0;
count=0;
+ printf(" -> ");
while(bitlen) {
- jtag_clock(0,p[count/8]&(1<<count)?1:0);
+ jtag_clock(0,p[count/8]&(1<<(count%8))?1:0);
+ printf("%d",p[count/8]&(1<<(count%8))?1:0);
bitlen-=1;
count+=1;
}
+ printf("\n");
return 0;
}
memset(ir,0,MAXDEV*MAXIRLEN/8*sizeof(u8));
+ count=0;
- printf("ir to set: ");
+ printf("set ir: ");
while(bitlen) {
- ir[count/8]|=(s[count]<<(count%8));
- printf("%d",ir[count/8]&(1<<count%8)?1:0);
+ if(s[count]=='1')
+ ir[count/8]|=(1<<(count%8));
+ printf("%d",ir[count/8]&(1<<(count%8))?1:0);
count+=1;
bitlen-=1;
}
printf("\n");
jtag_enter_shift_ir();
- jtag_write_data(ir,bitlen);
+ jtag_write_data(ir,count);
jtag_leave_shift_ir();
return 0;
t_jtag jtag;
u8 io[256];
- int i;
memset(&jtag,0,sizeof(t_jtag));
jtag_set_ir("000001000001",12);
jtag_enter_shift_dr();
jtag_read_data(io,64);
- for(i=0;i<64;i++) {
- printf("%d",io[i/8]&(1<<(i%8))?1:0);
- }
- printf("\n");
jtag_leave_shift_dr();
return 0;