- Timestamp:
- Feb 6, 2011, 10:48:27 PM (14 years ago)
- Location:
- sandbox/JamPlayerUSB
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/JamPlayerUSB/jbiexprt.h
r109 r110 161 161 int tms, 162 162 int tdi, 163 int read_tdo, 164 int flag 163 int read_tdo 165 164 ); 166 165 -
sandbox/JamPlayerUSB/jbijtag.c
r109 r110 518 518 for (i = 0; i < 5; ++i) 519 519 { 520 jbi_jtag_io(TMS_HIGH, TDI_LOW, IGNORE_TDO , 0);520 jbi_jtag_io(TMS_HIGH, TDI_LOW, IGNORE_TDO); 521 521 } 522 522 … … 524 524 * Now step to Run Test / Idle 525 525 */ 526 jbi_jtag_io(TMS_LOW, TDI_LOW, IGNORE_TDO , 0);526 jbi_jtag_io(TMS_LOW, TDI_LOW, IGNORE_TDO); 527 527 528 528 jbi_jtag_state = IDLE; … … 562 562 (state == IRPAUSE)) 563 563 { 564 jbi_jtag_io(TMS_LOW, TDI_LOW, IGNORE_TDO , 0);564 jbi_jtag_io(TMS_LOW, TDI_LOW, IGNORE_TDO); 565 565 } 566 566 else if (state == RESET) 567 567 { 568 jbi_jtag_io(TMS_HIGH, TDI_LOW, IGNORE_TDO , 0);568 jbi_jtag_io(TMS_HIGH, TDI_LOW, IGNORE_TDO); 569 569 } 570 570 } … … 582 582 * Take a step 583 583 */ 584 jbi_jtag_io(tms, TDI_LOW, IGNORE_TDO , 0);584 jbi_jtag_io(tms, TDI_LOW, IGNORE_TDO); 585 585 586 586 if (tms) … … 641 641 tms = (wait_state == RESET) ? TMS_HIGH : TMS_LOW; 642 642 643 flag = (cycles % 8 != 0 || tms) ? 0 : 1; 644 645 for (count = 0L; count < cycles; count++) 646 { 647 jbi_jtag_io(tms, TDI_LOW, IGNORE_TDO, flag); 648 } 643 usb_blaster_wait(cycles, tms); 649 644 } 650 645 … … 778 773 { 779 774 case 0: /* IDLE */ 780 jbi_jtag_io(1, 0, 0 , 0); /* DRSELECT */781 jbi_jtag_io(0, 0, 0 , 0); /* DRCAPTURE */782 jbi_jtag_io(0, 0, 0 , 0); /* DRSHIFT */783 break; 784 785 case 1: 786 jbi_jtag_io(1, 0, 0 , 0); /* DREXIT2 */787 jbi_jtag_io(1, 0, 0 , 0); /* DRUPDATE */788 jbi_jtag_io(1, 0, 0 , 0); /* DRSELECT */789 jbi_jtag_io(0, 0, 0 , 0); /* DRCAPTURE */790 jbi_jtag_io(0, 0, 0 , 0); /* DRSHIFT */791 break; 792 793 case 2: 794 jbi_jtag_io(1, 0, 0 , 0); /* IREXIT2 */795 jbi_jtag_io(1, 0, 0 , 0); /* IRUPDATE */796 jbi_jtag_io(1, 0, 0 , 0); /* DRSELECT */797 jbi_jtag_io(0, 0, 0 , 0); /* DRCAPTURE */798 jbi_jtag_io(0, 0, 0 , 0); /* DRSHIFT */775 jbi_jtag_io(1, 0, 0); /* DRSELECT */ 776 jbi_jtag_io(0, 0, 0); /* DRCAPTURE */ 777 jbi_jtag_io(0, 0, 0); /* DRSHIFT */ 778 break; 779 780 case 1: /* DRPAUSE */ 781 jbi_jtag_io(1, 0, 0); /* DREXIT2 */ 782 jbi_jtag_io(1, 0, 0); /* DRUPDATE */ 783 jbi_jtag_io(1, 0, 0); /* DRSELECT */ 784 jbi_jtag_io(0, 0, 0); /* DRCAPTURE */ 785 jbi_jtag_io(0, 0, 0); /* DRSHIFT */ 786 break; 787 788 case 2: /* IRPAUSE */ 789 jbi_jtag_io(1, 0, 0); /* IREXIT2 */ 790 jbi_jtag_io(1, 0, 0); /* IRUPDATE */ 791 jbi_jtag_io(1, 0, 0); /* DRSELECT */ 792 jbi_jtag_io(0, 0, 0); /* DRCAPTURE */ 793 jbi_jtag_io(0, 0, 0); /* DRSHIFT */ 799 794 break; 800 795 … … 806 801 { 807 802 /* loop in the SHIFT-DR state */ 808 for (i = 0; i < count; i++) 809 { 810 tdo_bit = jbi_jtag_io( 811 (i == count - 1), 812 tdi[i >> 3] & (1 << (i & 7)), 813 (tdo != NULL), 1); 814 815 if (tdo != NULL) 816 { 817 if (tdo_bit) 818 { 819 tdo[i >> 3] |= (1 << (i & 7)); 820 } 821 else 822 { 823 tdo[i >> 3] &= ~(unsigned int) (1 << (i & 7)); 824 } 825 } 826 } 827 828 jbi_jtag_io(0, 0, 0, 0); /* DRPAUSE */ 803 usb_blaster_scan(count, tdi, tdo); 804 805 jbi_jtag_io(0, 0, 0); /* DRPAUSE */ 829 806 } 830 807 … … 850 827 { 851 828 case 0: /* IDLE */ 852 jbi_jtag_io(1, 0, 0 , 0); /* DRSELECT */853 jbi_jtag_io(1, 0, 0 , 0); /* IRSELECT */854 jbi_jtag_io(0, 0, 0 , 0); /* IRCAPTURE */855 jbi_jtag_io(0, 0, 0 , 0); /* IRSHIFT */856 break; 857 858 case 1: 859 jbi_jtag_io(1, 0, 0 , 0); /* DREXIT2 */860 jbi_jtag_io(1, 0, 0 , 0); /* DRUPDATE */861 jbi_jtag_io(1, 0, 0 , 0); /* DRSELECT */862 jbi_jtag_io(1, 0, 0 , 0); /* IRSELECT */863 jbi_jtag_io(0, 0, 0 , 0); /* IRCAPTURE */864 jbi_jtag_io(0, 0, 0 , 0); /* IRSHIFT */865 break; 866 867 case 2: 868 jbi_jtag_io(1, 0, 0 , 0); /* IREXIT2 */869 jbi_jtag_io(1, 0, 0 , 0); /* IRUPDATE */870 jbi_jtag_io(1, 0, 0 , 0); /* DRSELECT */871 jbi_jtag_io(1, 0, 0 , 0); /* IRSELECT */872 jbi_jtag_io(0, 0, 0 , 0); /* IRCAPTURE */873 jbi_jtag_io(0, 0, 0 , 0); /* IRSHIFT */829 jbi_jtag_io(1, 0, 0); /* DRSELECT */ 830 jbi_jtag_io(1, 0, 0); /* IRSELECT */ 831 jbi_jtag_io(0, 0, 0); /* IRCAPTURE */ 832 jbi_jtag_io(0, 0, 0); /* IRSHIFT */ 833 break; 834 835 case 1: /* DRPAUSE */ 836 jbi_jtag_io(1, 0, 0); /* DREXIT2 */ 837 jbi_jtag_io(1, 0, 0); /* DRUPDATE */ 838 jbi_jtag_io(1, 0, 0); /* DRSELECT */ 839 jbi_jtag_io(1, 0, 0); /* IRSELECT */ 840 jbi_jtag_io(0, 0, 0); /* IRCAPTURE */ 841 jbi_jtag_io(0, 0, 0); /* IRSHIFT */ 842 break; 843 844 case 2: /* IRPAUSE */ 845 jbi_jtag_io(1, 0, 0); /* IREXIT2 */ 846 jbi_jtag_io(1, 0, 0); /* IRUPDATE */ 847 jbi_jtag_io(1, 0, 0); /* DRSELECT */ 848 jbi_jtag_io(1, 0, 0); /* IRSELECT */ 849 jbi_jtag_io(0, 0, 0); /* IRCAPTURE */ 850 jbi_jtag_io(0, 0, 0); /* IRSHIFT */ 874 851 break; 875 852 … … 881 858 { 882 859 /* loop in the SHIFT-IR state */ 883 for (i = 0; i < count; i++) 884 { 885 tdo_bit = jbi_jtag_io( 886 (i == count - 1), 887 tdi[i >> 3] & (1 << (i & 7)), 888 (tdo != NULL), 0); 889 890 if (tdo != NULL) 891 { 892 if (tdo_bit) 893 { 894 tdo[i >> 3] |= (1 << (i & 7)); 895 } 896 else 897 { 898 tdo[i >> 3] &= ~(unsigned int) (1 << (i & 7)); 899 } 900 } 901 } 902 903 jbi_jtag_io(0, 0, 0, 0); /* IRPAUSE */ 860 usb_blaster_scan(count, tdi, tdo); 861 862 jbi_jtag_io(0, 0, 0); /* IRPAUSE */ 904 863 } 905 864 -
sandbox/JamPlayerUSB/jbistub.c
r109 r110 163 163 /******************************************************************/ 164 164 165 void usb_blaster_ buf_flush()165 void usb_blaster_wait(int count, int tms) 166 166 { 167 167 DWORD cnt; 168 int len; 169 170 if(usb_buf_pos > 0) 171 { 172 len = usb_buf_pos >> 3; 173 usb_buf[0] = len | 0x80; 174 175 usb_blaster_buf_write(usb_buf, len + 1, &cnt); 176 usb_buf_pos = 0; 168 169 BYTE buf[64]; 170 171 int i, len, extra; 172 173 printf("usb_blaster_wait (count tms) -> (%d %d)\n", count, tms); 174 fflush(stdout); 175 176 if (count <= 0) return; 177 178 memset(buf, 0, 64); 179 180 extra = (count & 7); 181 182 buf[0] = 0x0C | (tms ? 0x02 : 0); 183 usb_blaster_buf_write(buf, 1, &cnt); 184 185 while (count > 0) 186 { 187 if (count > 504) 188 { 189 len = 63; 190 count -= 504; 191 } 192 else 193 { 194 len = count >> 3; 195 count = 0; 196 } 197 198 if (len > 0) 199 { 200 buf[0] = len | 0x80; 201 usb_blaster_buf_write(buf, len + 1, &cnt); 202 } 203 } 204 for (i = 0; i < extra; i++) 205 { 206 jbi_jtag_io(tms, 0, 0); 177 207 } 178 208 } … … 180 210 /******************************************************************/ 181 211 182 void usb_blaster_buf_fill(int tdi) 183 { 184 int index, shift; 185 186 if (usb_buf_pos >= 504) usb_blaster_buf_flush(); 187 188 index = (usb_buf_pos >> 3) + 1; 189 shift = (usb_buf_pos & 7); 190 191 if (shift == 0) usb_buf[index] = 0; 192 193 usb_buf[index] |= ((tdi&0x01) << shift); 194 195 ++usb_buf_pos; 212 void usb_blaster_scan(int count, unsigned char *tdi, unsigned char *tdo) 213 { 214 DWORD cnt; 215 216 BYTE buf[64]; 217 218 unsigned char extra_bits; 219 220 int i, len, pos, extra, tdo_bit, read_tdo; 221 222 read_tdo = (tdo != NULL); 223 224 printf("usb_blaster_scan (count read) -> (%d %d)\n", count, read_tdo); 225 fflush(stdout); 226 227 if (count <= 0) return; 228 229 pos = 0; 230 extra = (count & 7); 231 232 if (extra == 0) 233 { 234 count -= 8; 235 extra = 8; 236 } 237 238 extra_bits = tdi[count >> 3]; 239 240 while (count > 0) 241 { 242 if (count > 504) 243 { 244 len = 63; 245 count -= 504; 246 } 247 else 248 { 249 len = count >> 3; 250 count = 0; 251 } 252 253 if (len > 0) 254 { 255 buf[0] = len | 0x80 | (read_tdo ? 0x40 : 0); 256 memcpy(buf + 1, tdi + pos, len); 257 usb_blaster_buf_write(buf, len + 1, &cnt); 258 if (read_tdo) 259 { 260 usb_blaster_buf_read(tdo + pos, len, &cnt); 261 } 262 pos += len; 263 } 264 } 265 for (i = 0; i < extra; i++) 266 { 267 tdo_bit = jbi_jtag_io( 268 (i == extra - 1), 269 extra_bits & (1 << (i & 7)), 270 read_tdo); 271 272 if (read_tdo) 273 { 274 if (tdo_bit) 275 { 276 tdo[pos] |= (1 << (i & 7)); 277 } 278 else 279 { 280 tdo[pos] &= ~(unsigned int) (1 << (i & 7)); 281 } 282 } 283 } 196 284 } 197 285 … … 205 293 */ 206 294 207 int jbi_jtag_io(int tms, int tdi, int read_tdo , int flag)208 { 209 BYTE buf[ 2];295 int jbi_jtag_io(int tms, int tdi, int read_tdo) 296 { 297 BYTE buf[3]; 210 298 DWORD count; 211 299 … … 219 307 } 220 308 221 if (flag == 0 || read_tdo) 222 { 223 /* 224 printf("(tms tdi read flag) -> (%d %d %d %d)\n", tms, tdi, read_tdo, flag); 225 fflush(stdout); 226 */ 227 usb_blaster_buf_flush(); 228 229 data = (tdi ? 0x10 : 0) | (tms ? 0x02 : 0); 230 231 buf[0] = data | 0x0C; 232 buf[1] = data | 0x01 | 0x0C | (read_tdo ? 0x40 : 0); 233 usb_blaster_buf_write(buf, 2, &count); 234 235 if (read_tdo) 236 { 237 usb_blaster_buf_read(buf, 1, &count); 238 tdo = buf[0]&0x01; 239 /* 240 printf("(tdo) -> (%d)\n", tdo); 241 fflush(stdout); 242 */ 243 } 244 } 245 else 246 { 247 usb_blaster_buf_fill(tdi ? 1 : 0); 309 data = (tdi ? 0x10 : 0) | (tms ? 0x02 : 0); 310 311 buf[0] = data | 0x0C | (read_tdo ? 0x40 : 0); 312 buf[1] = data | 0x0C | 0x01; 313 buf[2] = data | 0x0C; 314 usb_blaster_buf_write(buf, 3, &count); 315 316 if (read_tdo) 317 { 318 usb_blaster_buf_read(buf, 1, &count); 319 tdo = buf[0]&0x01; 248 320 } 249 321
Note:
See TracChangeset
for help on using the changeset viewer.