|
|
|
|
@ -247,12 +247,9 @@ static __inline void FTDI_BEGIN_READ(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static __inline void FTDI_END_READ(){ |
|
|
|
|
int success, remaining; |
|
|
|
|
uint32_t read_size; |
|
|
|
|
|
|
|
|
|
read_size = remaining = out_state_buff_pos; |
|
|
|
|
int success, remaining, i; |
|
|
|
|
remaining = out_state_buff_pos; |
|
|
|
|
FTDI_WRITE_OUT_READ_MODE(); |
|
|
|
|
out_state_buff_pos = 0; |
|
|
|
|
|
|
|
|
|
success = 0; |
|
|
|
|
uint8_t *ptr = in_buff; |
|
|
|
|
@ -264,27 +261,18 @@ static __inline void FTDI_END_READ(){ |
|
|
|
|
} |
|
|
|
|
ptr+=success; |
|
|
|
|
remaining-=success; |
|
|
|
|
printf("try %d\n", success); |
|
|
|
|
} |
|
|
|
|
printf("Read %d/%d bytes\n",(int)(ptr-in_buff),read_size); |
|
|
|
|
|
|
|
|
|
printf("%x\n",dir_state); |
|
|
|
|
int i; |
|
|
|
|
for(i=0;i<success;i++){ |
|
|
|
|
printf("%x ",in_buff[i]>>7); |
|
|
|
|
} |
|
|
|
|
printf("\n"); |
|
|
|
|
DEBUG("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++){ |
|
|
|
|
uint8_t is_set = (in_buff[pin_read_buff[i].pos] & pin_read_buff[i].read_bitmask) != 0; |
|
|
|
|
printf("%d ",is_set); |
|
|
|
|
if( is_set ) { |
|
|
|
|
(*pin_read_buff[i].ptr) |= pin_read_buff[i].write_bitmask; |
|
|
|
|
}else{ |
|
|
|
|
(*pin_read_buff[i].ptr) &= ~pin_read_buff[i].write_bitmask; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
printf("\n"); |
|
|
|
|
pin_read_pos = is_in_read_mode = 0; |
|
|
|
|
|
|
|
|
|
success = ftdi_set_bitmode(&__ftdic, dir_state, BITMODE_SYNCBB ); |
|
|
|
|
@ -353,8 +341,6 @@ static __inline void DAP_SETUP (void) { |
|
|
|
|
} |
|
|
|
|
/*uint8_t foo;
|
|
|
|
|
success = ftdi_read_data(&__ftdic,&foo,1);*/ |
|
|
|
|
|
|
|
|
|
RESET_TARGET(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///@}
|
|
|
|
|
@ -502,7 +488,7 @@ static __forceinline void PIN_SWDIO_TMS_CLR (void) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static __inline uint8_t bit_count(uint8_t v){ |
|
|
|
|
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 |
|
|
|
|
@ -524,15 +510,29 @@ static __inline uint8_t bit_count(uint8_t v){ |
|
|
|
|
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 ){ |
|
|
|
|
DEBUG("setting read-to-pointer for pin reads!\n"); |
|
|
|
|
read_slot = ptr; |
|
|
|
|
if( bit_count(bit)==1 ){ |
|
|
|
|
if( bit_count8(bit)==1 ){ |
|
|
|
|
pin_read_mask=bit; |
|
|
|
|
}else{ |
|
|
|
|
pin_read_mask=1; |
|
|
|
|
@ -544,13 +544,12 @@ static __forceinline void PIN_SWDIO_IN (uint8_t *ptr,uint8_t bit){ |
|
|
|
|
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_buff[pin_read_pos].ptr = read_slot; |
|
|
|
|
pin_read_pos++; |
|
|
|
|
|
|
|
|
|
if( pin_read_pos==BUFFER_SIZE ){ |
|
|
|
|
|