mirror of
https://github.com/linux-msm/openocd.git
synced 2026-02-25 13:15:07 -08:00
build: cleanup src/jtag/drivers directory
Change-Id: I99c08ec0132d5a15250050e718310f1ddd9fe546 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/425 Tested-by: jenkins
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define NOP {__asm nop __endasm;}
|
||||
#define NOP { __asm nop __endasm; }
|
||||
|
||||
void delay_5us(void);
|
||||
void delay_1ms(void);
|
||||
|
||||
@@ -51,15 +51,14 @@
|
||||
|
||||
/* PORT A */
|
||||
#define PIN_U_OE OUTA0
|
||||
// PA1 Not Connected
|
||||
/* PA1 Not Connected */
|
||||
#define PIN_OE OUTA2
|
||||
// PA3 Not Connected
|
||||
/* PA3 Not Connected */
|
||||
#define PIN_RUN_LED OUTA4
|
||||
#define PIN_TDO PINA5
|
||||
#define PIN_BRKOUT PINA6
|
||||
#define PIN_COM_LED OUTA7
|
||||
|
||||
|
||||
/* PORT B */
|
||||
#define PIN_TDI OUTB0
|
||||
#define PIN_TMS OUTB1
|
||||
@@ -77,18 +76,18 @@
|
||||
#define PIN_RXD0 PINC0
|
||||
#define PIN_TXD0 OUTC1
|
||||
#define PIN_RESET_2 PINC2
|
||||
// PC3 Not Connected
|
||||
// PC4 Not Connected
|
||||
/* PC3 Not Connecte */
|
||||
/* PC4 Not Connected */
|
||||
#define PIN_RTCK PINC5
|
||||
#define PIN_WR OUTC6
|
||||
// PC7 Not Connected
|
||||
/* PC7 Not Connected */
|
||||
|
||||
/* LED Macros */
|
||||
#define SET_RUN_LED() OUTA &= ~PIN_RUN_LED
|
||||
#define CLEAR_RUN_LED() OUTA |= PIN_RUN_LED
|
||||
#define SET_RUN_LED() (OUTA &= ~PIN_RUN_LED)
|
||||
#define CLEAR_RUN_LED() (OUTA |= PIN_RUN_LED)
|
||||
|
||||
#define SET_COM_LED() OUTA &= ~PIN_COM_LED
|
||||
#define CLEAR_COM_LED() OUTA |= PIN_COM_LED
|
||||
#define SET_COM_LED() (OUTA &= ~PIN_COM_LED)
|
||||
#define CLEAR_COM_LED() (OUTA |= PIN_COM_LED)
|
||||
|
||||
/* JTAG Pin Macros */
|
||||
#define GET_TMS() (PINSB & PIN_TMS)
|
||||
@@ -99,27 +98,27 @@
|
||||
#define GET_TRAP() (PINSB & PIN_TRAP)
|
||||
#define GET_RTCK() (PINSC & PIN_RTCK)
|
||||
|
||||
#define SET_TMS_HIGH() OUTB |= PIN_TMS
|
||||
#define SET_TMS_LOW() OUTB &= ~PIN_TMS
|
||||
#define SET_TMS_HIGH() (OUTB |= PIN_TMS)
|
||||
#define SET_TMS_LOW() (OUTB &= ~PIN_TMS)
|
||||
|
||||
#define SET_TCK_HIGH() OUTB |= PIN_TCK
|
||||
#define SET_TCK_LOW() OUTB &= ~PIN_TCK
|
||||
#define SET_TCK_HIGH() (OUTB |= PIN_TCK)
|
||||
#define SET_TCK_LOW() (OUTB &= ~PIN_TCK)
|
||||
|
||||
#define SET_TDI_HIGH() OUTB |= PIN_TDI
|
||||
#define SET_TDI_LOW() OUTB &= ~PIN_TDI
|
||||
#define SET_TDI_HIGH() (OUTB |= PIN_TDI)
|
||||
#define SET_TDI_LOW() (OUTB &= ~PIN_TDI)
|
||||
|
||||
/* TRST and RESET are low-active and inverted by hardware. SET_HIGH de-asserts
|
||||
* the signal (enabling reset), SET_LOW asserts the signal (disabling reset) */
|
||||
#define SET_TRST_HIGH() OUTB |= PIN_TRST
|
||||
#define SET_TRST_LOW() OUTB &= ~PIN_TRST
|
||||
#define SET_TRST_HIGH() (OUTB |= PIN_TRST)
|
||||
#define SET_TRST_LOW() (OUTB &= ~PIN_TRST)
|
||||
|
||||
#define SET_RESET_HIGH() OUTB |= PIN_RESET
|
||||
#define SET_RESET_LOW() OUTB &= ~PIN_RESET
|
||||
#define SET_RESET_HIGH() (OUTB |= PIN_RESET)
|
||||
#define SET_RESET_LOW() (OUTB &= ~PIN_RESET)
|
||||
|
||||
#define SET_OCDSE_HIGH() OUTB |= PIN_OCDSE
|
||||
#define SET_OCDSE_LOW() OUTB &= ~PIN_OCDSE
|
||||
#define SET_OCDSE_HIGH() (OUTB |= PIN_OCDSE)
|
||||
#define SET_OCDSE_LOW() (OUTB &= ~PIN_OCDSE)
|
||||
|
||||
#define SET_BRKIN_HIGH() OUTB |= PIN_BRKIN
|
||||
#define SET_BRKIN_LOW() OUTB &= ~PIN_BRKIN
|
||||
#define SET_BRKIN_HIGH() (OUTB |= PIN_BRKIN)
|
||||
#define SET_BRKIN_LOW() (OUTB &= ~PIN_BRKIN)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define NOP {__asm nop __endasm;}
|
||||
#define NOP { __asm nop __endasm; }
|
||||
|
||||
void jtag_scan_in(uint8_t out_offset, uint8_t in_offset);
|
||||
void jtag_slow_scan_in(uint8_t out_offset, uint8_t in_offset);
|
||||
@@ -43,6 +43,6 @@ uint16_t jtag_get_signals(void);
|
||||
void jtag_set_signals(uint8_t low, uint8_t high);
|
||||
|
||||
void jtag_configure_tck_delay(uint8_t scan_in, uint8_t scan_out,
|
||||
uint8_t scan_io, uint8_t tck, uint8_t tms);
|
||||
uint8_t scan_io, uint8_t tck, uint8_t tms);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,9 +51,9 @@
|
||||
#define bmBit6 0x40
|
||||
#define bmBit7 0x80
|
||||
|
||||
/***************************************************************************/
|
||||
/************************ Special Function Registers ***********************/
|
||||
/***************************************************************************/
|
||||
/**************************************************************************
|
||||
************************ Special Function Registers **********************
|
||||
***************************************************************************/
|
||||
|
||||
/* See EZ-USB TRM, pp. A-9 - A-10 */
|
||||
|
||||
@@ -65,33 +65,33 @@ SFR(DPL2, 0x85);
|
||||
|
||||
SFR(DPS, 0x86);
|
||||
#define SEL bmBit0
|
||||
// Bit 1 read-only, always reads '0'
|
||||
// Bit 2 read-only, always reads '0'
|
||||
// Bit 3 read-only, always reads '0'
|
||||
// Bit 4 read-only, always reads '0'
|
||||
// Bit 5 read-only, always reads '0'
|
||||
// Bit 6 read-only, always reads '0'
|
||||
// Bit 7 read-only, always reads '0'
|
||||
/* Bit 1 read-only, always reads '0' */
|
||||
/* Bit 2 read-only, always reads '0' */
|
||||
/* Bit 3 read-only, always reads '0' */
|
||||
/* Bit 4 read-only, always reads '0' */
|
||||
/* Bit 5 read-only, always reads '0' */
|
||||
/* Bit 6 read-only, always reads '0' */
|
||||
/* Bit 7 read-only, always reads '0' */
|
||||
|
||||
SFR(PCON, 0x87);
|
||||
#define IDLE bmBit0
|
||||
#define STOP bmBit1
|
||||
#define GF0 bmBit2
|
||||
#define GF1 bmBit3
|
||||
// Bit 4 read-only, always reads '1'
|
||||
// Bit 5 read-only, always reads '1'
|
||||
// Bit 6 unused
|
||||
/* Bit 4 read-only, always reads '1' */
|
||||
/* Bit 5 read-only, always reads '1' */
|
||||
/* Bit 6 unused */
|
||||
#define SMOD0 bmBit7
|
||||
|
||||
SFR(TCON, 0x88);
|
||||
SBIT(IT0, 0x88, 0);
|
||||
SBIT(IE0, 0x88, 1);
|
||||
SBIT(IT1, 0x88, 2);
|
||||
SBIT(IE1, 0x88, 3);
|
||||
SBIT(TR0, 0x88, 4);
|
||||
SBIT(TF0, 0x88, 5);
|
||||
SBIT(TR1, 0x88, 6);
|
||||
SBIT(TF1, 0x88, 7);
|
||||
SBIT(IT0, 0x88, 0);
|
||||
SBIT(IE0, 0x88, 1);
|
||||
SBIT(IT1, 0x88, 2);
|
||||
SBIT(IE1, 0x88, 3);
|
||||
SBIT(TR0, 0x88, 4);
|
||||
SBIT(TF0, 0x88, 5);
|
||||
SBIT(TR1, 0x88, 6);
|
||||
SBIT(TF1, 0x88, 7);
|
||||
|
||||
SFR(TMOD, 0x89);
|
||||
/* Some bits in this register share the same name in the EZ-USB TRM. Therefore,
|
||||
@@ -117,24 +117,24 @@ SFR(CKCON, 0x8E);
|
||||
#define T0M bmBit3
|
||||
#define T1M bmBit4
|
||||
#define T2M bmBit5
|
||||
// Bit 6 unused
|
||||
// Bit 7 unused
|
||||
/* Bit 6 unused */
|
||||
/* Bit 7 unused */
|
||||
|
||||
SFR(SPC_FNC, 0x8D);
|
||||
#define bmWRS bmBit0
|
||||
// Bit 1 read-only, always reads '0'
|
||||
// Bit 2 read-only, always reads '0'
|
||||
// Bit 3 read-only, always reads '0'
|
||||
// Bit 4 read-only, always reads '0'
|
||||
// Bit 5 read-only, always reads '0'
|
||||
// Bit 6 read-only, always reads '0'
|
||||
// Bit 7 read-only, always reads '0'
|
||||
/* Bit 1 read-only, always reads '0' */
|
||||
/* Bit 2 read-only, always reads '0' */
|
||||
/* Bit 3 read-only, always reads '0' */
|
||||
/* Bit 4 read-only, always reads '0' */
|
||||
/* Bit 5 read-only, always reads '0' */
|
||||
/* Bit 6 read-only, always reads '0' */
|
||||
/* Bit 7 read-only, always reads '0' */
|
||||
|
||||
SFR(EXIF, 0x91);
|
||||
// Bit 0 read-only, always reads '0'
|
||||
// Bit 1 read-only, always reads '0'
|
||||
// Bit 2 read-only, always reads '0'
|
||||
// Bit 3 read-only, always reads '1'
|
||||
/* Bit 0 read-only, always reads '0' */
|
||||
/* Bit 1 read-only, always reads '0' */
|
||||
/* Bit 2 read-only, always reads '0' */
|
||||
/* Bit 3 read-only, always reads '1' */
|
||||
#define USBINT bmBit4
|
||||
#define I2CINT bmBit5
|
||||
#define IE4 bmBit6
|
||||
@@ -146,58 +146,58 @@ SFR(MPAGE, 0x92);
|
||||
SFR(_XPAGE, 0x92);
|
||||
|
||||
SFR(SCON0, 0x98);
|
||||
SBIT(RI_0, 0x98, 0);
|
||||
SBIT(TI_0, 0x98, 1);
|
||||
SBIT(RB8_0, 0x98, 2);
|
||||
SBIT(TB8_0, 0x98, 3);
|
||||
SBIT(REN_0, 0x98, 4);
|
||||
SBIT(SM2_0, 0x98, 5);
|
||||
SBIT(SM1_0, 0x98, 6);
|
||||
SBIT(SM0_0, 0x98, 7);
|
||||
SBIT(RI_0, 0x98, 0);
|
||||
SBIT(TI_0, 0x98, 1);
|
||||
SBIT(RB8_0, 0x98, 2);
|
||||
SBIT(TB8_0, 0x98, 3);
|
||||
SBIT(REN_0, 0x98, 4);
|
||||
SBIT(SM2_0, 0x98, 5);
|
||||
SBIT(SM1_0, 0x98, 6);
|
||||
SBIT(SM0_0, 0x98, 7);
|
||||
|
||||
SFR(SBUF0, 0x99);
|
||||
|
||||
SFR(IE, 0xA8);
|
||||
SBIT(EX0, 0xA8, 0);
|
||||
SBIT(ET0, 0xA8, 1);
|
||||
SBIT(EX1, 0xA8, 2);
|
||||
SBIT(ET1, 0xA8, 3);
|
||||
SBIT(ES0, 0xA8, 4);
|
||||
SBIT(ET2, 0xA8, 5);
|
||||
SBIT(ES1, 0xA8, 6);
|
||||
SBIT(EA, 0xA8, 7);
|
||||
SBIT(EX0, 0xA8, 0);
|
||||
SBIT(ET0, 0xA8, 1);
|
||||
SBIT(EX1, 0xA8, 2);
|
||||
SBIT(ET1, 0xA8, 3);
|
||||
SBIT(ES0, 0xA8, 4);
|
||||
SBIT(ET2, 0xA8, 5);
|
||||
SBIT(ES1, 0xA8, 6);
|
||||
SBIT(EA, 0xA8, 7);
|
||||
|
||||
SFR(IP, 0xB8);
|
||||
SBIT(PX0, 0xB8, 0);
|
||||
SBIT(PT0, 0xB8, 1);
|
||||
SBIT(PX1, 0xB8, 2);
|
||||
SBIT(PT1, 0xB8, 3);
|
||||
SBIT(PS0, 0xB8, 4);
|
||||
SBIT(PT2, 0xB8, 5);
|
||||
SBIT(PS1, 0xB8, 6);
|
||||
// Bit 7 read-only, always reads '1'
|
||||
SBIT(PX0, 0xB8, 0);
|
||||
SBIT(PT0, 0xB8, 1);
|
||||
SBIT(PX1, 0xB8, 2);
|
||||
SBIT(PT1, 0xB8, 3);
|
||||
SBIT(PS0, 0xB8, 4);
|
||||
SBIT(PT2, 0xB8, 5);
|
||||
SBIT(PS1, 0xB8, 6);
|
||||
/* Bit 7 read-only, always reads '1' */
|
||||
|
||||
SFR(SCON1, 0xC0);
|
||||
SBIT(RI_1, 0xC0, 0);
|
||||
SBIT(TI_1, 0xC0, 1);
|
||||
SBIT(RB8_1, 0xC0, 2);
|
||||
SBIT(TB8_1, 0xC0, 3);
|
||||
SBIT(REN_1, 0xC0, 4);
|
||||
SBIT(SM2_1, 0xC0, 5);
|
||||
SBIT(SM1_1, 0xC0, 6);
|
||||
SBIT(SM0_1, 0xC0, 7);
|
||||
SBIT(RI_1, 0xC0, 0);
|
||||
SBIT(TI_1, 0xC0, 1);
|
||||
SBIT(RB8_1, 0xC0, 2);
|
||||
SBIT(TB8_1, 0xC0, 3);
|
||||
SBIT(REN_1, 0xC0, 4);
|
||||
SBIT(SM2_1, 0xC0, 5);
|
||||
SBIT(SM1_1, 0xC0, 6);
|
||||
SBIT(SM0_1, 0xC0, 7);
|
||||
|
||||
SFR(SBUF1, 0xC1);
|
||||
|
||||
SFR(T2CON, 0xC8);
|
||||
SBIT(CPRL2, 0xC8, 0);
|
||||
SBIT(CT2, 0xC8, 1);
|
||||
SBIT(TR2, 0xC8, 2);
|
||||
SBIT(EXEN2, 0xC8, 3);
|
||||
SBIT(TCLK, 0xC8, 4);
|
||||
SBIT(RCLK, 0xC8, 5);
|
||||
SBIT(EXF2, 0xC8, 6);
|
||||
SBIT(TF2, 0xC8, 7);
|
||||
SBIT(CPRL2, 0xC8, 0);
|
||||
SBIT(CT2, 0xC8, 1);
|
||||
SBIT(TR2, 0xC8, 2);
|
||||
SBIT(EXEN2, 0xC8, 3);
|
||||
SBIT(TCLK, 0xC8, 4);
|
||||
SBIT(RCLK, 0xC8, 5);
|
||||
SBIT(EXF2, 0xC8, 6);
|
||||
SBIT(TF2, 0xC8, 7);
|
||||
|
||||
SFR(RCAP2L, 0xCA);
|
||||
SFR(RCAP2H, 0xCB);
|
||||
@@ -205,52 +205,52 @@ SFR(TL2, 0xCC);
|
||||
SFR(TH2, 0xCD);
|
||||
|
||||
SFR(PSW, 0xD0);
|
||||
SBIT(P, 0xD0, 0);
|
||||
SBIT(F1, 0xD0, 1);
|
||||
SBIT(OV, 0xD0, 2);
|
||||
SBIT(RS0, 0xD0, 3);
|
||||
SBIT(RS1, 0xD0, 4);
|
||||
SBIT(F0, 0xD0, 5);
|
||||
SBIT(AC, 0xD0, 6);
|
||||
SBIT(CY, 0xD0, 7);
|
||||
SBIT(P, 0xD0, 0);
|
||||
SBIT(F1, 0xD0, 1);
|
||||
SBIT(OV, 0xD0, 2);
|
||||
SBIT(RS0, 0xD0, 3);
|
||||
SBIT(RS1, 0xD0, 4);
|
||||
SBIT(F0, 0xD0, 5);
|
||||
SBIT(AC, 0xD0, 6);
|
||||
SBIT(CY, 0xD0, 7);
|
||||
|
||||
SFR(EICON, 0xD8);
|
||||
// Bit 0 read-only, always reads '0'
|
||||
// Bit 1 read-only, always reads '0'
|
||||
// Bit 2 read-only, always reads '0'
|
||||
SBIT(INT6, 0xD8, 3);
|
||||
SBIT(RESI, 0xD8, 4);
|
||||
SBIT(ERESI, 0xD8, 5);
|
||||
// Bit 6 read-only, always reads '1'
|
||||
SBIT(SMOD1, 0xD8, 7);
|
||||
/* Bit 0 read-only, always reads '0' */
|
||||
/* Bit 1 read-only, always reads '0' */
|
||||
/* Bit 2 read-only, always reads '0' */
|
||||
SBIT(INT6, 0xD8, 3);
|
||||
SBIT(RESI, 0xD8, 4);
|
||||
SBIT(ERESI, 0xD8, 5);
|
||||
/* Bit 6 read-only, always reads '1' */
|
||||
SBIT(SMOD1, 0xD8, 7);
|
||||
|
||||
SFR(ACC, 0xE0);
|
||||
|
||||
SFR(EIE, 0xE8);
|
||||
SBIT(EUSB, 0xE8, 0);
|
||||
SBIT(EI2C, 0xE8, 1);
|
||||
SBIT(EX4, 0xE8, 2);
|
||||
SBIT(EX5, 0xE8, 3);
|
||||
SBIT(EWDI, 0xE8, 4);
|
||||
// Bit 5 read-only, always reads '1'
|
||||
// Bit 6 read-only, always reads '1'
|
||||
// Bit 7 read-only, always reads '1'
|
||||
SBIT(EUSB, 0xE8, 0);
|
||||
SBIT(EI2C, 0xE8, 1);
|
||||
SBIT(EX4, 0xE8, 2);
|
||||
SBIT(EX5, 0xE8, 3);
|
||||
SBIT(EWDI, 0xE8, 4);
|
||||
/* Bit 5 read-only, always reads '1' */
|
||||
/* Bit 6 read-only, always reads '1' */
|
||||
/* Bit 7 read-only, always reads '1' */
|
||||
|
||||
SFR(B, 0xF0);
|
||||
|
||||
SFR(EIP, 0xF8);
|
||||
SBIT(PUSB, 0xF8, 0);
|
||||
SBIT(PI2C, 0xF8, 1);
|
||||
SBIT(PX4, 0xF8, 2);
|
||||
SBIT(PX5, 0xF8, 3);
|
||||
SBIT(PX6, 0xF8, 4);
|
||||
// Bit 5 read-only, always reads '1'
|
||||
// Bit 6 read-only, always reads '1'
|
||||
// Bit 7 read-only, always reads '1'
|
||||
SBIT(PUSB, 0xF8, 0);
|
||||
SBIT(PI2C, 0xF8, 1);
|
||||
SBIT(PX4, 0xF8, 2);
|
||||
SBIT(PX5, 0xF8, 3);
|
||||
SBIT(PX6, 0xF8, 4);
|
||||
/* Bit 5 read-only, always reads '1' */
|
||||
/* Bit 6 read-only, always reads '1' */
|
||||
/* Bit 7 read-only, always reads '1' */
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************** XDATA Registers *****************************/
|
||||
/***************************************************************************/
|
||||
/**************************************************************************
|
||||
***************************** XDATA Registers ****************************
|
||||
***************************************************************************/
|
||||
|
||||
/************************ Endpoint 0-7 Data Buffers ************************/
|
||||
SFRX(OUT7BUF[64], 0x7B40);
|
||||
@@ -269,7 +269,7 @@ SFRX(OUT1BUF[64], 0x7E40);
|
||||
SFRX(IN1BUF[64], 0x7E80);
|
||||
SFRX(OUT0BUF[64], 0x7EC0);
|
||||
SFRX(IN0BUF[64], 0x7F00);
|
||||
// 0x7F40 - 0x7F5F reserved
|
||||
/* 0x7F40 - 0x7F5F reserved */
|
||||
|
||||
/**************************** Isochronous Data *****************************/
|
||||
SFRX(OUT8DATA, 0x7F60);
|
||||
@@ -312,9 +312,9 @@ SFRX(OUT16BCL, 0x7F7F);
|
||||
SFRX(CPUCS, 0x7F92);
|
||||
#define RES8051 bmBit0
|
||||
#define CLK24OE bmBit1
|
||||
// Bit 2 read-only, always reads '0'
|
||||
// Bit 3 read-only, always reads '0'
|
||||
// Bits 4...7: Chip Revision
|
||||
/* Bit 2 read-only, always reads '0' */
|
||||
/* Bit 3 read-only, always reads '0' */
|
||||
/* Bits 4...7: Chip Revision */
|
||||
|
||||
SFRX(PORTACFG, 0x7F93);
|
||||
#define T0OUT bmBit0
|
||||
@@ -437,7 +437,7 @@ SFRX(OEC, 0x7F9E);
|
||||
#define OEC6 bmBit6
|
||||
#define OEC7 bmBit7
|
||||
|
||||
// 0x7F9F reserved
|
||||
/* 0x7F9F reserved */
|
||||
|
||||
/****************** Isochronous Control/Status Registers *******************/
|
||||
SFRX(ISOERR, 0x7FA0);
|
||||
@@ -455,10 +455,10 @@ SFRX(ISOCTL, 0x7FA1);
|
||||
#define MBZ0 bmBit1
|
||||
#define MBZ1 bmBit2
|
||||
#define PPSTAT bmBit3
|
||||
// Bit 4 unused
|
||||
// Bit 5 unused
|
||||
// Bit 6 unused
|
||||
// Bit 7 unused
|
||||
/* Bit 4 unused */
|
||||
/* Bit 5 unused */
|
||||
/* Bit 6 unused */
|
||||
/* Bit 7 unused */
|
||||
|
||||
SFRX(ZBCOUT, 0x7FA2);
|
||||
#define EP8 bmBit0
|
||||
@@ -470,8 +470,8 @@ SFRX(ZBCOUT, 0x7FA2);
|
||||
#define EP14 bmBit6
|
||||
#define EP15 bmBit7
|
||||
|
||||
// 0x7FA3 reserved
|
||||
// 0x7FA4 reserved
|
||||
/* 0x7FA3 reserved */
|
||||
/* 0x7FA4 reserved */
|
||||
|
||||
/****************************** I2C Registers ******************************/
|
||||
SFRX(I2CS, 0x7FA5);
|
||||
@@ -485,18 +485,18 @@ SFRX(I2CS, 0x7FA5);
|
||||
#define I2C_START bmBit7
|
||||
|
||||
SFRX(I2DAT, 0x7FA6);
|
||||
// 0x7FA7 reserved
|
||||
/* 0x7FA7 reserved */
|
||||
|
||||
/******************************* Interrupts ********************************/
|
||||
SFRX(IVEC, 0x7FA8);
|
||||
// Bit 0 read-only, always reads '0'
|
||||
// Bit 1 read-only, always reads '0'
|
||||
/* Bit 0 read-only, always reads '0' */
|
||||
/* Bit 1 read-only, always reads '0' */
|
||||
#define IV0 bmBit2
|
||||
#define IV1 bmBit3
|
||||
#define IV2 bmBit4
|
||||
#define IV3 bmBit5
|
||||
#define IV4 bmBit6
|
||||
// Bit 7 read-only, always reads '0'
|
||||
/* Bit 7 read-only, always reads '0' */
|
||||
|
||||
SFRX(IN07IRQ, 0x7FA9);
|
||||
#define IN0IR bmBit0
|
||||
@@ -524,9 +524,9 @@ SFRX(USBIRQ, 0x7FAB);
|
||||
#define SUTOKIR bmBit2
|
||||
#define SUSPIR bmBit3
|
||||
#define URESIR bmBit4
|
||||
// Bit 5 unused
|
||||
// Bit 6 unused
|
||||
// Bit 7 unused
|
||||
/* Bit 5 unused */
|
||||
/* Bit 6 unused */
|
||||
/* Bit 7 unused */
|
||||
|
||||
SFRX(IN07IEN, 0x7FAC);
|
||||
#define IN0IEN bmBit0
|
||||
@@ -554,22 +554,22 @@ SFRX(USBIEN, 0x7FAE);
|
||||
#define SUTOKIE bmBit2
|
||||
#define SUSPIE bmBit3
|
||||
#define URESIE bmBit4
|
||||
// Bit 5 unused
|
||||
// Bit 6 unused
|
||||
// Bit 7 unused
|
||||
/* Bit 5 unused */
|
||||
/* Bit 6 unused */
|
||||
/* Bit 7 unused */
|
||||
|
||||
SFRX(USBBAV, 0x7FAF);
|
||||
#define AVEN bmBit0
|
||||
#define BPEN bmBit1
|
||||
#define BPPULSE bmBit2
|
||||
#define BREAK bmBit3
|
||||
// Bit 4 unused
|
||||
// Bit 5 unused
|
||||
// Bit 6 unused
|
||||
// Bit 7 unused
|
||||
/* Bit 4 unused */
|
||||
/* Bit 5 unused */
|
||||
/* Bit 6 unused */
|
||||
/* Bit 7 unused */
|
||||
|
||||
// 0x7FB0 reserved
|
||||
// 0x7FB1 reserved
|
||||
/* 0x7FB0 reserved */
|
||||
/* 0x7FB1 reserved */
|
||||
SFRX(BPADDRH, 0x7FB2);
|
||||
SFRX(BPADDRL, 0x7FB3);
|
||||
|
||||
@@ -579,10 +579,10 @@ SFRX(EP0CS, 0x7FB4);
|
||||
#define HSNAK bmBit1
|
||||
#define IN0BSY bmBit2
|
||||
#define OUT0BSY bmBit3
|
||||
// Bit 4 unused
|
||||
// Bit 5 unused
|
||||
// Bit 6 unused
|
||||
// Bit 7 unused
|
||||
/* Bit 4 unused */
|
||||
/* Bit 5 unused */
|
||||
/* Bit 6 unused */
|
||||
/* Bit 7 unused */
|
||||
|
||||
SFRX(IN0BC, 0x7FB5);
|
||||
SFRX(IN1CS, 0x7FB6);
|
||||
@@ -599,7 +599,7 @@ SFRX(IN6CS, 0x7FC0);
|
||||
SFRX(IN6BC, 0x7FC1);
|
||||
SFRX(IN7CS, 0x7FC2);
|
||||
SFRX(IN7BC, 0x7FC3);
|
||||
// 0x7FC4 reserved
|
||||
/* 0x7FC4 reserved */
|
||||
SFRX(OUT0BC, 0x7FC5);
|
||||
SFRX(OUT1CS, 0x7FC6);
|
||||
SFRX(OUT1BC, 0x7FC7);
|
||||
@@ -630,16 +630,16 @@ SFRX(USBCS, 0x7FD6);
|
||||
#define RENUM bmBit1
|
||||
#define DISCOE bmBit2
|
||||
#define DISCON bmBit3
|
||||
// Bit 4 unused
|
||||
// Bit 5 unused
|
||||
// Bit 6 unused
|
||||
/* Bit 4 unused */
|
||||
/* Bit 5 unused */
|
||||
/* Bit 6 unused */
|
||||
#define WAKESRC bmBit7
|
||||
|
||||
SFRX(TOGCTL, 0x7FD7);
|
||||
#define TOG_EP0 bmBit0
|
||||
#define TOG_EP1 bmBit1
|
||||
#define TOG_EP2 bmBit2
|
||||
// Bit 3 is read-only, always reads '0'
|
||||
/* Bit 3 is read-only, always reads '0' */
|
||||
#define TOG_IO bmBit4
|
||||
#define TOG_R bmBit5
|
||||
#define TOG_S bmBit6
|
||||
@@ -647,9 +647,9 @@ SFRX(TOGCTL, 0x7FD7);
|
||||
|
||||
SFRX(USBFRAMEL, 0x7FD8);
|
||||
SFRX(USBFRAMEH, 0x7FD9);
|
||||
// 0x7FDA reserved
|
||||
/* 0x7FDA reserved */
|
||||
SFRX(FNADDR, 0x7FDB);
|
||||
// 0x7FDC reserved
|
||||
/* 0x7FDC reserved */
|
||||
|
||||
SFRX(USBPAIR, 0x7FDD);
|
||||
#define PR2IN bmBit0
|
||||
@@ -658,11 +658,11 @@ SFRX(USBPAIR, 0x7FDD);
|
||||
#define PR2OUT bmBit3
|
||||
#define PR4OUT bmBit4
|
||||
#define PR6OUT bmBit5
|
||||
// Bit 6 unused
|
||||
/* Bit 6 unused */
|
||||
#define ISOSEND0 bmBit7
|
||||
|
||||
SFRX(IN07VAL, 0x7FDE);
|
||||
// Bit 0 is read-only, always reads '1'
|
||||
/* Bit 0 is read-only, always reads '1' */
|
||||
#define IN1VAL bmBit1
|
||||
#define IN2VAL bmBit2
|
||||
#define IN3VAL bmBit3
|
||||
@@ -672,7 +672,7 @@ SFRX(IN07VAL, 0x7FDE);
|
||||
#define IN7VAL bmBit7
|
||||
|
||||
SFRX(OUT07VAL, 0x7FDF);
|
||||
// Bit 0 is read-only, always reads '1'
|
||||
/* Bit 0 is read-only, always reads '1' */
|
||||
#define OUT1VAL bmBit1
|
||||
#define OUT2VAL bmBit2
|
||||
#define OUT3VAL bmBit3
|
||||
@@ -714,8 +714,8 @@ SFRX(FASTXFR, 0x7FE2);
|
||||
SFRX(AUTOPTRH, 0x7FE3);
|
||||
SFRX(AUTOPTRL, 0x7FE4);
|
||||
SFRX(AUTODATA, 0x7FE5);
|
||||
// 0x7FE6 reserved
|
||||
// 0x7FE7 reserved
|
||||
/* 0x7FE6 reserved */
|
||||
/* 0x7FE7 reserved */
|
||||
|
||||
/******************************* Setup Data ********************************/
|
||||
SFRX(SETUPDAT[8], 0x7FE8);
|
||||
|
||||
@@ -26,15 +26,15 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define NULL (void*)0;
|
||||
#define NULL (void *)0;
|
||||
|
||||
/* High and Low byte of a word (uint16_t) */
|
||||
#define HI8(word) (uint8_t)(((uint16_t)word >> 8) & 0xff)
|
||||
#define LO8(word) (uint8_t)((uint16_t)word & 0xff)
|
||||
|
||||
/* Convenience functions */
|
||||
#define STALL_EP0() EP0CS |= EP0STALL
|
||||
#define CLEAR_IRQ() EXIF &= ~USBINT
|
||||
#define STALL_EP0() (EP0CS |= EP0STALL)
|
||||
#define CLEAR_IRQ() (EXIF &= ~USBINT)
|
||||
|
||||
/*********** USB descriptors. See section 9.5 of the USB 1.1 spec **********/
|
||||
|
||||
@@ -45,84 +45,84 @@
|
||||
#define DESCRIPTOR_TYPE_INTERFACE 0x04
|
||||
#define DESCRIPTOR_TYPE_ENDPOINT 0x05
|
||||
|
||||
#define STR_DESCR(len,...) { len*2+2, DESCRIPTOR_TYPE_STRING, { __VA_ARGS__ } }
|
||||
#define STR_DESCR(len, ...) { len * 2 + 2, DESCRIPTOR_TYPE_STRING, { __VA_ARGS__ } }
|
||||
|
||||
/** USB Device Descriptor. See USB 1.1 spec, pp. 196 - 198 */
|
||||
struct usb_device_descriptor {
|
||||
uint8_t bLength; ///< Size of this descriptor in bytes.
|
||||
uint8_t bDescriptorType; ///< DEVICE Descriptor Type.
|
||||
uint16_t bcdUSB; ///< USB specification release number (BCD).
|
||||
uint8_t bDeviceClass; ///< Class code.
|
||||
uint8_t bDeviceSubClass; ///< Subclass code.
|
||||
uint8_t bDeviceProtocol; ///< Protocol code.
|
||||
uint8_t bMaxPacketSize0; ///< Maximum packet size for EP0 (8, 16, 32, 64).
|
||||
uint16_t idVendor; ///< USB Vendor ID.
|
||||
uint16_t idProduct; ///< USB Product ID.
|
||||
uint16_t bcdDevice; ///< Device Release Number (BCD).
|
||||
uint8_t iManufacturer; ///< Index of manufacturer string descriptor.
|
||||
uint8_t iProduct; ///< Index of product string descriptor.
|
||||
uint8_t iSerialNumber; ///< Index of string descriptor containing serial #.
|
||||
uint8_t bNumConfigurations; ///< Number of possible configurations.
|
||||
uint8_t bLength; /* /< Size of this descriptor in bytes. */
|
||||
uint8_t bDescriptorType;/* /< DEVICE Descriptor Type. */
|
||||
uint16_t bcdUSB; /* /< USB specification release number (BCD). */
|
||||
uint8_t bDeviceClass; /* /< Class code. */
|
||||
uint8_t bDeviceSubClass;/* /< Subclass code. */
|
||||
uint8_t bDeviceProtocol;/* /< Protocol code. */
|
||||
uint8_t bMaxPacketSize0;/* /< Maximum packet size for EP0 (8, 16, 32, 64). */
|
||||
uint16_t idVendor; /* /< USB Vendor ID. */
|
||||
uint16_t idProduct; /* /< USB Product ID. */
|
||||
uint16_t bcdDevice; /* /< Device Release Number (BCD). */
|
||||
uint8_t iManufacturer; /* /< Index of manufacturer string descriptor. */
|
||||
uint8_t iProduct; /* /< Index of product string descriptor. */
|
||||
uint8_t iSerialNumber; /* /< Index of string descriptor containing serial #. */
|
||||
uint8_t bNumConfigurations; /* /< Number of possible configurations. */
|
||||
};
|
||||
|
||||
/** USB Configuration Descriptor. See USB 1.1 spec, pp. 199 - 200 */
|
||||
struct usb_config_descriptor {
|
||||
uint8_t bLength; ///< Size of this descriptor in bytes.
|
||||
uint8_t bDescriptorType; ///< CONFIGURATION descriptor type.
|
||||
uint16_t wTotalLength; ///< Combined total length of all descriptors.
|
||||
uint8_t bNumInterfaces; ///< Number of interfaces in this configuration.
|
||||
uint8_t bConfigurationValue;///< Value used to select this configuration.
|
||||
uint8_t iConfiguration; ///< Index of configuration string descriptor.
|
||||
uint8_t bmAttributes; ///< Configuration characteristics.
|
||||
uint8_t MaxPower; ///< Maximum power consumption in 2 mA units.
|
||||
uint8_t bLength; /* /< Size of this descriptor in bytes. */
|
||||
uint8_t bDescriptorType;/* /< CONFIGURATION descriptor type. */
|
||||
uint16_t wTotalLength; /* /< Combined total length of all descriptors. */
|
||||
uint8_t bNumInterfaces; /* /< Number of interfaces in this configuration. */
|
||||
uint8_t bConfigurationValue; /* /< Value used to select this configuration. */
|
||||
uint8_t iConfiguration; /* /< Index of configuration string descriptor. */
|
||||
uint8_t bmAttributes; /* /< Configuration characteristics. */
|
||||
uint8_t MaxPower; /* /< Maximum power consumption in 2 mA units. */
|
||||
};
|
||||
|
||||
/** USB Interface Descriptor. See USB 1.1 spec, pp. 201 - 203 */
|
||||
struct usb_interface_descriptor {
|
||||
uint8_t bLength; ///< Size of this descriptor in bytes.
|
||||
uint8_t bDescriptorType; ///< INTERFACE descriptor type.
|
||||
uint8_t bInterfaceNumber; ///< Interface number.
|
||||
uint8_t bAlternateSetting; ///< Value used to select alternate setting.
|
||||
uint8_t bNumEndpoints; ///< Number of endpoints used by this interface.
|
||||
uint8_t bInterfaceClass; ///< Class code.
|
||||
uint8_t bInterfaceSubclass; ///< Subclass code.
|
||||
uint8_t bInterfaceProtocol; ///< Protocol code.
|
||||
uint8_t iInterface; ///< Index of interface string descriptor.
|
||||
uint8_t bLength; /* /< Size of this descriptor in bytes. */
|
||||
uint8_t bDescriptorType;/* /< INTERFACE descriptor type. */
|
||||
uint8_t bInterfaceNumber; /* /< Interface number. */
|
||||
uint8_t bAlternateSetting; /* /< Value used to select alternate setting. */
|
||||
uint8_t bNumEndpoints; /* /< Number of endpoints used by this interface. */
|
||||
uint8_t bInterfaceClass;/* /< Class code. */
|
||||
uint8_t bInterfaceSubclass; /* /< Subclass code. */
|
||||
uint8_t bInterfaceProtocol; /* /< Protocol code. */
|
||||
uint8_t iInterface; /* /< Index of interface string descriptor. */
|
||||
};
|
||||
|
||||
/** USB Endpoint Descriptor. See USB 1.1 spec, pp. 203 - 204 */
|
||||
struct usb_endpoint_descriptor {
|
||||
uint8_t bLength; ///< Size of this descriptor in bytes.
|
||||
uint8_t bDescriptorType; ///< ENDPOINT descriptor type.
|
||||
uint8_t bEndpointAddress; ///< Endpoint Address: USB 1.1 spec, table 9-10.
|
||||
uint8_t bmAttributes; ///< Endpoint Attributes: USB 1.1 spec, table 9-10.
|
||||
uint16_t wMaxPacketSize; ///< Maximum packet size for this endpoint.
|
||||
uint8_t bInterval; ///< Polling interval (in ms) for this endpoint.
|
||||
uint8_t bLength; /* /< Size of this descriptor in bytes. */
|
||||
uint8_t bDescriptorType;/* /< ENDPOINT descriptor type. */
|
||||
uint8_t bEndpointAddress; /* /< Endpoint Address: USB 1.1 spec, table 9-10. */
|
||||
uint8_t bmAttributes; /* /< Endpoint Attributes: USB 1.1 spec, table 9-10. */
|
||||
uint16_t wMaxPacketSize;/* /< Maximum packet size for this endpoint. */
|
||||
uint8_t bInterval; /* /< Polling interval (in ms) for this endpoint. */
|
||||
};
|
||||
|
||||
/** USB Language Descriptor. See USB 1.1 spec, pp. 204 - 205 */
|
||||
struct usb_language_descriptor {
|
||||
uint8_t bLength; ///< Size of this descriptor in bytes.
|
||||
uint8_t bDescriptorType; ///< STRING descriptor type.
|
||||
uint16_t wLANGID[]; ///< LANGID codes.
|
||||
uint8_t bLength; /* /< Size of this descriptor in bytes. */
|
||||
uint8_t bDescriptorType;/* /< STRING descriptor type. */
|
||||
uint16_t wLANGID[]; /* /< LANGID codes. */
|
||||
};
|
||||
|
||||
/** USB String Descriptor. See USB 1.1 spec, pp. 204 - 205 */
|
||||
struct usb_string_descriptor {
|
||||
uint8_t bLength; ///< Size of this descriptor in bytes.
|
||||
uint8_t bDescriptorType; ///< STRING descriptor type.
|
||||
uint16_t bString[]; ///< UNICODE encoded string.
|
||||
uint8_t bLength; /* /< Size of this descriptor in bytes. */
|
||||
uint8_t bDescriptorType;/* /< STRING descriptor type. */
|
||||
uint16_t bString[]; /* /< UNICODE encoded string. */
|
||||
};
|
||||
|
||||
/********************** USB Control Endpoint 0 related *********************/
|
||||
|
||||
/** USB Control Setup Data. See USB 1.1 spec, pp. 183 - 185 */
|
||||
struct setup_data {
|
||||
uint8_t bmRequestType; ///< Characteristics of a request.
|
||||
uint8_t bRequest; ///< Specific request.
|
||||
uint16_t wValue; ///< Field that varies according to request.
|
||||
uint16_t wIndex; ///< Field that varies according to request.
|
||||
uint16_t wLength; ///< Number of bytes to transfer in data stage.
|
||||
uint8_t bmRequestType; /* /< Characteristics of a request. */
|
||||
uint8_t bRequest; /* /< Specific request. */
|
||||
uint16_t wValue; /* /< Field that varies according to request. */
|
||||
uint16_t wIndex; /* /< Field that varies according to request. */
|
||||
uint16_t wLength; /* /< Number of bytes to transfer in data stage. */
|
||||
};
|
||||
|
||||
/* External declarations for variables that need to be accessed outside of
|
||||
@@ -206,9 +206,9 @@ extern volatile __xdata __at 0x7FE8 struct setup_data setup_data;
|
||||
/* USB Requests (bRequest): See USB 1.1 spec, table 9-4 on page 187 */
|
||||
#define GET_STATUS 0
|
||||
#define CLEAR_FEATURE 1
|
||||
// Value '2' is reserved for future use
|
||||
/* Value '2' is reserved for future use */
|
||||
#define SET_FEATURE 3
|
||||
// Value '4' is reserved for future use
|
||||
/* Value '4' is reserved for future use */
|
||||
#define SET_ADDRESS 5
|
||||
#define GET_DESCRIPTOR 6
|
||||
#define SET_DESCRIPTOR 7
|
||||
@@ -226,33 +226,33 @@ extern volatile __xdata __at 0x7FE8 struct setup_data setup_data;
|
||||
|
||||
/** USB Interrupts. See AN2131-TRM, page 9-4 for details */
|
||||
enum usb_isr {
|
||||
SUDAV_ISR = 13,
|
||||
SOF_ISR,
|
||||
SUTOK_ISR,
|
||||
SUSPEND_ISR,
|
||||
USBRESET_ISR,
|
||||
IBN_ISR,
|
||||
EP0IN_ISR,
|
||||
EP0OUT_ISR,
|
||||
EP1IN_ISR,
|
||||
EP1OUT_ISR,
|
||||
EP2IN_ISR,
|
||||
EP2OUT_ISR,
|
||||
EP3IN_ISR,
|
||||
EP3OUT_ISR,
|
||||
EP4IN_ISR,
|
||||
EP4OUT_ISR,
|
||||
EP5IN_ISR,
|
||||
EP5OUT_ISR,
|
||||
EP6IN_ISR,
|
||||
EP6OUT_ISR,
|
||||
EP7IN_ISR,
|
||||
EP7OUT_ISR
|
||||
SUDAV_ISR = 13,
|
||||
SOF_ISR,
|
||||
SUTOK_ISR,
|
||||
SUSPEND_ISR,
|
||||
USBRESET_ISR,
|
||||
IBN_ISR,
|
||||
EP0IN_ISR,
|
||||
EP0OUT_ISR,
|
||||
EP1IN_ISR,
|
||||
EP1OUT_ISR,
|
||||
EP2IN_ISR,
|
||||
EP2OUT_ISR,
|
||||
EP3IN_ISR,
|
||||
EP3OUT_ISR,
|
||||
EP4IN_ISR,
|
||||
EP4OUT_ISR,
|
||||
EP5IN_ISR,
|
||||
EP5OUT_ISR,
|
||||
EP6IN_ISR,
|
||||
EP6OUT_ISR,
|
||||
EP7IN_ISR,
|
||||
EP7OUT_ISR
|
||||
};
|
||||
|
||||
/*************************** Function Prototypes ***************************/
|
||||
|
||||
__xdata uint8_t* usb_get_endpoint_cs_reg(uint8_t ep);
|
||||
__xdata uint8_t *usb_get_endpoint_cs_reg(uint8_t ep);
|
||||
void usb_reset_data_toggle(uint8_t ep);
|
||||
|
||||
bool usb_handle_get_status(void);
|
||||
|
||||
@@ -22,30 +22,30 @@
|
||||
|
||||
void delay_5us(void)
|
||||
{
|
||||
NOP;
|
||||
NOP;
|
||||
}
|
||||
|
||||
void delay_1ms(void) {
|
||||
uint16_t i;
|
||||
void delay_1ms(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for (i = 0; i < 598; i++);
|
||||
for (i = 0; i < 598; i++)
|
||||
;
|
||||
}
|
||||
|
||||
void delay_us(uint16_t delay)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t maxcount = (delay / 5);
|
||||
uint16_t i;
|
||||
uint16_t maxcount = (delay / 5);
|
||||
|
||||
for (i = 0; i < maxcount; i++) {
|
||||
delay_5us();
|
||||
}
|
||||
for (i = 0; i < maxcount; i++)
|
||||
delay_5us();
|
||||
}
|
||||
|
||||
void delay_ms(uint16_t delay)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t i;
|
||||
|
||||
for (i = 0; i < delay; i++) {
|
||||
delay_1ms();
|
||||
}
|
||||
for (i = 0; i < delay; i++)
|
||||
delay_1ms();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -49,43 +49,43 @@ extern void ep7out_isr(void) __interrupt;
|
||||
|
||||
void io_init(void)
|
||||
{
|
||||
/* PORTxCFG register bits select alternate functions (1 == alternate function,
|
||||
* 0 == standard I/O)
|
||||
* OEx register bits turn on/off output buffer (1 == output, 0 == input)
|
||||
* OUTx register bits determine pin state of output
|
||||
* PINx register bits reflect pin state (high == 1, low == 0) */
|
||||
/* PORTxCFG register bits select alternate functions (1 == alternate function,
|
||||
* 0 == standard I/O)
|
||||
* OEx register bits turn on/off output buffer (1 == output, 0 == input)
|
||||
* OUTx register bits determine pin state of output
|
||||
* PINx register bits reflect pin state (high == 1, low == 0) */
|
||||
|
||||
/* PORT A */
|
||||
PORTACFG = PIN_OE;
|
||||
OEA = PIN_U_OE | PIN_OE | PIN_RUN_LED | PIN_COM_LED;
|
||||
OUTA = PIN_RUN_LED | PIN_COM_LED;
|
||||
/* PORT A */
|
||||
PORTACFG = PIN_OE;
|
||||
OEA = PIN_U_OE | PIN_OE | PIN_RUN_LED | PIN_COM_LED;
|
||||
OUTA = PIN_RUN_LED | PIN_COM_LED;
|
||||
|
||||
/* PORT B */
|
||||
PORTBCFG = 0x00;
|
||||
OEB = PIN_TDI | PIN_TMS | PIN_TCK | PIN_TRST | PIN_BRKIN | PIN_RESET
|
||||
| PIN_OCDSE;
|
||||
/* PORT B */
|
||||
PORTBCFG = 0x00;
|
||||
OEB = PIN_TDI | PIN_TMS | PIN_TCK | PIN_TRST | PIN_BRKIN | PIN_RESET
|
||||
| PIN_OCDSE;
|
||||
|
||||
/* TRST and RESET signals are low-active but inverted by hardware, so we clear
|
||||
* these signals here! */
|
||||
OUTB = 0x00;
|
||||
/* TRST and RESET signals are low-active but inverted by hardware, so we clear
|
||||
* these signals here! */
|
||||
OUTB = 0x00;
|
||||
|
||||
/* PORT C */
|
||||
PORTCCFG = PIN_WR;
|
||||
OEC = PIN_TXD0 | PIN_WR;
|
||||
OUTC = 0x00;
|
||||
/* PORT C */
|
||||
PORTCCFG = PIN_WR;
|
||||
OEC = PIN_TXD0 | PIN_WR;
|
||||
OUTC = 0x00;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
io_init();
|
||||
usb_init();
|
||||
io_init();
|
||||
usb_init();
|
||||
|
||||
/* Enable Interrupts */
|
||||
EA = 1;
|
||||
/* Enable Interrupts */
|
||||
EA = 1;
|
||||
|
||||
/* Begin executing command(s). This function never returns. */
|
||||
command_loop();
|
||||
/* Begin executing command(s). This function never returns. */
|
||||
command_loop();
|
||||
|
||||
/* Never reached, but SDCC complains about missing return statement */
|
||||
return 0;
|
||||
/* Never reached, but SDCC complains about missing return statement */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
* are configured to use the maximum packet size for full-speed transfers,
|
||||
* 64 bytes. Commands always start with a command ID (see msgtypes.h for
|
||||
* command ID definitions) and contain zero or more payload data bytes in both
|
||||
* transfer directions (IN and OUT). The payload
|
||||
* transfer directions (IN and OUT). The payload
|
||||
*
|
||||
* Almost all commands contain a fixed number of payload data bytes. The number
|
||||
* of payload data bytes for the IN and OUT direction does not need to be the
|
||||
* same.
|
||||
*
|
||||
*
|
||||
* Multiple commands may be sent in one EP2 Bulk-OUT packet. Because the
|
||||
* OpenULINK firmware does not perform bounds checking for EP2 Bulk-IN packets,
|
||||
* the host MUST ensure that the commands sent in the OUT packet require a
|
||||
@@ -57,23 +57,19 @@ volatile uint8_t payload_index_in;
|
||||
*/
|
||||
void execute_set_led_command(void)
|
||||
{
|
||||
uint8_t led_state = OUT2BUF[cmd_id_index + 1];
|
||||
uint8_t led_state = OUT2BUF[cmd_id_index + 1];
|
||||
|
||||
if (led_state & RUN_LED_ON) {
|
||||
SET_RUN_LED();
|
||||
}
|
||||
if (led_state & RUN_LED_ON)
|
||||
SET_RUN_LED();
|
||||
|
||||
if (led_state & COM_LED_ON) {
|
||||
SET_COM_LED();
|
||||
}
|
||||
if (led_state & COM_LED_ON)
|
||||
SET_COM_LED();
|
||||
|
||||
if (led_state & RUN_LED_OFF) {
|
||||
CLEAR_RUN_LED();
|
||||
}
|
||||
if (led_state & RUN_LED_OFF)
|
||||
CLEAR_RUN_LED();
|
||||
|
||||
if (led_state & COM_LED_OFF) {
|
||||
CLEAR_COM_LED();
|
||||
}
|
||||
if (led_state & COM_LED_OFF)
|
||||
CLEAR_COM_LED();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,123 +83,122 @@ void execute_set_led_command(void)
|
||||
*/
|
||||
bool execute_command(void)
|
||||
{
|
||||
uint8_t usb_out_bytecount, usb_in_bytecount;
|
||||
uint16_t signal_state;
|
||||
uint16_t count;
|
||||
uint8_t usb_out_bytecount, usb_in_bytecount;
|
||||
uint16_t signal_state;
|
||||
uint16_t count;
|
||||
|
||||
/* Most commands do not transfer IN data. To save code space, we write 0 to
|
||||
* usb_in_bytecount here, then modify it in the switch statement below where
|
||||
* neccessary */
|
||||
usb_in_bytecount = 0;
|
||||
/* Most commands do not transfer IN data. To save code space, we write 0 to
|
||||
* usb_in_bytecount here, then modify it in the switch statement below where
|
||||
* neccessary */
|
||||
usb_in_bytecount = 0;
|
||||
|
||||
switch (OUT2BUF[cmd_id_index] /* Command ID */) {
|
||||
case CMD_SCAN_IN:
|
||||
usb_out_bytecount = 5;
|
||||
usb_in_bytecount = OUT2BUF[cmd_id_index + 1];
|
||||
jtag_scan_in(cmd_id_index + 1, payload_index_in);
|
||||
break;
|
||||
case CMD_SCAN_OUT:
|
||||
usb_out_bytecount = OUT2BUF[cmd_id_index + 1] + 5;
|
||||
jtag_scan_out(cmd_id_index + 1);
|
||||
break;
|
||||
case CMD_SCAN_IO:
|
||||
usb_in_bytecount = OUT2BUF[cmd_id_index + 1];
|
||||
usb_out_bytecount = usb_in_bytecount + 5;
|
||||
jtag_scan_io(cmd_id_index + 1, payload_index_in);
|
||||
break;
|
||||
case CMD_CLOCK_TMS:
|
||||
usb_out_bytecount = 2;
|
||||
jtag_clock_tms(OUT2BUF[cmd_id_index + 1], OUT2BUF[cmd_id_index + 2]);
|
||||
break;
|
||||
case CMD_CLOCK_TCK:
|
||||
usb_out_bytecount = 2;
|
||||
count = (uint16_t)OUT2BUF[cmd_id_index + 1];
|
||||
count |= ((uint16_t)OUT2BUF[cmd_id_index + 2]) << 8;
|
||||
jtag_clock_tck(count);
|
||||
break;
|
||||
case CMD_SLOW_SCAN_IN:
|
||||
usb_out_bytecount = 5;
|
||||
usb_in_bytecount = OUT2BUF[cmd_id_index + 1];
|
||||
jtag_slow_scan_in(cmd_id_index + 1, payload_index_in);
|
||||
break;
|
||||
case CMD_SLOW_SCAN_OUT:
|
||||
usb_out_bytecount = OUT2BUF[cmd_id_index + 1] + 5;
|
||||
jtag_slow_scan_out(cmd_id_index + 1);
|
||||
break;
|
||||
case CMD_SLOW_SCAN_IO:
|
||||
usb_in_bytecount = OUT2BUF[cmd_id_index + 1];
|
||||
usb_out_bytecount = usb_in_bytecount + 5;
|
||||
jtag_slow_scan_io(cmd_id_index + 1, payload_index_in);
|
||||
break;
|
||||
case CMD_SLOW_CLOCK_TMS:
|
||||
usb_out_bytecount = 2;
|
||||
jtag_slow_clock_tms(OUT2BUF[cmd_id_index + 1], OUT2BUF[cmd_id_index + 2]);
|
||||
break;
|
||||
case CMD_SLOW_CLOCK_TCK:
|
||||
usb_out_bytecount = 2;
|
||||
count = (uint16_t)OUT2BUF[cmd_id_index + 1];
|
||||
count |= ((uint16_t)OUT2BUF[cmd_id_index + 2]) << 8;
|
||||
jtag_slow_clock_tck(count);
|
||||
break;
|
||||
case CMD_SLEEP_US:
|
||||
usb_out_bytecount = 2;
|
||||
count = (uint16_t)OUT2BUF[cmd_id_index + 1];
|
||||
count |= ((uint16_t)OUT2BUF[cmd_id_index + 2]) << 8;
|
||||
delay_us(count);
|
||||
break;
|
||||
case CMD_SLEEP_MS:
|
||||
usb_out_bytecount = 2;
|
||||
count = (uint16_t)OUT2BUF[cmd_id_index + 1];
|
||||
count |= ((uint16_t)OUT2BUF[cmd_id_index + 2]) << 8;
|
||||
delay_ms(count);
|
||||
break;
|
||||
case CMD_GET_SIGNALS:
|
||||
usb_out_bytecount = 0;
|
||||
usb_in_bytecount = 2;
|
||||
signal_state = jtag_get_signals();
|
||||
IN2BUF[payload_index_in] = (signal_state >> 8) & 0x00FF;
|
||||
IN2BUF[payload_index_in + 1] = signal_state & 0x00FF;
|
||||
break;
|
||||
case CMD_SET_SIGNALS:
|
||||
usb_out_bytecount = 2;
|
||||
jtag_set_signals(OUT2BUF[cmd_id_index + 1], OUT2BUF[cmd_id_index + 2]);
|
||||
break;
|
||||
case CMD_CONFIGURE_TCK_FREQ:
|
||||
usb_out_bytecount = 5;
|
||||
jtag_configure_tck_delay(
|
||||
OUT2BUF[cmd_id_index + 1], /* scan_in */
|
||||
OUT2BUF[cmd_id_index + 2], /* scan_out */
|
||||
OUT2BUF[cmd_id_index + 3], /* scan_io */
|
||||
OUT2BUF[cmd_id_index + 4], /* clock_tck */
|
||||
OUT2BUF[cmd_id_index + 5]); /* clock_tms */
|
||||
break;
|
||||
case CMD_SET_LEDS:
|
||||
usb_out_bytecount = 1;
|
||||
execute_set_led_command();
|
||||
break;
|
||||
case CMD_TEST:
|
||||
usb_out_bytecount = 1;
|
||||
/* Do nothing... This command is only used to test if the device is ready
|
||||
* to accept new commands */
|
||||
break;
|
||||
default:
|
||||
/* Should never be reached */
|
||||
usb_out_bytecount = 0;
|
||||
break;
|
||||
}
|
||||
switch (OUT2BUF[cmd_id_index] /* Command ID */) {
|
||||
case CMD_SCAN_IN:
|
||||
usb_out_bytecount = 5;
|
||||
usb_in_bytecount = OUT2BUF[cmd_id_index + 1];
|
||||
jtag_scan_in(cmd_id_index + 1, payload_index_in);
|
||||
break;
|
||||
case CMD_SCAN_OUT:
|
||||
usb_out_bytecount = OUT2BUF[cmd_id_index + 1] + 5;
|
||||
jtag_scan_out(cmd_id_index + 1);
|
||||
break;
|
||||
case CMD_SCAN_IO:
|
||||
usb_in_bytecount = OUT2BUF[cmd_id_index + 1];
|
||||
usb_out_bytecount = usb_in_bytecount + 5;
|
||||
jtag_scan_io(cmd_id_index + 1, payload_index_in);
|
||||
break;
|
||||
case CMD_CLOCK_TMS:
|
||||
usb_out_bytecount = 2;
|
||||
jtag_clock_tms(OUT2BUF[cmd_id_index + 1], OUT2BUF[cmd_id_index + 2]);
|
||||
break;
|
||||
case CMD_CLOCK_TCK:
|
||||
usb_out_bytecount = 2;
|
||||
count = (uint16_t)OUT2BUF[cmd_id_index + 1];
|
||||
count |= ((uint16_t)OUT2BUF[cmd_id_index + 2]) << 8;
|
||||
jtag_clock_tck(count);
|
||||
break;
|
||||
case CMD_SLOW_SCAN_IN:
|
||||
usb_out_bytecount = 5;
|
||||
usb_in_bytecount = OUT2BUF[cmd_id_index + 1];
|
||||
jtag_slow_scan_in(cmd_id_index + 1, payload_index_in);
|
||||
break;
|
||||
case CMD_SLOW_SCAN_OUT:
|
||||
usb_out_bytecount = OUT2BUF[cmd_id_index + 1] + 5;
|
||||
jtag_slow_scan_out(cmd_id_index + 1);
|
||||
break;
|
||||
case CMD_SLOW_SCAN_IO:
|
||||
usb_in_bytecount = OUT2BUF[cmd_id_index + 1];
|
||||
usb_out_bytecount = usb_in_bytecount + 5;
|
||||
jtag_slow_scan_io(cmd_id_index + 1, payload_index_in);
|
||||
break;
|
||||
case CMD_SLOW_CLOCK_TMS:
|
||||
usb_out_bytecount = 2;
|
||||
jtag_slow_clock_tms(OUT2BUF[cmd_id_index + 1], OUT2BUF[cmd_id_index + 2]);
|
||||
break;
|
||||
case CMD_SLOW_CLOCK_TCK:
|
||||
usb_out_bytecount = 2;
|
||||
count = (uint16_t)OUT2BUF[cmd_id_index + 1];
|
||||
count |= ((uint16_t)OUT2BUF[cmd_id_index + 2]) << 8;
|
||||
jtag_slow_clock_tck(count);
|
||||
break;
|
||||
case CMD_SLEEP_US:
|
||||
usb_out_bytecount = 2;
|
||||
count = (uint16_t)OUT2BUF[cmd_id_index + 1];
|
||||
count |= ((uint16_t)OUT2BUF[cmd_id_index + 2]) << 8;
|
||||
delay_us(count);
|
||||
break;
|
||||
case CMD_SLEEP_MS:
|
||||
usb_out_bytecount = 2;
|
||||
count = (uint16_t)OUT2BUF[cmd_id_index + 1];
|
||||
count |= ((uint16_t)OUT2BUF[cmd_id_index + 2]) << 8;
|
||||
delay_ms(count);
|
||||
break;
|
||||
case CMD_GET_SIGNALS:
|
||||
usb_out_bytecount = 0;
|
||||
usb_in_bytecount = 2;
|
||||
signal_state = jtag_get_signals();
|
||||
IN2BUF[payload_index_in] = (signal_state >> 8) & 0x00FF;
|
||||
IN2BUF[payload_index_in + 1] = signal_state & 0x00FF;
|
||||
break;
|
||||
case CMD_SET_SIGNALS:
|
||||
usb_out_bytecount = 2;
|
||||
jtag_set_signals(OUT2BUF[cmd_id_index + 1], OUT2BUF[cmd_id_index + 2]);
|
||||
break;
|
||||
case CMD_CONFIGURE_TCK_FREQ:
|
||||
usb_out_bytecount = 5;
|
||||
jtag_configure_tck_delay(
|
||||
OUT2BUF[cmd_id_index + 1], /* scan_in */
|
||||
OUT2BUF[cmd_id_index + 2], /* scan_out */
|
||||
OUT2BUF[cmd_id_index + 3], /* scan_io */
|
||||
OUT2BUF[cmd_id_index + 4], /* clock_tck */
|
||||
OUT2BUF[cmd_id_index + 5]); /* clock_tms */
|
||||
break;
|
||||
case CMD_SET_LEDS:
|
||||
usb_out_bytecount = 1;
|
||||
execute_set_led_command();
|
||||
break;
|
||||
case CMD_TEST:
|
||||
usb_out_bytecount = 1;
|
||||
/* Do nothing... This command is only used to test if the device is ready
|
||||
* to accept new commands */
|
||||
break;
|
||||
default:
|
||||
/* Should never be reached */
|
||||
usb_out_bytecount = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update EP2 Bulk-IN data byte count */
|
||||
payload_index_in += usb_in_bytecount;
|
||||
/* Update EP2 Bulk-IN data byte count */
|
||||
payload_index_in += usb_in_bytecount;
|
||||
|
||||
/* Determine if this was the last command */
|
||||
if ((cmd_id_index + usb_out_bytecount + 1) >= OUT2BC) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
/* Not the last command, update cmd_id_index */
|
||||
cmd_id_index += (usb_out_bytecount + 1);
|
||||
return false;
|
||||
}
|
||||
/* Determine if this was the last command */
|
||||
if ((cmd_id_index + usb_out_bytecount + 1) >= OUT2BC)
|
||||
return true;
|
||||
else {
|
||||
/* Not the last command, update cmd_id_index */
|
||||
cmd_id_index += (usb_out_bytecount + 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,35 +206,36 @@ bool execute_command(void)
|
||||
*/
|
||||
void command_loop(void)
|
||||
{
|
||||
bool last_command;
|
||||
bool last_command;
|
||||
|
||||
while (1) {
|
||||
cmd_id_index = 0;
|
||||
payload_index_in = 0;
|
||||
while (1) {
|
||||
cmd_id_index = 0;
|
||||
payload_index_in = 0;
|
||||
|
||||
/* Wait until host sends EP2 Bulk-OUT packet */
|
||||
while (!EP2_out);
|
||||
EP2_out = 0;
|
||||
/* Wait until host sends EP2 Bulk-OUT packet */
|
||||
while (!EP2_out)
|
||||
;
|
||||
EP2_out = 0;
|
||||
|
||||
/* Turn on COM LED to indicate command execution */
|
||||
SET_COM_LED();
|
||||
/* Turn on COM LED to indicate command execution */
|
||||
SET_COM_LED();
|
||||
|
||||
/* Execute the commands */
|
||||
last_command = false;
|
||||
while (last_command == false) {
|
||||
last_command = execute_command();
|
||||
}
|
||||
/* Execute the commands */
|
||||
last_command = false;
|
||||
while (last_command == false)
|
||||
last_command = execute_command();
|
||||
|
||||
CLEAR_COM_LED();
|
||||
|
||||
/* Send back EP2 Bulk-IN packet if required */
|
||||
if (payload_index_in > 0) {
|
||||
IN2BC = payload_index_in;
|
||||
while (!EP2_in);
|
||||
EP2_in = 0;
|
||||
}
|
||||
CLEAR_COM_LED();
|
||||
|
||||
/* Re-arm EP2-OUT after command execution */
|
||||
OUT2BC = 0;
|
||||
}
|
||||
/* Send back EP2 Bulk-IN packet if required */
|
||||
if (payload_index_in > 0) {
|
||||
IN2BC = payload_index_in;
|
||||
while (!EP2_in)
|
||||
;
|
||||
EP2_in = 0;
|
||||
}
|
||||
|
||||
/* Re-arm EP2-OUT after command execution */
|
||||
OUT2BC = 0;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -27,7 +28,7 @@
|
||||
#include <linux/parport.h>
|
||||
#include <linux/ppdev.h>
|
||||
#include <sys/ioctl.h>
|
||||
#else /* not PARPORT_USE_PPDEV */
|
||||
#else /* not PARPORT_USE_PPDEV */
|
||||
#ifndef _WIN32
|
||||
#include <sys/io.h>
|
||||
#endif
|
||||
@@ -53,11 +54,11 @@ static uint16_t amt_jtagaccel_port;
|
||||
|
||||
/* interface variables
|
||||
*/
|
||||
static uint8_t aw_control_rst = 0x00;
|
||||
static uint8_t aw_control_rst;
|
||||
static uint8_t aw_control_fsm = 0x10;
|
||||
static uint8_t aw_control_baudrate = 0x20;
|
||||
|
||||
static int rtck_enabled = 0;
|
||||
static int rtck_enabled;
|
||||
|
||||
#if PARPORT_USE_PPDEV == 1
|
||||
static int device_handle;
|
||||
@@ -70,7 +71,7 @@ static const int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
|
||||
do { \
|
||||
int __retval; \
|
||||
\
|
||||
__retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
|
||||
__retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
|
||||
assert(__retval >= 0); \
|
||||
__retval = write(device_handle, &val, 1); \
|
||||
assert(__retval >= 0); \
|
||||
@@ -79,7 +80,7 @@ static const int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
|
||||
do { \
|
||||
int __retval; \
|
||||
\
|
||||
__retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
|
||||
__retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
|
||||
assert(__retval >= 0); \
|
||||
__retval = read(device_handle, &val, 1); \
|
||||
assert(__retval >= 0); \
|
||||
@@ -91,7 +92,7 @@ static const int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
|
||||
do { \
|
||||
int __retval; \
|
||||
\
|
||||
__retval = ioctl(device_handle, PPSETMODE, &data_mode); \
|
||||
__retval = ioctl(device_handle, PPSETMODE, &data_mode); \
|
||||
assert(__retval >= 0); \
|
||||
__retval = write(device_handle, &val, 1); \
|
||||
assert(__retval >= 0); \
|
||||
@@ -100,7 +101,7 @@ static const int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
|
||||
do { \
|
||||
int __retval; \
|
||||
\
|
||||
__retval = ioctl(device_handle, PPSETMODE, &data_mode); \
|
||||
__retval = ioctl(device_handle, PPSETMODE, &data_mode); \
|
||||
assert(__retval >= 0); \
|
||||
__retval = read(device_handle, &val, 1); \
|
||||
assert(__retval >= 0); \
|
||||
@@ -108,12 +109,12 @@ static const int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
|
||||
|
||||
#else
|
||||
|
||||
#define AMT_AW(val) do { outb(val, amt_jtagaccel_port + 3); } while (0)
|
||||
#define AMT_AR(val) do { val = inb(amt_jtagaccel_port + 3); } while (0)
|
||||
#define AMT_DW(val) do { outb(val, amt_jtagaccel_port + 4); } while (0)
|
||||
#define AMT_DR(val) do { val = inb(amt_jtagaccel_port + 4); } while (0)
|
||||
#define AMT_AW(val) do { outb(val, amt_jtagaccel_port + 3); } while (0)
|
||||
#define AMT_AR(val) do { val = inb(amt_jtagaccel_port + 3); } while (0)
|
||||
#define AMT_DW(val) do { outb(val, amt_jtagaccel_port + 4); } while (0)
|
||||
#define AMT_DR(val) do { val = inb(amt_jtagaccel_port + 4); } while (0)
|
||||
|
||||
#endif // PARPORT_USE_PPDEV
|
||||
#endif /* PARPORT_USE_PPDEV */
|
||||
|
||||
/* tap_move[i][j]: tap movement command to go from state i to state j
|
||||
* 0: Test-Logic-Reset
|
||||
@@ -123,18 +124,16 @@ static const int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
|
||||
* 4: Shift-IR
|
||||
* 5: Pause-IR
|
||||
*/
|
||||
static uint8_t amt_jtagaccel_tap_move[6][6][2] =
|
||||
{
|
||||
static uint8_t amt_jtagaccel_tap_move[6][6][2] = {
|
||||
/* RESET IDLE DRSHIFT DRPAUSE IRSHIFT IRPAUSE */
|
||||
{{0x1f, 0x00}, {0x0f, 0x00}, {0x05, 0x00}, {0x0a, 0x00}, {0x06, 0x00}, {0x96, 0x00}}, /* RESET */
|
||||
{{0x1f, 0x00}, {0x00, 0x00}, {0x04, 0x00}, {0x05, 0x00}, {0x06, 0x00}, {0x0b, 0x00}}, /* IDLE */
|
||||
{{0x1f, 0x00}, {0x0d, 0x00}, {0x00, 0x00}, {0x01, 0x00}, {0x8f, 0x09}, {0x8f, 0x01}}, /* DRSHIFT */
|
||||
{{0x1f, 0x00}, {0x0c, 0x00}, {0x08, 0x00}, {0x00, 0x00}, {0x8f, 0x09}, {0x8f, 0x01}}, /* DRPAUSE */
|
||||
{{0x1f, 0x00}, {0x0d, 0x00}, {0x07, 0x00}, {0x97, 0x00}, {0x00, 0x00}, {0x01, 0x00}}, /* IRSHIFT */
|
||||
{{0x1f, 0x00}, {0x0c, 0x00}, {0x07, 0x00}, {0x97, 0x00}, {0x08, 0x00}, {0x00, 0x00}}, /* IRPAUSE */
|
||||
{ {0x1f, 0x00}, {0x0f, 0x00}, {0x05, 0x00}, {0x0a, 0x00}, {0x06, 0x00}, {0x96, 0x00} }, /* RESET */
|
||||
{ {0x1f, 0x00}, {0x00, 0x00}, {0x04, 0x00}, {0x05, 0x00}, {0x06, 0x00}, {0x0b, 0x00} }, /* IDLE */
|
||||
{ {0x1f, 0x00}, {0x0d, 0x00}, {0x00, 0x00}, {0x01, 0x00}, {0x8f, 0x09}, {0x8f, 0x01} }, /* DRSHIFT */
|
||||
{ {0x1f, 0x00}, {0x0c, 0x00}, {0x08, 0x00}, {0x00, 0x00}, {0x8f, 0x09}, {0x8f, 0x01} }, /* DRPAUSE */
|
||||
{ {0x1f, 0x00}, {0x0d, 0x00}, {0x07, 0x00}, {0x97, 0x00}, {0x00, 0x00}, {0x01, 0x00} }, /* IRSHIFT */
|
||||
{ {0x1f, 0x00}, {0x0c, 0x00}, {0x07, 0x00}, {0x97, 0x00}, {0x08, 0x00}, {0x00, 0x00} }, /* IRPAUSE */
|
||||
};
|
||||
|
||||
|
||||
static void amt_jtagaccel_reset(int trst, int srst)
|
||||
{
|
||||
if (trst == 1)
|
||||
@@ -163,8 +162,7 @@ static void amt_jtagaccel_end_state(tap_state_t state)
|
||||
{
|
||||
if (tap_is_state_stable(state))
|
||||
tap_set_end_state(state);
|
||||
else
|
||||
{
|
||||
else {
|
||||
LOG_ERROR("BUG: %i is not a valid end state", state);
|
||||
exit(-1);
|
||||
}
|
||||
@@ -179,9 +177,11 @@ static void amt_wait_scan_busy(void)
|
||||
while (((ar_status) & 0x80) && (timeout-- > 0))
|
||||
AMT_AR(ar_status);
|
||||
|
||||
if (ar_status & 0x80)
|
||||
{
|
||||
LOG_ERROR("amt_jtagaccel timed out while waiting for end of scan, rtck was %s, last AR_STATUS: 0x%2.2x", (rtck_enabled) ? "enabled" : "disabled", ar_status);
|
||||
if (ar_status & 0x80) {
|
||||
LOG_ERROR(
|
||||
"amt_jtagaccel timed out while waiting for end of scan, rtck was %s, last AR_STATUS: 0x%2.2x",
|
||||
(rtck_enabled) ? "enabled" : "disabled",
|
||||
ar_status);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@@ -191,22 +191,21 @@ static void amt_jtagaccel_state_move(void)
|
||||
uint8_t aw_scan_tms_5;
|
||||
uint8_t tms_scan[2];
|
||||
|
||||
tap_state_t cur_state = tap_get_state();
|
||||
tap_state_t end_state = tap_get_end_state();
|
||||
tap_state_t cur_state = tap_get_state();
|
||||
tap_state_t end_state = tap_get_end_state();
|
||||
|
||||
tms_scan[0] = amt_jtagaccel_tap_move[tap_move_ndx(cur_state)][tap_move_ndx(end_state)][0];
|
||||
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_ndx(cur_state)][tap_move_ndx(end_state)][1];
|
||||
|
||||
aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
|
||||
AMT_AW(aw_scan_tms_5);
|
||||
int jtag_speed=0;
|
||||
int jtag_speed = 0;
|
||||
int retval = jtag_get_speed(&jtag_speed);
|
||||
assert(retval == ERROR_OK);
|
||||
if (jtag_speed > 3 || rtck_enabled)
|
||||
amt_wait_scan_busy();
|
||||
|
||||
if (tms_scan[0] & 0x80)
|
||||
{
|
||||
if (tms_scan[0] & 0x80) {
|
||||
aw_scan_tms_5 = 0x40 | (tms_scan[1] & 0x1f);
|
||||
AMT_AW(aw_scan_tms_5);
|
||||
if (jtag_speed > 3 || rtck_enabled)
|
||||
@@ -225,21 +224,18 @@ static void amt_jtagaccel_runtest(int num_cycles)
|
||||
tap_state_t saved_end_state = tap_get_end_state();
|
||||
|
||||
/* only do a state_move when we're not already in IDLE */
|
||||
if (tap_get_state() != TAP_IDLE)
|
||||
{
|
||||
if (tap_get_state() != TAP_IDLE) {
|
||||
amt_jtagaccel_end_state(TAP_IDLE);
|
||||
amt_jtagaccel_state_move();
|
||||
}
|
||||
|
||||
while (num_cycles - i >= 5)
|
||||
{
|
||||
while (num_cycles - i >= 5) {
|
||||
aw_scan_tms_5 = 0x40;
|
||||
AMT_AW(aw_scan_tms_5);
|
||||
i += 5;
|
||||
}
|
||||
|
||||
if (num_cycles - i > 0)
|
||||
{
|
||||
if (num_cycles - i > 0) {
|
||||
aw_scan_tms_1to4 = 0x80 | ((num_cycles - i - 1) & 0x3) << 4;
|
||||
AMT_AW(aw_scan_tms_1to4);
|
||||
}
|
||||
@@ -272,8 +268,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||
amt_jtagaccel_end_state(saved_end_state);
|
||||
|
||||
/* handle unaligned bits at the beginning */
|
||||
if ((scan_size - 1) % 8)
|
||||
{
|
||||
if ((scan_size - 1) % 8) {
|
||||
aw_tdi_option = 0x30 | (((scan_size - 1) % 8) - 1);
|
||||
AMT_AW(aw_tdi_option);
|
||||
|
||||
@@ -282,8 +277,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||
if (jtag_speed_var > 3 || rtck_enabled)
|
||||
amt_wait_scan_busy();
|
||||
|
||||
if ((type == SCAN_IN) || (type == SCAN_IO))
|
||||
{
|
||||
if ((type == SCAN_IN) || (type == SCAN_IO)) {
|
||||
AMT_DR(dr_tdo);
|
||||
dr_tdo = dr_tdo >> (8 - ((scan_size - 1) % 8));
|
||||
buf_set_u32(buffer, bit_count, (scan_size - 1) % 8, dr_tdo);
|
||||
@@ -293,15 +287,13 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||
bits_left -= (scan_size - 1) % 8;
|
||||
}
|
||||
|
||||
while (bits_left - 1 >= 8)
|
||||
{
|
||||
while (bits_left - 1 >= 8) {
|
||||
dw_tdi_scan = buf_get_u32(buffer, bit_count, 8) & 0xff;
|
||||
AMT_DW(dw_tdi_scan);
|
||||
if (jtag_speed_var > 3 || rtck_enabled)
|
||||
amt_wait_scan_busy();
|
||||
|
||||
if ((type == SCAN_IN) || (type == SCAN_IO))
|
||||
{
|
||||
if ((type == SCAN_IN) || (type == SCAN_IO)) {
|
||||
AMT_DR(dr_tdo);
|
||||
buf_set_u32(buffer, bit_count, 8, dr_tdo);
|
||||
}
|
||||
@@ -310,22 +302,22 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||
bits_left -= 8;
|
||||
}
|
||||
|
||||
tms_scan[0] = amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][0];
|
||||
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][1];
|
||||
tms_scan[0] =
|
||||
amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][0];
|
||||
tms_scan[1] =
|
||||
amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][1];
|
||||
aw_tms_scan = 0x40 | (tms_scan[0] & 0x1f) | (buf_get_u32(buffer, bit_count, 1) << 5);
|
||||
AMT_AW(aw_tms_scan);
|
||||
if (jtag_speed_var > 3 || rtck_enabled)
|
||||
amt_wait_scan_busy();
|
||||
|
||||
if ((type == SCAN_IN) || (type == SCAN_IO))
|
||||
{
|
||||
if ((type == SCAN_IN) || (type == SCAN_IO)) {
|
||||
AMT_DR(dr_tdo);
|
||||
dr_tdo = dr_tdo >> 7;
|
||||
buf_set_u32(buffer, bit_count, 1, dr_tdo);
|
||||
}
|
||||
|
||||
if (tms_scan[0] & 0x80)
|
||||
{
|
||||
if (tms_scan[0] & 0x80) {
|
||||
aw_tms_scan = 0x40 | (tms_scan[1] & 0x1f);
|
||||
AMT_AW(aw_tms_scan);
|
||||
if (jtag_speed_var > 3 || rtck_enabled)
|
||||
@@ -336,7 +328,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||
|
||||
static int amt_jtagaccel_execute_queue(void)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
@@ -347,23 +339,23 @@ static int amt_jtagaccel_execute_queue(void)
|
||||
*/
|
||||
retval = ERROR_OK;
|
||||
|
||||
while (cmd)
|
||||
{
|
||||
switch (cmd->type)
|
||||
{
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
LOG_DEBUG("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
#endif
|
||||
if (cmd->cmd.reset->trst == 1)
|
||||
{
|
||||
tap_set_state(TAP_RESET);
|
||||
}
|
||||
amt_jtagaccel_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
break;
|
||||
case JTAG_RUNTEST:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state);
|
||||
LOG_DEBUG("runtest %i cycles, end in %i",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
#endif
|
||||
amt_jtagaccel_end_state(cmd->cmd.runtest->end_state);
|
||||
amt_jtagaccel_runtest(cmd->cmd.runtest->num_cycles);
|
||||
@@ -412,16 +404,22 @@ int amt_jtagaccel_get_giveio_access(void)
|
||||
|
||||
version.dwOSVersionInfoSize = sizeof version;
|
||||
if (!GetVersionEx(&version)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
h = CreateFile("\\\\.\\giveio",
|
||||
GENERIC_READ,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
errno = ENODEV;
|
||||
return -1;
|
||||
errno = ENODEV;
|
||||
return -1;
|
||||
}
|
||||
|
||||
CloseHandle(h);
|
||||
@@ -442,8 +440,7 @@ static int amt_jtagaccel_init(void)
|
||||
uint8_t ar_status;
|
||||
|
||||
#if PARPORT_USE_PPDEV == 1
|
||||
if (device_handle > 0)
|
||||
{
|
||||
if (device_handle > 0) {
|
||||
LOG_ERROR("device is already opened");
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
@@ -451,23 +448,21 @@ static int amt_jtagaccel_init(void)
|
||||
snprintf(buffer, 256, "/dev/parport%d", amt_jtagaccel_port);
|
||||
device_handle = open(buffer, O_RDWR);
|
||||
|
||||
if (device_handle < 0)
|
||||
{
|
||||
LOG_ERROR("cannot open device. check it exists and that user read and write rights are set");
|
||||
if (device_handle < 0) {
|
||||
LOG_ERROR(
|
||||
"cannot open device. check it exists and that user read and write rights are set");
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
i = ioctl(device_handle, PPCLAIM);
|
||||
if (i < 0)
|
||||
{
|
||||
if (i < 0) {
|
||||
LOG_ERROR("cannot claim device");
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
i = IEEE1284_MODE_EPP;
|
||||
i = ioctl(device_handle, PPSETMODE, & i);
|
||||
if (i < 0)
|
||||
{
|
||||
i = ioctl(device_handle, PPSETMODE, &i);
|
||||
if (i < 0) {
|
||||
LOG_ERROR(" cannot set compatible mode to device");
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
@@ -479,23 +474,22 @@ static int amt_jtagaccel_init(void)
|
||||
i = ioctl(device_handle, PPWCONTROL, &control_port);
|
||||
|
||||
#else
|
||||
if (amt_jtagaccel_port == 0)
|
||||
{
|
||||
if (amt_jtagaccel_port == 0) {
|
||||
amt_jtagaccel_port = 0x378;
|
||||
LOG_WARNING("No parport port specified, using default '0x378' (LPT1)");
|
||||
}
|
||||
|
||||
#if PARPORT_USE_GIVEIO == 1
|
||||
if (amt_jtagaccel_get_giveio_access() != 0) {
|
||||
#else /* PARPORT_USE_GIVEIO */
|
||||
#else /* PARPORT_USE_GIVEIO */
|
||||
if (ioperm(amt_jtagaccel_port, 5, 1) != 0) {
|
||||
#endif /* PARPORT_USE_GIVEIO */
|
||||
#endif /* PARPORT_USE_GIVEIO */
|
||||
LOG_ERROR("missing privileges for direct i/o");
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
/* prepare epp port */
|
||||
/* clear timeout */
|
||||
/* prepare epp port
|
||||
* clear timeout */
|
||||
status_port = inb(amt_jtagaccel_port + 1);
|
||||
outb(status_port | 0x1, amt_jtagaccel_port + 1);
|
||||
|
||||
@@ -504,8 +498,7 @@ static int amt_jtagaccel_init(void)
|
||||
outb(0x04, amt_jtagaccel_port + 2);
|
||||
#endif
|
||||
|
||||
if (rtck_enabled)
|
||||
{
|
||||
if (rtck_enabled) {
|
||||
/* set RTCK enable bit */
|
||||
aw_control_fsm |= 0x02;
|
||||
}
|
||||
@@ -542,17 +535,13 @@ static int amt_jtagaccel_quit(void)
|
||||
|
||||
COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
|
||||
{
|
||||
if (CMD_ARGC == 1)
|
||||
{
|
||||
if (CMD_ARGC == 1) {
|
||||
/* only if the port wasn't overwritten by cmdline */
|
||||
if (amt_jtagaccel_port == 0)
|
||||
{
|
||||
if (amt_jtagaccel_port == 0) {
|
||||
uint16_t port;
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], port);
|
||||
amt_jtagaccel_port = port;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
LOG_ERROR("The parport port was already configured!");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -565,21 +554,16 @@ COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
|
||||
|
||||
COMMAND_HANDLER(amt_jtagaccel_handle_rtck_command)
|
||||
{
|
||||
if (CMD_ARGC == 0)
|
||||
{
|
||||
command_print(CMD_CTX, "amt_jtagaccel RTCK feature %s", (rtck_enabled) ? "enabled" : "disabled");
|
||||
if (CMD_ARGC == 0) {
|
||||
command_print(CMD_CTX,
|
||||
"amt_jtagaccel RTCK feature %s",
|
||||
(rtck_enabled) ? "enabled" : "disabled");
|
||||
return ERROR_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (strcmp(CMD_ARGV[0], "enabled") == 0)
|
||||
{
|
||||
rtck_enabled = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rtck_enabled = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -26,7 +27,6 @@
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
||||
/* AT91RM9200 */
|
||||
#define AT91C_BASE_SYS (0xfffff000)
|
||||
|
||||
@@ -78,9 +78,8 @@
|
||||
#define P30 (1 << 30)
|
||||
#define P31 (1 << 31)
|
||||
|
||||
struct device_t
|
||||
{
|
||||
char* name;
|
||||
struct device_t {
|
||||
char *name;
|
||||
int TDO_PIO; /* PIO holding TDO */
|
||||
uint32_t TDO_MASK; /* TDO bitmask */
|
||||
int TRST_PIO; /* PIO holding TRST */
|
||||
@@ -95,21 +94,20 @@ struct device_t
|
||||
uint32_t SRST_MASK; /* SRST bitmask */
|
||||
};
|
||||
|
||||
static struct device_t devices[] =
|
||||
{
|
||||
static struct device_t devices[] = {
|
||||
{ "rea_ecr", PIOD, P27, PIOA, NC, PIOD, P23, PIOD, P24, PIOD, P26, PIOC, P5 },
|
||||
{ .name = NULL },
|
||||
};
|
||||
|
||||
/* configuration */
|
||||
static char* at91rm9200_device;
|
||||
static char *at91rm9200_device;
|
||||
|
||||
/* interface variables
|
||||
*/
|
||||
static struct device_t* device;
|
||||
static struct device_t *device;
|
||||
static int dev_mem_fd;
|
||||
static void *sys_controller;
|
||||
static uint32_t* pio_base;
|
||||
static uint32_t *pio_base;
|
||||
|
||||
/* low level command set
|
||||
*/
|
||||
@@ -121,8 +119,7 @@ static int at91rm9200_speed(int speed);
|
||||
static int at91rm9200_init(void);
|
||||
static int at91rm9200_quit(void);
|
||||
|
||||
static struct bitbang_interface at91rm9200_bitbang =
|
||||
{
|
||||
static struct bitbang_interface at91rm9200_bitbang = {
|
||||
.read = at91rm9200_read,
|
||||
.write = at91rm9200_write,
|
||||
.reset = at91rm9200_reset,
|
||||
@@ -178,8 +175,7 @@ COMMAND_HANDLER(at91rm9200_handle_device_command)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
/* only if the device name wasn't overwritten by cmdline */
|
||||
if (at91rm9200_device == 0)
|
||||
{
|
||||
if (at91rm9200_device == 0) {
|
||||
at91rm9200_device = malloc(strlen(CMD_ARGV[0]) + sizeof(char));
|
||||
strcpy(at91rm9200_device, CMD_ARGV[0]);
|
||||
}
|
||||
@@ -197,12 +193,9 @@ static const struct command_registration at91rm9200_command_handlers[] = {
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
struct jtag_interface at91rm9200_interface =
|
||||
{
|
||||
struct jtag_interface at91rm9200_interface = {
|
||||
.name = "at91rm9200",
|
||||
|
||||
.execute_queue = bitbang_execute_queue,
|
||||
|
||||
.speed = at91rm9200_speed,
|
||||
.commands = at91rm9200_command_handlers,
|
||||
.init = at91rm9200_init,
|
||||
@@ -215,24 +208,20 @@ static int at91rm9200_init(void)
|
||||
|
||||
cur_device = devices;
|
||||
|
||||
if (at91rm9200_device == NULL || at91rm9200_device[0] == 0)
|
||||
{
|
||||
if (at91rm9200_device == NULL || at91rm9200_device[0] == 0) {
|
||||
at91rm9200_device = "rea_ecr";
|
||||
LOG_WARNING("No at91rm9200 device specified, using default 'rea_ecr'");
|
||||
}
|
||||
|
||||
while (cur_device->name)
|
||||
{
|
||||
if (strcmp(cur_device->name, at91rm9200_device) == 0)
|
||||
{
|
||||
while (cur_device->name) {
|
||||
if (strcmp(cur_device->name, at91rm9200_device) == 0) {
|
||||
device = cur_device;
|
||||
break;
|
||||
}
|
||||
cur_device++;
|
||||
}
|
||||
|
||||
if (!device)
|
||||
{
|
||||
if (!device) {
|
||||
LOG_ERROR("No matching device found for %s", at91rm9200_device);
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
@@ -252,7 +241,7 @@ static int at91rm9200_init(void)
|
||||
close(dev_mem_fd);
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
pio_base = (uint32_t*)sys_controller + 0x100;
|
||||
pio_base = (uint32_t *)sys_controller + 0x100;
|
||||
|
||||
/*
|
||||
* Configure TDO as an input, and TDI, TCK, TMS, TRST, SRST
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -38,7 +39,6 @@
|
||||
*/
|
||||
static void bitbang_stableclocks(int num_cycles);
|
||||
|
||||
|
||||
struct bitbang_interface *bitbang_interface;
|
||||
|
||||
/* DANGER!!!! clock absolutely *MUST* be 0 in idle or reset won't work!
|
||||
@@ -61,14 +61,12 @@ struct bitbang_interface *bitbang_interface;
|
||||
*/
|
||||
#define CLOCK_IDLE() 0
|
||||
|
||||
|
||||
/* The bitbang driver leaves the TCK 0 when in idle */
|
||||
static void bitbang_end_state(tap_state_t state)
|
||||
{
|
||||
if (tap_is_state_stable(state))
|
||||
tap_set_end_state(state);
|
||||
else
|
||||
{
|
||||
else {
|
||||
LOG_ERROR("BUG: %i is not a valid end state", state);
|
||||
exit(-1);
|
||||
}
|
||||
@@ -80,8 +78,7 @@ static void bitbang_state_move(int skip)
|
||||
uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
|
||||
int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
|
||||
|
||||
for (i = skip; i < tms_count; i++)
|
||||
{
|
||||
for (i = skip; i < tms_count; i++) {
|
||||
tms = (tms_scan >> i) & 1;
|
||||
bitbang_interface->write(0, tms, 0);
|
||||
bitbang_interface->write(1, tms, 0);
|
||||
@@ -91,21 +88,19 @@ static void bitbang_state_move(int skip)
|
||||
tap_set_state(tap_get_end_state());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clock a bunch of TMS (or SWDIO) transitions, to change the JTAG
|
||||
* (or SWD) state machine.
|
||||
*/
|
||||
static int bitbang_execute_tms(struct jtag_command *cmd)
|
||||
{
|
||||
unsigned num_bits = cmd->cmd.tms->num_bits;
|
||||
const uint8_t *bits = cmd->cmd.tms->bits;
|
||||
unsigned num_bits = cmd->cmd.tms->num_bits;
|
||||
const uint8_t *bits = cmd->cmd.tms->bits;
|
||||
|
||||
DEBUG_JTAG_IO("TMS: %d bits", num_bits);
|
||||
|
||||
int tms = 0;
|
||||
for (unsigned i = 0; i < num_bits; i++)
|
||||
{
|
||||
for (unsigned i = 0; i < num_bits; i++) {
|
||||
tms = ((bits[i/8] >> (i % 8)) & 1);
|
||||
bitbang_interface->write(0, tms, 0);
|
||||
bitbang_interface->write(1, tms, 0);
|
||||
@@ -115,7 +110,6 @@ static int bitbang_execute_tms(struct jtag_command *cmd)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
static void bitbang_path_move(struct pathmove_command *cmd)
|
||||
{
|
||||
int num_states = cmd->num_states;
|
||||
@@ -123,19 +117,15 @@ static void bitbang_path_move(struct pathmove_command *cmd)
|
||||
int tms = 0;
|
||||
|
||||
state_count = 0;
|
||||
while (num_states)
|
||||
{
|
||||
while (num_states) {
|
||||
if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
|
||||
{
|
||||
tms = 0;
|
||||
}
|
||||
else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
|
||||
{
|
||||
tms = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(cmd->path[state_count]));
|
||||
else {
|
||||
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
|
||||
tap_state_name(tap_get_state()),
|
||||
tap_state_name(cmd->path[state_count]));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@@ -159,15 +149,13 @@ static void bitbang_runtest(int num_cycles)
|
||||
tap_state_t saved_end_state = tap_get_end_state();
|
||||
|
||||
/* only do a state_move when we're not already in IDLE */
|
||||
if (tap_get_state() != TAP_IDLE)
|
||||
{
|
||||
if (tap_get_state() != TAP_IDLE) {
|
||||
bitbang_end_state(TAP_IDLE);
|
||||
bitbang_state_move(0);
|
||||
}
|
||||
|
||||
/* execute num_cycles */
|
||||
for (i = 0; i < num_cycles; i++)
|
||||
{
|
||||
for (i = 0; i < num_cycles; i++) {
|
||||
bitbang_interface->write(0, 0, 0);
|
||||
bitbang_interface->write(1, 0, 0);
|
||||
}
|
||||
@@ -179,29 +167,26 @@ static void bitbang_runtest(int num_cycles)
|
||||
bitbang_state_move(0);
|
||||
}
|
||||
|
||||
|
||||
static void bitbang_stableclocks(int num_cycles)
|
||||
{
|
||||
int tms = (tap_get_state() == TAP_RESET ? 1 : 0);
|
||||
int i;
|
||||
|
||||
/* send num_cycles clocks onto the cable */
|
||||
for (i = 0; i < num_cycles; i++)
|
||||
{
|
||||
for (i = 0; i < num_cycles; i++) {
|
||||
bitbang_interface->write(1, tms, 0);
|
||||
bitbang_interface->write(0, tms, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
|
||||
{
|
||||
tap_state_t saved_end_state = tap_get_end_state();
|
||||
int bit_cnt;
|
||||
|
||||
if (!((!ir_scan && (tap_get_state() == TAP_DRSHIFT)) || (ir_scan && (tap_get_state() == TAP_IRSHIFT))))
|
||||
{
|
||||
if (!((!ir_scan &&
|
||||
(tap_get_state() == TAP_DRSHIFT)) ||
|
||||
(ir_scan && (tap_get_state() == TAP_IRSHIFT)))) {
|
||||
if (ir_scan)
|
||||
bitbang_end_state(TAP_IRSHIFT);
|
||||
else
|
||||
@@ -211,8 +196,7 @@ static void bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int
|
||||
bitbang_end_state(saved_end_state);
|
||||
}
|
||||
|
||||
for (bit_cnt = 0; bit_cnt < scan_size; bit_cnt++)
|
||||
{
|
||||
for (bit_cnt = 0; bit_cnt < scan_size; bit_cnt++) {
|
||||
int val = 0;
|
||||
int tms = (bit_cnt == scan_size-1) ? 1 : 0;
|
||||
int tdi;
|
||||
@@ -234,8 +218,7 @@ static void bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int
|
||||
|
||||
bitbang_interface->write(1, tms, tdi);
|
||||
|
||||
if (type != SCAN_OUT)
|
||||
{
|
||||
if (type != SCAN_OUT) {
|
||||
if (val)
|
||||
buffer[bytec] |= bcval;
|
||||
else
|
||||
@@ -243,8 +226,7 @@ static void bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int
|
||||
}
|
||||
}
|
||||
|
||||
if (tap_get_state() != tap_get_end_state())
|
||||
{
|
||||
if (tap_get_state() != tap_get_end_state()) {
|
||||
/* we *KNOW* the above loop transitioned out of
|
||||
* the shift state, so we skip the first state
|
||||
* and move directly to the end state.
|
||||
@@ -255,14 +237,13 @@ static void bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int
|
||||
|
||||
int bitbang_execute_queue(void)
|
||||
{
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
int scan_size;
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
int retval;
|
||||
|
||||
if (!bitbang_interface)
|
||||
{
|
||||
if (!bitbang_interface) {
|
||||
LOG_ERROR("BUG: Bitbang interface called, but not yet initialized");
|
||||
exit(-1);
|
||||
}
|
||||
@@ -275,23 +256,24 @@ int bitbang_execute_queue(void)
|
||||
if (bitbang_interface->blink)
|
||||
bitbang_interface->blink(1);
|
||||
|
||||
while (cmd)
|
||||
{
|
||||
switch (cmd->type)
|
||||
{
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
LOG_DEBUG("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
#endif
|
||||
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
|
||||
{
|
||||
if ((cmd->cmd.reset->trst == 1) ||
|
||||
(cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
|
||||
tap_set_state(TAP_RESET);
|
||||
}
|
||||
bitbang_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
break;
|
||||
case JTAG_RUNTEST:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name(cmd->cmd.runtest->end_state));
|
||||
LOG_DEBUG("runtest %i cycles, end in %s",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
tap_state_name(cmd->cmd.runtest->end_state));
|
||||
#endif
|
||||
bitbang_end_state(cmd->cmd.runtest->end_state);
|
||||
bitbang_runtest(cmd->cmd.runtest->num_cycles);
|
||||
@@ -306,21 +288,25 @@ int bitbang_execute_queue(void)
|
||||
|
||||
case JTAG_TLR_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state));
|
||||
LOG_DEBUG("statemove end in %s",
|
||||
tap_state_name(cmd->cmd.statemove->end_state));
|
||||
#endif
|
||||
bitbang_end_state(cmd->cmd.statemove->end_state);
|
||||
bitbang_state_move(0);
|
||||
break;
|
||||
case JTAG_PATHMOVE:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("pathmove: %i states, end in %s", cmd->cmd.pathmove->num_states,
|
||||
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
|
||||
LOG_DEBUG("pathmove: %i states, end in %s",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
|
||||
#endif
|
||||
bitbang_path_move(cmd->cmd.pathmove);
|
||||
break;
|
||||
case JTAG_SCAN:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("%s scan end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", tap_state_name(cmd->cmd.scan->end_state));
|
||||
LOG_DEBUG("%s scan end in %s",
|
||||
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
|
||||
tap_state_name(cmd->cmd.scan->end_state));
|
||||
#endif
|
||||
bitbang_end_state(cmd->cmd.scan->end_state);
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef BITBANG_H
|
||||
#define BITBANG_H
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -25,8 +26,7 @@
|
||||
#include "bitq.h"
|
||||
#include <jtag/interface.h>
|
||||
|
||||
|
||||
struct bitq_interface* bitq_interface; /* low level bit queue interface */
|
||||
struct bitq_interface *bitq_interface; /* low level bit queue interface */
|
||||
|
||||
/* state of input queue */
|
||||
struct bitq_state {
|
||||
@@ -44,29 +44,23 @@ static struct bitq_state bitq_in_state;
|
||||
static void bitq_in_proc(void)
|
||||
{
|
||||
/* loop through the queue */
|
||||
while (bitq_in_state.cmd)
|
||||
{
|
||||
while (bitq_in_state.cmd) {
|
||||
/* only JTAG_SCAN command may return data */
|
||||
if (bitq_in_state.cmd->type == JTAG_SCAN)
|
||||
{
|
||||
if (bitq_in_state.cmd->type == JTAG_SCAN) {
|
||||
/* loop through the fields */
|
||||
while (bitq_in_state.field_idx < bitq_in_state.cmd->cmd.scan->num_fields)
|
||||
{
|
||||
while (bitq_in_state.field_idx < bitq_in_state.cmd->cmd.scan->num_fields) {
|
||||
struct scan_field *field;
|
||||
field = &bitq_in_state.cmd->cmd.scan->fields[bitq_in_state.field_idx];
|
||||
if (field->in_value)
|
||||
{
|
||||
if (field->in_value) {
|
||||
/* field scanning */
|
||||
while (bitq_in_state.bit_pos < field->num_bits)
|
||||
{
|
||||
while (bitq_in_state.bit_pos < field->num_bits) {
|
||||
/* index of byte being scanned */
|
||||
int in_idx = bitq_in_state.bit_pos / 8;
|
||||
/* mask of next bit to be scanned */
|
||||
uint8_t in_mask = 1 << (bitq_in_state.bit_pos % 8);
|
||||
|
||||
int tdo = bitq_interface->in();
|
||||
if (tdo < 0)
|
||||
{
|
||||
if (tdo < 0) {
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("bitq in EOF");
|
||||
#endif
|
||||
@@ -89,7 +83,6 @@ static void bitq_in_proc(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void bitq_io(int tms, int tdi, int tdo_req)
|
||||
{
|
||||
bitq_interface->out(tms, tdi, tdo_req);
|
||||
@@ -98,25 +91,21 @@ static void bitq_io(int tms, int tdi, int tdo_req)
|
||||
bitq_in_proc();
|
||||
}
|
||||
|
||||
|
||||
static void bitq_end_state(tap_state_t state)
|
||||
{
|
||||
if (!tap_is_state_stable(state))
|
||||
{
|
||||
if (!tap_is_state_stable(state)) {
|
||||
LOG_ERROR("BUG: %i is not a valid end state", state);
|
||||
exit(-1);
|
||||
}
|
||||
tap_set_end_state(state);
|
||||
}
|
||||
|
||||
|
||||
static void bitq_state_move(tap_state_t new_state)
|
||||
{
|
||||
int i = 0;
|
||||
uint8_t tms_scan;
|
||||
|
||||
if (!tap_is_state_stable(tap_get_state()) || !tap_is_state_stable(new_state))
|
||||
{
|
||||
if (!tap_is_state_stable(tap_get_state()) || !tap_is_state_stable(new_state)) {
|
||||
LOG_ERROR("TAP move from or to unstable state");
|
||||
exit(-1);
|
||||
}
|
||||
@@ -124,8 +113,7 @@ static void bitq_state_move(tap_state_t new_state)
|
||||
tms_scan = tap_get_tms_path(tap_get_state(), new_state);
|
||||
int tms_count = tap_get_tms_path_len(tap_get_state(), new_state);
|
||||
|
||||
for (i = 0; i < tms_count; i++)
|
||||
{
|
||||
for (i = 0; i < tms_count; i++) {
|
||||
bitq_io(tms_scan & 1, 0, 0);
|
||||
tms_scan >>= 1;
|
||||
}
|
||||
@@ -133,19 +121,16 @@ static void bitq_state_move(tap_state_t new_state)
|
||||
tap_set_state(new_state);
|
||||
}
|
||||
|
||||
|
||||
static void bitq_path_move(struct pathmove_command *cmd)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= cmd->num_states; i++)
|
||||
{
|
||||
for (i = 0; i <= cmd->num_states; i++) {
|
||||
if (tap_state_transition(tap_get_state(), false) == cmd->path[i])
|
||||
bitq_io(0, 0, 0);
|
||||
else if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
|
||||
bitq_io(1, 0, 0);
|
||||
else
|
||||
{
|
||||
else {
|
||||
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(
|
||||
tap_get_state()), tap_state_name(cmd->path[i]));
|
||||
exit(-1);
|
||||
@@ -157,7 +142,6 @@ static void bitq_path_move(struct pathmove_command *cmd)
|
||||
tap_set_end_state(tap_get_state());
|
||||
}
|
||||
|
||||
|
||||
static void bitq_runtest(int num_cycles)
|
||||
{
|
||||
int i;
|
||||
@@ -175,13 +159,12 @@ static void bitq_runtest(int num_cycles)
|
||||
bitq_state_move(tap_get_end_state());
|
||||
}
|
||||
|
||||
|
||||
static void bitq_scan_field(struct scan_field *field, int do_pause)
|
||||
{
|
||||
int bit_cnt;
|
||||
int tdo_req;
|
||||
|
||||
const uint8_t* out_ptr;
|
||||
const uint8_t *out_ptr;
|
||||
uint8_t out_mask;
|
||||
|
||||
if (field->in_value)
|
||||
@@ -189,36 +172,29 @@ static void bitq_scan_field(struct scan_field *field, int do_pause)
|
||||
else
|
||||
tdo_req = 0;
|
||||
|
||||
if (field->out_value == NULL)
|
||||
{
|
||||
if (field->out_value == NULL) {
|
||||
/* just send zeros and request data from TDO */
|
||||
for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--)
|
||||
bitq_io(0, 0, tdo_req);
|
||||
|
||||
bitq_io(do_pause, 0, tdo_req);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* send data, and optionally request TDO */
|
||||
out_mask = 0x01;
|
||||
out_ptr = field->out_value;
|
||||
for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--)
|
||||
{
|
||||
for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--) {
|
||||
bitq_io(0, ((*out_ptr) & out_mask) != 0, tdo_req);
|
||||
if (out_mask == 0x80)
|
||||
{
|
||||
if (out_mask == 0x80) {
|
||||
out_mask = 0x01;
|
||||
out_ptr++;
|
||||
}
|
||||
else
|
||||
} else
|
||||
out_mask <<= 1;
|
||||
}
|
||||
|
||||
bitq_io(do_pause, ((*out_ptr) & out_mask) != 0, tdo_req);
|
||||
}
|
||||
|
||||
if (do_pause)
|
||||
{
|
||||
if (do_pause) {
|
||||
bitq_io(0, 0, 0);
|
||||
if (tap_get_state() == TAP_IRSHIFT)
|
||||
tap_set_state(TAP_IRPAUSE);
|
||||
@@ -227,7 +203,6 @@ static void bitq_scan_field(struct scan_field *field, int do_pause)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void bitq_scan(struct scan_command *cmd)
|
||||
{
|
||||
int i;
|
||||
@@ -243,28 +218,25 @@ static void bitq_scan(struct scan_command *cmd)
|
||||
bitq_scan_field(&cmd->fields[i], 1);
|
||||
}
|
||||
|
||||
|
||||
int bitq_execute_queue(void)
|
||||
{
|
||||
struct jtag_command* cmd = jtag_command_queue; /* currently processed command */
|
||||
struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
|
||||
|
||||
bitq_in_state.cmd = jtag_command_queue;
|
||||
bitq_in_state.field_idx = 0;
|
||||
bitq_in_state.bit_pos = 0;
|
||||
bitq_in_state.status = ERROR_OK;
|
||||
|
||||
while (cmd)
|
||||
{
|
||||
switch (cmd->type)
|
||||
{
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
#endif
|
||||
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
|
||||
{
|
||||
if ((cmd->cmd.reset->trst == 1) ||
|
||||
(cmd->cmd.reset->srst &&
|
||||
(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
|
||||
tap_set_state(TAP_RESET);
|
||||
}
|
||||
bitq_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
if (bitq_interface->in_rdy())
|
||||
bitq_in_proc();
|
||||
@@ -328,13 +300,11 @@ int bitq_execute_queue(void)
|
||||
bitq_interface->flush();
|
||||
bitq_in_proc();
|
||||
|
||||
if (bitq_in_state.cmd)
|
||||
{
|
||||
if (bitq_in_state.cmd) {
|
||||
LOG_ERROR("missing data from bitq interface");
|
||||
return ERROR_JTAG_QUEUE_FAILED;
|
||||
}
|
||||
if (bitq_interface->in() >= 0)
|
||||
{
|
||||
if (bitq_interface->in() >= 0) {
|
||||
LOG_ERROR("extra data from bitq interface");
|
||||
return ERROR_JTAG_QUEUE_FAILED;
|
||||
}
|
||||
@@ -342,7 +312,6 @@ int bitq_execute_queue(void)
|
||||
return bitq_in_state.status;
|
||||
}
|
||||
|
||||
|
||||
void bitq_cleanup(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef BITQ_H
|
||||
#define BITQ_H
|
||||
|
||||
#include <jtag/commands.h>
|
||||
|
||||
struct bitq_interface {
|
||||
// function to enqueueing low level IO requests
|
||||
/* function to enqueueing low level IO requests */
|
||||
int (*out)(int tms, int tdi, int tdo_req);
|
||||
int (*flush)(void);
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ static void buspirate_runtest(int num_cycles);
|
||||
static void buspirate_scan(bool ir_scan, enum scan_type type,
|
||||
uint8_t *buffer, int scan_size, struct scan_command *command);
|
||||
|
||||
|
||||
#define CMD_UNKNOWN 0x00
|
||||
#define CMD_PORT_MODE 0x01
|
||||
#define CMD_FEATURE 0x02
|
||||
@@ -84,7 +83,6 @@ enum {
|
||||
SERIAL_FAST = 1
|
||||
};
|
||||
|
||||
|
||||
static int buspirate_fd = -1;
|
||||
static int buspirate_pinmode = MODE_JTAG_OD;
|
||||
static int buspirate_baudrate = SERIAL_NORMAL;
|
||||
@@ -92,7 +90,6 @@ static int buspirate_vreg;
|
||||
static int buspirate_pullup;
|
||||
static char *buspirate_port;
|
||||
|
||||
|
||||
/* TAP interface */
|
||||
static void buspirate_tap_init(void);
|
||||
static int buspirate_tap_execute(void);
|
||||
@@ -279,9 +276,8 @@ COMMAND_HANDLER(buspirate_handle_adc_command)
|
||||
|
||||
COMMAND_HANDLER(buspirate_handle_vreg_command)
|
||||
{
|
||||
if (CMD_ARGC < 1) {
|
||||
if (CMD_ARGC < 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (atoi(CMD_ARGV[0]) == 1)
|
||||
buspirate_vreg = 1;
|
||||
@@ -296,9 +292,8 @@ COMMAND_HANDLER(buspirate_handle_vreg_command)
|
||||
|
||||
COMMAND_HANDLER(buspirate_handle_pullup_command)
|
||||
{
|
||||
if (CMD_ARGC < 1) {
|
||||
if (CMD_ARGC < 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (atoi(CMD_ARGV[0]) == 1)
|
||||
buspirate_pullup = 1;
|
||||
@@ -313,9 +308,8 @@ COMMAND_HANDLER(buspirate_handle_pullup_command)
|
||||
|
||||
COMMAND_HANDLER(buspirate_handle_led_command)
|
||||
{
|
||||
if (CMD_ARGC < 1) {
|
||||
if (CMD_ARGC < 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (atoi(CMD_ARGV[0]) == 1) {
|
||||
/* enable led */
|
||||
@@ -335,9 +329,8 @@ COMMAND_HANDLER(buspirate_handle_led_command)
|
||||
|
||||
COMMAND_HANDLER(buspirate_handle_mode_command)
|
||||
{
|
||||
if (CMD_ARGC < 1) {
|
||||
if (CMD_ARGC < 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (CMD_ARGV[0][0] == 'n')
|
||||
buspirate_pinmode = MODE_JTAG;
|
||||
@@ -352,9 +345,8 @@ COMMAND_HANDLER(buspirate_handle_mode_command)
|
||||
|
||||
COMMAND_HANDLER(buspirate_handle_speed_command)
|
||||
{
|
||||
if (CMD_ARGC < 1) {
|
||||
if (CMD_ARGC < 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (CMD_ARGV[0][0] == 'n')
|
||||
buspirate_baudrate = SERIAL_NORMAL;
|
||||
@@ -369,9 +361,8 @@ COMMAND_HANDLER(buspirate_handle_speed_command)
|
||||
|
||||
COMMAND_HANDLER(buspirate_handle_port_command)
|
||||
{
|
||||
if (CMD_ARGC < 1) {
|
||||
if (CMD_ARGC < 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (buspirate_port == NULL)
|
||||
buspirate_port = strdup(CMD_ARGV[0]);
|
||||
@@ -987,8 +978,6 @@ static void buspirate_print_buffer(char *buf, int size)
|
||||
}
|
||||
}
|
||||
|
||||
if (line[0] != 0) {
|
||||
if (line[0] != 0)
|
||||
LOG_DEBUG("%s", line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -37,8 +38,7 @@
|
||||
#include <jtag/minidriver.h>
|
||||
#include <helper/command.h>
|
||||
|
||||
struct jtag_callback_entry
|
||||
{
|
||||
struct jtag_callback_entry {
|
||||
struct jtag_callback_entry *next;
|
||||
|
||||
jtag_callback_t callback;
|
||||
@@ -48,8 +48,8 @@ struct jtag_callback_entry
|
||||
jtag_callback_data_t data3;
|
||||
};
|
||||
|
||||
static struct jtag_callback_entry *jtag_callback_queue_head = NULL;
|
||||
static struct jtag_callback_entry *jtag_callback_queue_tail = NULL;
|
||||
static struct jtag_callback_entry *jtag_callback_queue_head;
|
||||
static struct jtag_callback_entry *jtag_callback_queue_tail;
|
||||
|
||||
static void jtag_callback_queue_reset(void)
|
||||
{
|
||||
@@ -62,60 +62,56 @@ static void jtag_callback_queue_reset(void)
|
||||
*
|
||||
* This allocates a new copy of out_value using cmd_queue_alloc.
|
||||
*/
|
||||
static void cmd_queue_scan_field_clone(struct scan_field * dst, const struct scan_field * src)
|
||||
static void cmd_queue_scan_field_clone(struct scan_field *dst, const struct scan_field *src)
|
||||
{
|
||||
dst->num_bits = src->num_bits;
|
||||
dst->out_value = buf_cpy(src->out_value, cmd_queue_alloc(DIV_ROUND_UP(src->num_bits, 8)), src->num_bits);
|
||||
dst->in_value = src->in_value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* see jtag_add_ir_scan()
|
||||
*
|
||||
*/
|
||||
int interface_jtag_add_ir_scan(struct jtag_tap* active, const struct scan_field *in_fields, tap_state_t state)
|
||||
int interface_jtag_add_ir_scan(struct jtag_tap *active,
|
||||
const struct scan_field *in_fields, tap_state_t state)
|
||||
{
|
||||
size_t num_taps = jtag_tap_count_enabled();
|
||||
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
|
||||
struct scan_field * out_fields = cmd_queue_alloc(num_taps * sizeof(struct scan_field));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct scan_command *scan = cmd_queue_alloc(sizeof(struct scan_command));
|
||||
struct scan_field *out_fields = cmd_queue_alloc(num_taps * sizeof(struct scan_field));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
cmd->type = JTAG_SCAN;
|
||||
cmd->cmd.scan = scan;
|
||||
cmd->type = JTAG_SCAN;
|
||||
cmd->cmd.scan = scan;
|
||||
|
||||
scan->ir_scan = true;
|
||||
scan->num_fields = num_taps; /* one field per device */
|
||||
scan->fields = out_fields;
|
||||
scan->end_state = state;
|
||||
scan->ir_scan = true;
|
||||
scan->num_fields = num_taps; /* one field per device */
|
||||
scan->fields = out_fields;
|
||||
scan->end_state = state;
|
||||
|
||||
|
||||
struct scan_field * field = out_fields; /* keep track where we insert data */
|
||||
struct scan_field *field = out_fields; /* keep track where we insert data */
|
||||
|
||||
/* loop over all enabled TAPs */
|
||||
|
||||
for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
|
||||
{
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
|
||||
/* search the input field list for fields for the current TAP */
|
||||
|
||||
if (tap == active)
|
||||
{
|
||||
if (tap == active) {
|
||||
/* if TAP is listed in input fields, copy the value */
|
||||
tap->bypass = 0;
|
||||
|
||||
cmd_queue_scan_field_clone(field, in_fields);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
/* if a TAP isn't listed in input fields, set it to BYPASS */
|
||||
|
||||
tap->bypass = 1;
|
||||
|
||||
field->num_bits = tap->ir_length;
|
||||
field->out_value = buf_set_ones(cmd_queue_alloc(DIV_ROUND_UP(tap->ir_length, 8)), tap->ir_length);
|
||||
field->in_value = NULL; /* do not collect input for tap's in bypass */
|
||||
field->num_bits = tap->ir_length;
|
||||
field->out_value = buf_set_ones(cmd_queue_alloc(DIV_ROUND_UP(tap->ir_length, 8)), tap->ir_length);
|
||||
field->in_value = NULL; /* do not collect input for tap's in bypass */
|
||||
}
|
||||
|
||||
/* update device information */
|
||||
@@ -123,8 +119,8 @@ int interface_jtag_add_ir_scan(struct jtag_tap* active, const struct scan_field
|
||||
|
||||
field++;
|
||||
}
|
||||
|
||||
assert(field == out_fields + num_taps); /* paranoia: jtag_tap_count_enabled() and jtag_tap_next_enabled() not in sync */
|
||||
/* paranoia: jtag_tap_count_enabled() and jtag_tap_next_enabled() not in sync */
|
||||
assert(field == out_fields + num_taps);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -133,51 +129,47 @@ int interface_jtag_add_ir_scan(struct jtag_tap* active, const struct scan_field
|
||||
* see jtag_add_dr_scan()
|
||||
*
|
||||
*/
|
||||
int interface_jtag_add_dr_scan(struct jtag_tap* active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
|
||||
int interface_jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields,
|
||||
const struct scan_field *in_fields, tap_state_t state)
|
||||
{
|
||||
/* count devices in bypass */
|
||||
|
||||
size_t bypass_devices = 0;
|
||||
|
||||
for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
|
||||
{
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
|
||||
if (tap->bypass)
|
||||
bypass_devices++;
|
||||
}
|
||||
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
|
||||
struct scan_field * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct scan_command *scan = cmd_queue_alloc(sizeof(struct scan_command));
|
||||
struct scan_field *out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
cmd->type = JTAG_SCAN;
|
||||
cmd->cmd.scan = scan;
|
||||
cmd->type = JTAG_SCAN;
|
||||
cmd->cmd.scan = scan;
|
||||
|
||||
scan->ir_scan = false;
|
||||
scan->num_fields = in_num_fields + bypass_devices;
|
||||
scan->fields = out_fields;
|
||||
scan->end_state = state;
|
||||
scan->ir_scan = false;
|
||||
scan->num_fields = in_num_fields + bypass_devices;
|
||||
scan->fields = out_fields;
|
||||
scan->end_state = state;
|
||||
|
||||
|
||||
struct scan_field * field = out_fields; /* keep track where we insert data */
|
||||
struct scan_field *field = out_fields; /* keep track where we insert data */
|
||||
|
||||
/* loop over all enabled TAPs */
|
||||
|
||||
for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
|
||||
{
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
|
||||
/* if TAP is not bypassed insert matching input fields */
|
||||
|
||||
if (!tap->bypass)
|
||||
{
|
||||
if (!tap->bypass) {
|
||||
assert(active == tap);
|
||||
#ifndef NDEBUG
|
||||
/* remember initial position for assert() */
|
||||
struct scan_field *start_field = field;
|
||||
#endif /* NDEBUG */
|
||||
|
||||
for (int j = 0; j < in_num_fields; j++)
|
||||
{
|
||||
for (int j = 0; j < in_num_fields; j++) {
|
||||
cmd_queue_scan_field_clone(field, in_fields + j);
|
||||
|
||||
field++;
|
||||
@@ -187,11 +179,10 @@ int interface_jtag_add_dr_scan(struct jtag_tap* active, int in_num_fields, const
|
||||
}
|
||||
|
||||
/* if a TAP is bypassed, generated a dummy bit*/
|
||||
else
|
||||
{
|
||||
field->num_bits = 1;
|
||||
field->out_value = NULL;
|
||||
field->in_value = NULL;
|
||||
else {
|
||||
field->num_bits = 1;
|
||||
field->out_value = NULL;
|
||||
field->in_value = NULL;
|
||||
|
||||
field++;
|
||||
}
|
||||
@@ -202,8 +193,6 @@ int interface_jtag_add_dr_scan(struct jtag_tap* active, int in_num_fields, const
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate a DR SCAN using the array of output values passed to the function
|
||||
*
|
||||
@@ -228,65 +217,60 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
|
||||
|
||||
size_t bypass_devices = 0;
|
||||
|
||||
for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
|
||||
{
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
|
||||
if (tap->bypass)
|
||||
bypass_devices++;
|
||||
}
|
||||
|
||||
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
|
||||
struct scan_field * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct scan_command *scan = cmd_queue_alloc(sizeof(struct scan_command));
|
||||
struct scan_field *out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
cmd->type = JTAG_SCAN;
|
||||
cmd->cmd.scan = scan;
|
||||
cmd->type = JTAG_SCAN;
|
||||
cmd->cmd.scan = scan;
|
||||
|
||||
scan->ir_scan = false;
|
||||
scan->num_fields = in_num_fields + bypass_devices;
|
||||
scan->fields = out_fields;
|
||||
scan->end_state = end_state;
|
||||
scan->ir_scan = false;
|
||||
scan->num_fields = in_num_fields + bypass_devices;
|
||||
scan->fields = out_fields;
|
||||
scan->end_state = end_state;
|
||||
|
||||
|
||||
bool target_tap_match = false;
|
||||
|
||||
struct scan_field * field = out_fields; /* keep track where we insert data */
|
||||
struct scan_field *field = out_fields; /* keep track where we insert data */
|
||||
|
||||
/* loop over all enabled TAPs */
|
||||
|
||||
for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap))
|
||||
{
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
|
||||
/* if TAP is not bypassed insert matching input fields */
|
||||
|
||||
if (!tap->bypass)
|
||||
{
|
||||
if (!tap->bypass) {
|
||||
assert(tap == target_tap); /* target_tap must match the one not bypassed TAP */
|
||||
|
||||
target_tap_match = true;
|
||||
|
||||
for (int j = 0; j < in_num_fields; j++)
|
||||
{
|
||||
for (int j = 0; j < in_num_fields; j++) {
|
||||
uint8_t out_value[4];
|
||||
size_t scan_size = num_bits[j];
|
||||
buf_set_u32(out_value, 0, scan_size, value[j]);
|
||||
|
||||
field->num_bits = scan_size;
|
||||
field->out_value = buf_cpy(out_value, cmd_queue_alloc(DIV_ROUND_UP(scan_size, 8)), scan_size);
|
||||
field->in_value = NULL;
|
||||
field->num_bits = scan_size;
|
||||
field->out_value = buf_cpy(out_value, cmd_queue_alloc(DIV_ROUND_UP(scan_size, 8)), scan_size);
|
||||
field->in_value = NULL;
|
||||
|
||||
field++;
|
||||
}
|
||||
}
|
||||
|
||||
/* if a TAP is bypassed, generated a dummy bit*/
|
||||
else
|
||||
{
|
||||
else {
|
||||
|
||||
field->num_bits = 1;
|
||||
field->out_value = NULL;
|
||||
field->in_value = NULL;
|
||||
field->num_bits = 1;
|
||||
field->out_value = NULL;
|
||||
field->in_value = NULL;
|
||||
|
||||
field++;
|
||||
}
|
||||
@@ -298,23 +282,23 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
|
||||
static int jtag_add_plain_scan(int num_bits, const uint8_t *out_bits,
|
||||
uint8_t *in_bits, tap_state_t state, bool ir_scan)
|
||||
{
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command));
|
||||
struct scan_field * out_fields = cmd_queue_alloc(sizeof(struct scan_field));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct scan_command *scan = cmd_queue_alloc(sizeof(struct scan_command));
|
||||
struct scan_field *out_fields = cmd_queue_alloc(sizeof(struct scan_field));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
cmd->type = JTAG_SCAN;
|
||||
cmd->cmd.scan = scan;
|
||||
cmd->type = JTAG_SCAN;
|
||||
cmd->cmd.scan = scan;
|
||||
|
||||
scan->ir_scan = ir_scan;
|
||||
scan->num_fields = 1;
|
||||
scan->fields = out_fields;
|
||||
scan->end_state = state;
|
||||
scan->ir_scan = ir_scan;
|
||||
scan->num_fields = 1;
|
||||
scan->fields = out_fields;
|
||||
scan->end_state = state;
|
||||
|
||||
out_fields->num_bits = num_bits;
|
||||
out_fields->out_value = buf_cpy(out_bits, cmd_queue_alloc(DIV_ROUND_UP(num_bits, 8)), num_bits);
|
||||
out_fields->in_value = in_bits;
|
||||
out_fields->num_bits = num_bits;
|
||||
out_fields->out_value = buf_cpy(out_bits, cmd_queue_alloc(DIV_ROUND_UP(num_bits, 8)), num_bits);
|
||||
out_fields->in_value = in_bits;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -334,7 +318,7 @@ int interface_jtag_add_tlr(void)
|
||||
tap_state_t state = TAP_RESET;
|
||||
|
||||
/* allocate memory for a new list member */
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
@@ -374,7 +358,7 @@ int interface_add_tms_seq(unsigned num_bits, const uint8_t *seq, enum tap_state
|
||||
int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
|
||||
{
|
||||
/* allocate memory for a new list member */
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
@@ -393,7 +377,7 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
|
||||
int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
|
||||
{
|
||||
/* allocate memory for a new list member */
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
@@ -409,7 +393,7 @@ int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
|
||||
int interface_jtag_add_clocks(int num_cycles)
|
||||
{
|
||||
/* allocate memory for a new list member */
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
@@ -424,7 +408,7 @@ int interface_jtag_add_clocks(int num_cycles)
|
||||
int interface_jtag_add_reset(int req_trst, int req_srst)
|
||||
{
|
||||
/* allocate memory for a new list member */
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
@@ -440,7 +424,7 @@ int interface_jtag_add_reset(int req_trst, int req_srst)
|
||||
int interface_jtag_add_sleep(uint32_t us)
|
||||
{
|
||||
/* allocate memory for a new list member */
|
||||
struct jtag_command * cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
struct jtag_command *cmd = cmd_queue_alloc(sizeof(struct jtag_command));
|
||||
|
||||
jtag_queue_command(cmd);
|
||||
|
||||
@@ -453,7 +437,9 @@ int interface_jtag_add_sleep(uint32_t us)
|
||||
}
|
||||
|
||||
/* add callback to end of queue */
|
||||
void interface_jtag_add_callback4(jtag_callback_t callback, jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
|
||||
void interface_jtag_add_callback4(jtag_callback_t callback,
|
||||
jtag_callback_data_t data0, jtag_callback_data_t data1,
|
||||
jtag_callback_data_t data2, jtag_callback_data_t data3)
|
||||
{
|
||||
struct jtag_callback_entry *entry = cmd_queue_alloc(sizeof(struct jtag_callback_entry));
|
||||
|
||||
@@ -464,12 +450,10 @@ void interface_jtag_add_callback4(jtag_callback_t callback, jtag_callback_data_t
|
||||
entry->data2 = data2;
|
||||
entry->data3 = data3;
|
||||
|
||||
if (jtag_callback_queue_head == NULL)
|
||||
{
|
||||
if (jtag_callback_queue_head == NULL) {
|
||||
jtag_callback_queue_head = entry;
|
||||
jtag_callback_queue_tail = entry;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
jtag_callback_queue_tail->next = entry;
|
||||
jtag_callback_queue_tail = entry;
|
||||
}
|
||||
@@ -477,17 +461,15 @@ void interface_jtag_add_callback4(jtag_callback_t callback, jtag_callback_data_t
|
||||
|
||||
int interface_jtag_execute_queue(void)
|
||||
{
|
||||
static int reentry = 0;
|
||||
static int reentry;
|
||||
|
||||
assert(reentry==0);
|
||||
assert(reentry == 0);
|
||||
reentry++;
|
||||
|
||||
int retval = default_interface_jtag_execute_queue();
|
||||
if (retval == ERROR_OK)
|
||||
{
|
||||
if (retval == ERROR_OK) {
|
||||
struct jtag_callback_entry *entry;
|
||||
for (entry = jtag_callback_queue_head; entry != NULL; entry = entry->next)
|
||||
{
|
||||
for (entry = jtag_callback_queue_head; entry != NULL; entry = entry->next) {
|
||||
retval = entry->callback(entry->data0, entry->data1, entry->data2, entry->data3);
|
||||
if (retval != ERROR_OK)
|
||||
break;
|
||||
@@ -502,7 +484,8 @@ int interface_jtag_execute_queue(void)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int jtag_convert_to_callback4(jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
|
||||
static int jtag_convert_to_callback4(jtag_callback_data_t data0,
|
||||
jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
|
||||
{
|
||||
((jtag_callback1_t)data1)(data0);
|
||||
return ERROR_OK;
|
||||
@@ -513,10 +496,9 @@ void interface_jtag_add_callback(jtag_callback1_t callback, jtag_callback_data_t
|
||||
jtag_add_callback4(jtag_convert_to_callback4, data0, (jtag_callback_data_t)callback, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/* A minidriver can use use an inline versions of this API level fn */
|
||||
void jtag_add_dr_out(struct jtag_tap* tap,
|
||||
int num_fields, const int* num_bits, const uint32_t* value,
|
||||
void jtag_add_dr_out(struct jtag_tap *tap,
|
||||
int num_fields, const int *num_bits, const uint32_t *value,
|
||||
tap_state_t end_state)
|
||||
{
|
||||
assert(end_state != TAP_RESET);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -25,17 +26,15 @@
|
||||
#include "bitbang.h"
|
||||
#include "hello.h"
|
||||
|
||||
|
||||
/* my private tap controller state, which tracks state for calling code */
|
||||
static tap_state_t dummy_state = TAP_RESET;
|
||||
|
||||
static int dummy_clock; /* edge detector */
|
||||
static int dummy_clock; /* edge detector */
|
||||
|
||||
static int clock_count; /* count clocks in any stable state, only stable states */
|
||||
static int clock_count; /* count clocks in any stable state, only stable states */
|
||||
|
||||
static uint32_t dummy_data;
|
||||
|
||||
|
||||
static int dummy_read(void)
|
||||
{
|
||||
int data = 1 & dummy_data;
|
||||
@@ -43,21 +42,16 @@ static int dummy_read(void)
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static void dummy_write(int tck, int tms, int tdi)
|
||||
{
|
||||
/* TAP standard: "state transitions occur on rising edge of clock" */
|
||||
if (tck != dummy_clock)
|
||||
{
|
||||
if (tck)
|
||||
{
|
||||
if (tck != dummy_clock) {
|
||||
if (tck) {
|
||||
tap_state_t old_state = dummy_state;
|
||||
dummy_state = tap_state_transition(old_state, tms);
|
||||
|
||||
if (old_state != dummy_state)
|
||||
{
|
||||
if (clock_count)
|
||||
{
|
||||
if (old_state != dummy_state) {
|
||||
if (clock_count) {
|
||||
LOG_DEBUG("dummy_tap: %d stable clocks", clock_count);
|
||||
clock_count = 0;
|
||||
}
|
||||
@@ -68,9 +62,7 @@ static void dummy_write(int tck, int tms, int tdi)
|
||||
if (dummy_state == TAP_DRCAPTURE)
|
||||
dummy_data = 0x01255043;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* this is a stable state clock edge, no change of state here,
|
||||
* simply increment clock_count for subsequent logging
|
||||
*/
|
||||
@@ -102,30 +94,21 @@ static struct bitbang_interface dummy_bitbang = {
|
||||
.blink = &dummy_led,
|
||||
};
|
||||
|
||||
|
||||
static int dummy_khz(int khz, int *jtag_speed)
|
||||
{
|
||||
if (khz == 0)
|
||||
{
|
||||
*jtag_speed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*jtag_speed = 64000/khz;
|
||||
}
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int dummy_speed_div(int speed, int *khz)
|
||||
{
|
||||
if (speed == 0)
|
||||
{
|
||||
*khz = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*khz = 64000/speed;
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user