|
|
|
|
@ -62,7 +62,7 @@ Provides definitions about: |
|
|
|
|
|
|
|
|
|
/// Indicate that JTAG communication mode is available at the Debug Port.
|
|
|
|
|
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
|
|
|
|
|
#define DAP_JTAG 1 ///< JTAG Mode: 1 = available, 0 = not available.
|
|
|
|
|
#define DAP_JTAG 0 ///< JTAG Mode: 1 = available, 0 = not available.
|
|
|
|
|
|
|
|
|
|
/// Configure maximum number of JTAG devices on the scan chain connected to the Debug Access Port.
|
|
|
|
|
/// This setting impacts the RAM requirements of the Debug Unit. Valid range is 1 .. 255.
|
|
|
|
|
@ -139,19 +139,19 @@ of the same I/O port. The following SWDIO I/O Pin functions are provided: |
|
|
|
|
|
|
|
|
|
// Configure DAP I/O pins ------------------------------
|
|
|
|
|
|
|
|
|
|
#define TMS_SWDIO RTS |
|
|
|
|
#define TMS_SWDIO CTS |
|
|
|
|
#define TCK_SWCLK TXD |
|
|
|
|
#define TDO_SWO RXD |
|
|
|
|
#define TDI DCD |
|
|
|
|
#define nRESET DTR |
|
|
|
|
#define TDI DTR |
|
|
|
|
#define nRESET DCD |
|
|
|
|
#define nTRST RI |
|
|
|
|
#define LED_CONN CTS |
|
|
|
|
#define LED_CONN RTS |
|
|
|
|
#define LED_RUN DSR |
|
|
|
|
|
|
|
|
|
static __inline const char* pin_to_str(uint8_t pin){ |
|
|
|
|
switch(pin){ |
|
|
|
|
case TMS_SWDIO: |
|
|
|
|
return "TMS_SWDIO(RTS)"; |
|
|
|
|
return "TMS_SWDIO(CTS)"; |
|
|
|
|
case TCK_SWCLK: |
|
|
|
|
return "TCK_SWCLK(TXD)"; |
|
|
|
|
case TDO_SWO: |
|
|
|
|
@ -159,11 +159,11 @@ static __inline const char* pin_to_str(uint8_t pin){ |
|
|
|
|
case TDI: |
|
|
|
|
return "TDI(DCD)"; |
|
|
|
|
case nRESET: |
|
|
|
|
return "nRESET(DTR)"; |
|
|
|
|
return "nRESET(DTR)"; |
|
|
|
|
case nTRST: |
|
|
|
|
return "nTRST(RI)"; |
|
|
|
|
case LED_CONN: |
|
|
|
|
return "LED_CONN(CTS)"; |
|
|
|
|
return "LED_CONN(RTS)"; |
|
|
|
|
case LED_RUN: |
|
|
|
|
return "LED_RUN(DSR)"; |
|
|
|
|
default: |
|
|
|
|
@ -171,34 +171,36 @@ static __inline const char* pin_to_str(uint8_t pin){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static __inline void FTDI_BITBANG_SETUP() { |
|
|
|
|
static __inline int FTDI_BITBANG_SETUP() { |
|
|
|
|
int success; |
|
|
|
|
/* Enable bitbang mode */ |
|
|
|
|
success = ftdi_set_bitmode(&__ftdic, dir_state, BITMODE_BITBANG ); |
|
|
|
|
if( success<0 ){ |
|
|
|
|
DEBUGF("Could not change to async. bitbang: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not change to async. bitbang: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
success = ftdi_write_data(&__ftdic,&out_state,1); |
|
|
|
|
if( success < 0){ |
|
|
|
|
DEBUGF("Could not write pins: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not write pins: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
return -2; |
|
|
|
|
} |
|
|
|
|
/*ftdi_read_data_set_chunksize(&__ftdic,1);
|
|
|
|
|
ftdi_write_data_set_chunksize(&__ftdic,1);*/ |
|
|
|
|
ftdi_read_data_set_chunksize(&__ftdic,64); |
|
|
|
|
ftdi_write_data_set_chunksize(&__ftdic,64); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static __forceinline void FTDI_WRITE_OUT_READ_MODE( ) { |
|
|
|
|
int success = ftdi_write_data(&__ftdic,out_state_buff,out_state_buff_pos); |
|
|
|
|
if( success<0 ){ |
|
|
|
|
DEBUGF("Could not write pins: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not write pins: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static __forceinline void FTDI_WRITE_OUT( ) { |
|
|
|
|
int success; |
|
|
|
|
if( out_state_buff_pos==0 ){ |
|
|
|
|
DEBUGF("buffer is empty %d \n",out_state_buff_pos); |
|
|
|
|
DPRINTF("buffer is empty %d \n",out_state_buff_pos); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
FTDI_WRITE_OUT_READ_MODE( ); |
|
|
|
|
@ -211,7 +213,7 @@ static __forceinline void FTDI_SUBMIT( ) { |
|
|
|
|
out_state_buff[out_state_buff_pos] = out_state; |
|
|
|
|
out_state_buff_pos++; |
|
|
|
|
if( out_state_buff_pos>=BUFFER_SIZE ){ |
|
|
|
|
DEBUG("FTDI bitbang-buffer overflow!\n"); |
|
|
|
|
DPRINT("FTDI bitbang-buffer overflow!\n"); |
|
|
|
|
FTDI_WRITE_OUT( ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -224,14 +226,12 @@ static __inline void FTDI_BEGIN_READ(){ |
|
|
|
|
|
|
|
|
|
int success = ftdi_set_bitmode(&__ftdic, dir_state, BITMODE_SYNCBB ); |
|
|
|
|
if( success<0 ){ |
|
|
|
|
DEBUGF("Could not change to sync. bitbang: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not change to sync. bitbang: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
} |
|
|
|
|
success = ftdi_usb_purge_buffers(&__ftdic); |
|
|
|
|
if( success<0 ){ |
|
|
|
|
DEBUGF("Could not flush buffer: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not flush buffer: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//memset ( pin_read_buff, 0, BUFFER_SIZE*sizeof(int) );
|
|
|
|
|
is_in_read_mode = 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -245,13 +245,13 @@ static __inline void FTDI_END_READ(){ |
|
|
|
|
while( remaining ){ |
|
|
|
|
success = ftdi_read_data(&__ftdic,ptr,remaining); |
|
|
|
|
if( success<0 ){ |
|
|
|
|
DEBUGF("Error while read: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Error while read: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
ptr+=success; |
|
|
|
|
remaining-=success; |
|
|
|
|
} |
|
|
|
|
DEBUGF("Read %d/%d bytes\n",(int)(ptr-in_buff),out_state_buff_pos); |
|
|
|
|
DPRINTF("Read %d/%d bytes\n",(int)(ptr-in_buff),out_state_buff_pos); |
|
|
|
|
out_state_buff_pos = 0; |
|
|
|
|
|
|
|
|
|
for(i=0;i<pin_read_pos;i++){ |
|
|
|
|
@ -266,10 +266,43 @@ static __inline void FTDI_END_READ(){ |
|
|
|
|
|
|
|
|
|
success = ftdi_set_bitmode(&__ftdic, dir_state, BITMODE_BITBANG ); |
|
|
|
|
if( success<0 ){ |
|
|
|
|
DEBUGF("Could not change to async. bitbang: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not change to async. bitbang: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static __inline uint8_t bit_count8(uint8_t v){ |
|
|
|
|
/*
|
|
|
|
|
* http://stackoverflow.com/questions/3815165/how-to-implement-bitcount-using-only-bitwise-operators
|
|
|
|
|
* 0x55=01010101, 0x33=00110011, 0x0F=00001111 |
|
|
|
|
* v = [v7][v6][v5][v4][v3][v2][v1][v0] |
|
|
|
|
* 1. |
|
|
|
|
* c = 0[v6]0[v4]0[v2]0[v0] + 0[v7]0[v5]0[v3]0[v1] |
|
|
|
|
* c = [v7+v6][v5+v4][v3+v2][v1+v0] |
|
|
|
|
* 2. |
|
|
|
|
* c = 00[v5+v4]00[v1+v0] + 00[v7+v6]00[v3+v2] |
|
|
|
|
* c = [v7+v6+v5+v4][v3+v2+v1+v0] |
|
|
|
|
* 3. |
|
|
|
|
* c = 0000[v3+v2+v1+v0] + c=0000[v7+v6+v5+v4] |
|
|
|
|
* c = [v7+v6+v5+v4+v3+v2+v1+v0] |
|
|
|
|
*/ |
|
|
|
|
uint8_t c = 0; |
|
|
|
|
c = (v & 0x55) + ((v >> 1) & 0x55) ; |
|
|
|
|
c = (c & 0x33) + ((c >> 2) & 0x33); |
|
|
|
|
c = (c & 0x0F) + ((c >> 4) & 0x0F); |
|
|
|
|
return c; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static __inline uint8_t bit_count32(uint32_t v){ |
|
|
|
|
uint32_t c = 0; |
|
|
|
|
c = (v & 0x55555555) + ((v >> 1) & 0x55555555) ; |
|
|
|
|
c = (c & 0x33333333) + ((c >> 2) & 0x33333333) ; |
|
|
|
|
c = (c & 0x0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F) ; |
|
|
|
|
c = (c & 0x00FF00FF) + ((c >> 8) & 0x00FF00FF) ; |
|
|
|
|
c = (c & 0x0000FFFF) + ((c >>16) & 0x0000FFFF) ; |
|
|
|
|
|
|
|
|
|
return c; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//**************************************************************************************************
|
|
|
|
|
/**
|
|
|
|
|
\defgroup DAP_Config_Initialization_gr CMSIS-DAP Initialization |
|
|
|
|
@ -309,27 +342,29 @@ Status LEDs. In detail the operation of Hardware I/O and LED pins are enabled an |
|
|
|
|
- for nTRST, nRESET a weak pull-up (if available) is enabled. |
|
|
|
|
- LED output pins are enabled and LEDs are turned off. |
|
|
|
|
*/ |
|
|
|
|
static __inline void DAP_SETUP (void) { |
|
|
|
|
static __inline int DAP_SETUP (void) { |
|
|
|
|
/* Initialize context for subsequent function calls */ |
|
|
|
|
ftdi_init(&__ftdic); |
|
|
|
|
int success; |
|
|
|
|
/* Open FTDI device based on FT232R vendor & product IDs */ |
|
|
|
|
success = ftdi_usb_open(&__ftdic, VID, PID); |
|
|
|
|
if(success < 0) { |
|
|
|
|
DEBUGF("Can't open device [%x:%x]: %s\n",VID,PID,ftdi_get_error_string(&__ftdic)); |
|
|
|
|
exit(1); |
|
|
|
|
DPRINTF("Can't open device [%x:%x]: %s\n",VID,PID,ftdi_get_error_string(&__ftdic)); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dir_state = LED_CONN|LED_RUN|TCK_SWCLK|nRESET; |
|
|
|
|
out_state = 0xFF;// & ~(LED_CONN|LED_RUN);
|
|
|
|
|
FTDI_BITBANG_SETUP(); |
|
|
|
|
if( FTDI_BITBANG_SETUP() < 0 ){ |
|
|
|
|
return -2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
success = ftdi_set_baudrate (&__ftdic, DAP_DEFAULT_SWJ_CLOCK/2); |
|
|
|
|
if( success < 0){ |
|
|
|
|
DEBUGF("Could not set baudrate: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not set baudrate: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
/* not critical */ |
|
|
|
|
} |
|
|
|
|
/*uint8_t foo;
|
|
|
|
|
success = ftdi_read_data(&__ftdic,&foo,1);*/ |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///@}
|
|
|
|
|
@ -359,21 +394,54 @@ static __inline void PORT_SWD_SETUP (void) { |
|
|
|
|
FTDI_BITBANG_SETUP(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static __forceinline uint32_t PIN_IN ( uint8_t pin ) { |
|
|
|
|
static __forceinline uint32_t PIN_IN_NOBUFF ( uint8_t pin ) { |
|
|
|
|
uint8_t c; |
|
|
|
|
if( dir_state & pin ){ |
|
|
|
|
DEBUGF("Pin %s is not an input pin!\n", pin_to_str(pin)); |
|
|
|
|
DPRINTF("Pin %s is not an input pin!\n", pin_to_str(pin)); |
|
|
|
|
} |
|
|
|
|
int success = ftdi_read_pins(&__ftdic,&c); |
|
|
|
|
if(success < 0){ |
|
|
|
|
DEBUGF("Could not read pin: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not read pin: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
} |
|
|
|
|
return (c & pin)!=0 ? 1 : 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static __forceinline void PIN_IN(uint8_t pin, uint8_t *ptr,uint8_t bit) { |
|
|
|
|
if( !is_in_read_mode ){ |
|
|
|
|
DPRINT("Not in read mode!\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if( ptr!=NULL ){ |
|
|
|
|
read_slot = ptr; |
|
|
|
|
if( bit_count8(bit)==1 ){ |
|
|
|
|
pin_read_mask=bit; |
|
|
|
|
}else{ |
|
|
|
|
pin_read_mask=1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* correlate the read with the output buffer */ |
|
|
|
|
pin_read_buff[pin_read_pos].pos = out_state_buff_pos; |
|
|
|
|
pin_read_buff[pin_read_pos].write_bitmask = pin_read_mask; |
|
|
|
|
pin_read_buff[pin_read_pos].read_bitmask = pin; |
|
|
|
|
|
|
|
|
|
pin_read_buff[pin_read_pos].ptr = read_slot; |
|
|
|
|
pin_read_mask = pin_read_mask<<1; |
|
|
|
|
if( !pin_read_mask ){ |
|
|
|
|
pin_read_mask = 1; |
|
|
|
|
read_slot += 1; |
|
|
|
|
} |
|
|
|
|
pin_read_pos++; |
|
|
|
|
|
|
|
|
|
if( pin_read_pos==BUFFER_SIZE ){ |
|
|
|
|
DPRINT("read buffer overflow!\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static __forceinline void PIN_SET ( uint8_t pin, uint32_t bit ) { |
|
|
|
|
if( !(dir_state & pin) ){ |
|
|
|
|
DEBUGF("Pin %s is not an output pin!\n", pin_to_str(pin)); |
|
|
|
|
DPRINTF("Pin %s is not an output pin!\n", pin_to_str(pin)); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
/*if(bit & ~1){
|
|
|
|
|
@ -386,7 +454,7 @@ static __forceinline void PIN_SET ( uint8_t pin, uint32_t bit ) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
extern void late_close_socket(); |
|
|
|
|
extern void deinit(); |
|
|
|
|
/** Disable JTAG/SWD I/O Pins.
|
|
|
|
|
Disables the DAP Hardware I/O pins which configures: |
|
|
|
|
- TCK/SWCLK, TMS/SWDIO, TDI, TDO, nTRST, nRESET to High-Z mode. |
|
|
|
|
@ -395,7 +463,7 @@ static __inline void PORT_OFF (void) { |
|
|
|
|
//TODO HighZ?
|
|
|
|
|
/*ftdi_disable_bitbang(&__ftdic);
|
|
|
|
|
ftdi_deinit(&__ftdic); TODO */ |
|
|
|
|
late_close_socket(); |
|
|
|
|
deinit(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -404,8 +472,8 @@ static __inline void PORT_OFF (void) { |
|
|
|
|
/** SWCLK/TCK I/O pin: Get Input.
|
|
|
|
|
\return Current status of the SWCLK/TCK DAP hardware I/O pin. |
|
|
|
|
*/ |
|
|
|
|
static __forceinline uint32_t PIN_SWCLK_TCK_IN (void) { |
|
|
|
|
return PIN_IN(TCK_SWCLK); |
|
|
|
|
static __forceinline void PIN_SWCLK_TCK_IN (uint8_t *ptr,uint8_t bit){ |
|
|
|
|
PIN_IN( TCK_SWCLK, ptr, bit ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** SWCLK/TCK I/O pin: Set Output to High.
|
|
|
|
|
@ -428,8 +496,8 @@ static __forceinline void PIN_SWCLK_TCK_CLR (void) { |
|
|
|
|
/** SWDIO/TMS I/O pin: Get Input.
|
|
|
|
|
\return Current status of the SWDIO/TMS DAP hardware I/O pin. |
|
|
|
|
*/ |
|
|
|
|
static __forceinline uint32_t PIN_SWDIO_TMS_IN (void) { |
|
|
|
|
return PIN_IN(TMS_SWDIO); |
|
|
|
|
static __forceinline void PIN_SWDIO_TMS_IN (uint8_t *ptr,uint8_t bit){ |
|
|
|
|
PIN_IN( TMS_SWDIO, ptr, bit ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** SWDIO/TMS I/O pin: Set Output to High.
|
|
|
|
|
@ -447,72 +515,11 @@ static __forceinline void PIN_SWDIO_TMS_CLR (void) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static __inline uint8_t bit_count8(uint8_t v){ |
|
|
|
|
/*
|
|
|
|
|
* http://stackoverflow.com/questions/3815165/how-to-implement-bitcount-using-only-bitwise-operators
|
|
|
|
|
* 0x55=01010101, 0x33=00110011, 0x0F=00001111 |
|
|
|
|
* v = [v7][v6][v5][v4][v3][v2][v1][v0] |
|
|
|
|
* 1. |
|
|
|
|
* c = 0[v6]0[v4]0[v2]0[v0] + 0[v7]0[v5]0[v3]0[v1] |
|
|
|
|
* c = [v7+v6][v5+v4][v3+v2][v1+v0] |
|
|
|
|
* 2. |
|
|
|
|
* c = 00[v5+v4]00[v1+v0] + 00[v7+v6]00[v3+v2] |
|
|
|
|
* c = [v7+v6+v5+v4][v3+v2+v1+v0] |
|
|
|
|
* 3. |
|
|
|
|
* c = 0000[v3+v2+v1+v0] + c=0000[v7+v6+v5+v4] |
|
|
|
|
* c = [v7+v6+v5+v4+v3+v2+v1+v0] |
|
|
|
|
*/ |
|
|
|
|
uint8_t c = 0; |
|
|
|
|
c = (v & 0x55) + ((v >> 1) & 0x55) ; |
|
|
|
|
c = (c & 0x33) + ((c >> 2) & 0x33); |
|
|
|
|
c = (c & 0x0F) + ((c >> 4) & 0x0F); |
|
|
|
|
return c; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static __inline uint8_t bit_count32(uint32_t v){ |
|
|
|
|
uint32_t c = 0; |
|
|
|
|
c = (v & 0x55555555) + ((v >> 1) & 0x55555555) ; |
|
|
|
|
c = (c & 0x33333333) + ((c >> 2) & 0x33333333) ; |
|
|
|
|
c = (c & 0x0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F) ; |
|
|
|
|
c = (c & 0x00FF00FF) + ((c >> 8) & 0x00FF00FF) ; |
|
|
|
|
c = (c & 0x0000FFFF) + ((c >>16) & 0x0000FFFF) ; |
|
|
|
|
|
|
|
|
|
return c; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** SWDIO I/O pin: Get Input (used in SWD mode only).
|
|
|
|
|
\return Current status of the SWDIO DAP hardware I/O pin. |
|
|
|
|
*/ |
|
|
|
|
static __forceinline void PIN_SWDIO_IN (uint8_t *ptr,uint8_t bit){ |
|
|
|
|
if( !is_in_read_mode ){ |
|
|
|
|
DEBUG("Not in read mode!\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if( ptr!=NULL ){ |
|
|
|
|
read_slot = ptr; |
|
|
|
|
if( bit_count8(bit)==1 ){ |
|
|
|
|
pin_read_mask=bit; |
|
|
|
|
}else{ |
|
|
|
|
pin_read_mask=1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* correlate the read with the output buffer */ |
|
|
|
|
pin_read_buff[pin_read_pos].pos = out_state_buff_pos; |
|
|
|
|
pin_read_buff[pin_read_pos].write_bitmask = pin_read_mask; |
|
|
|
|
pin_read_buff[pin_read_pos].read_bitmask = TMS_SWDIO; |
|
|
|
|
|
|
|
|
|
pin_read_buff[pin_read_pos].ptr = read_slot; |
|
|
|
|
pin_read_mask = pin_read_mask<<1; |
|
|
|
|
if( !pin_read_mask ){ |
|
|
|
|
pin_read_mask = 1; |
|
|
|
|
read_slot += 1; |
|
|
|
|
} |
|
|
|
|
pin_read_pos++; |
|
|
|
|
|
|
|
|
|
if( pin_read_pos==BUFFER_SIZE ){ |
|
|
|
|
DEBUG("read buffer overflow!\n"); |
|
|
|
|
} |
|
|
|
|
PIN_IN( TMS_SWDIO, ptr, bit ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** SWDIO I/O pin: Set Output (used in SWD mode only).
|
|
|
|
|
@ -532,7 +539,7 @@ static __forceinline void PIN_SWDIO_OUT_ENABLE (void) { |
|
|
|
|
dir_state |= TMS_SWDIO; |
|
|
|
|
int success = ftdi_set_bitmode(&__ftdic, dir_state, __ftdic.bitbang_mode ); |
|
|
|
|
if( success<0 ){ |
|
|
|
|
DEBUGF("Could not change SWDIO to out: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not change SWDIO to out: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -547,7 +554,7 @@ static __forceinline void PIN_SWDIO_OUT_DISABLE (void) { |
|
|
|
|
|
|
|
|
|
int success = ftdi_set_bitmode(&__ftdic, dir_state, __ftdic.bitbang_mode ); |
|
|
|
|
if( success<0 ){ |
|
|
|
|
DEBUGF("Could not change SWDIO to in: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
DPRINTF("Could not change SWDIO to in: %s\n",ftdi_get_error_string(&__ftdic)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -557,8 +564,8 @@ static __forceinline void PIN_SWDIO_OUT_DISABLE (void) { |
|
|
|
|
/** TDI I/O pin: Get Input.
|
|
|
|
|
\return Current status of the TDI DAP hardware I/O pin. |
|
|
|
|
*/ |
|
|
|
|
static __forceinline uint32_t PIN_TDI_IN (void) { |
|
|
|
|
return PIN_IN(TDI); |
|
|
|
|
static __forceinline void PIN_TDI_IN (uint8_t *ptr,uint8_t bit){ |
|
|
|
|
PIN_IN( TMS_SWDIO, ptr, bit ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** TDI I/O pin: Set Output.
|
|
|
|
|
@ -574,8 +581,12 @@ static __forceinline void PIN_TDI_OUT (uint32_t bit) { |
|
|
|
|
/** TDO I/O pin: Get Input.
|
|
|
|
|
\return Current status of the TDO DAP hardware I/O pin. |
|
|
|
|
*/ |
|
|
|
|
static __forceinline uint32_t PIN_TDO_IN (void) { |
|
|
|
|
return PIN_IN(TDO_SWO); |
|
|
|
|
|
|
|
|
|
/** TDO I/O pin: Get Input.
|
|
|
|
|
\return Current status of the TDO DAP hardware I/O pin. |
|
|
|
|
*/ |
|
|
|
|
static __forceinline void PIN_TDO_IN (uint8_t *ptr,uint8_t bit){ |
|
|
|
|
PIN_IN(TDO_SWO,ptr,bit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -584,8 +595,8 @@ static __forceinline uint32_t PIN_TDO_IN (void) { |
|
|
|
|
/** nTRST I/O pin: Get Input.
|
|
|
|
|
\return Current status of the nTRST DAP hardware I/O pin. |
|
|
|
|
*/ |
|
|
|
|
static __forceinline uint32_t PIN_nTRST_IN (void) { |
|
|
|
|
return PIN_IN(nTRST); |
|
|
|
|
static __forceinline void PIN_nTRST_IN (uint8_t *ptr,uint8_t bit){ |
|
|
|
|
PIN_IN( nTRST, ptr, bit ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** nTRST I/O pin: Set Output.
|
|
|
|
|
@ -602,8 +613,8 @@ static __forceinline void PIN_nTRST_OUT (uint32_t bit) { |
|
|
|
|
/** nRESET I/O pin: Get Input.
|
|
|
|
|
\return Current status of the nRESET DAP hardware I/O pin. |
|
|
|
|
*/ |
|
|
|
|
static __forceinline uint32_t PIN_nRESET_IN (void) { |
|
|
|
|
return PIN_IN(nRESET); |
|
|
|
|
static __forceinline void PIN_nRESET_IN (uint8_t *ptr,uint8_t bit){ |
|
|
|
|
PIN_IN( nRESET, ptr, bit ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** nRESET I/O pin: Set Output.
|
|
|
|
|
|