예제 #1
0
void swdptap_reset(void)
{
        swdptap_turnaround(0);
        /* 50 clocks with TMS high */
	swdptap_seq_out(0xffffffff, 32);
	swdptap_seq_out(0x000fffff, 24);
}
예제 #2
0
파일: swdptap.c 프로젝트: emlid/blackmagic
void swdptap_seq_out(uint32_t MS, int ticks)
{
	swdptap_turnaround(0);

	while(ticks--) {
		swdptap_bit_out(MS & 1);
		MS >>= 1;
	}
}
예제 #3
0
파일: swdptap.c 프로젝트: Marus/blackmagic
void swdptap_bit_out(bool val)
{
#ifdef DEBUG_SWD_BITS
	DEBUG("%d", val);
#endif

	swdptap_turnaround(0);

	gpio_set_val(SWDIO_PORT, SWDIO_PIN, val);
	gpio_set(SWCLK_PORT, SWCLK_PIN);
	gpio_clear(SWCLK_PORT, SWCLK_PIN);
}
예제 #4
0
파일: swdptap.c 프로젝트: emlid/blackmagic
void swdptap_seq_out_parity(uint32_t MS, int ticks)
{
	uint8_t parity = 0;

	swdptap_turnaround(0);

	while(ticks--) {
		swdptap_bit_out(MS & 1);
		parity ^= MS;
		MS >>= 1;
	}
	swdptap_bit_out(parity & 1);
}
예제 #5
0
파일: swdptap.c 프로젝트: emlid/blackmagic
uint32_t swdptap_seq_in(int ticks)
{
	uint32_t index = 1;
	uint32_t ret = 0;

	swdptap_turnaround(1);

	while(ticks--) {
		if(swdptap_bit_in()) ret |= index;
		index <<= 1;
	}

	return ret;
}
예제 #6
0
파일: swdptap.c 프로젝트: Marus/blackmagic
bool swdptap_bit_in(void)
{
	uint16_t ret;

	swdptap_turnaround(1);

	ret = gpio_get(SWDIO_PORT, SWDIO_PIN);
	gpio_set(SWCLK_PORT, SWCLK_PIN);
	gpio_clear(SWCLK_PORT, SWCLK_PIN);

#ifdef DEBUG_SWD_BITS
	DEBUG("%d", ret?1:0);
#endif

	return ret != 0;
}
예제 #7
0
파일: swdptap.c 프로젝트: emlid/blackmagic
uint8_t swdptap_seq_in_parity(uint32_t *ret, int ticks)
{
	uint32_t index = 1;
	uint8_t parity = 0;
	*ret = 0;

	swdptap_turnaround(1);

	while(ticks--) {
		if(swdptap_bit_in()) {
			*ret |= index;
			parity ^= 1;
		}
		index <<= 1;
	}
	if(swdptap_bit_in()) parity ^= 1;

	return parity;
}
예제 #8
0
uint32_t swdptap_seq_in(int ticks)
{
	uint8_t buf[] = {
		MPSSE_DO_READ | MPSSE_LSB,
		0,		/* len - 1 low */
		0		/* len - 1 high (always 0) */
	};

	assert(ticks <= 32);

	/* DEBUG("seq_in %d\n", ticks); */

	swdptap_turnaround(1);

	if (ticks >= 8) {
		buf[1] = ticks / 8 - 1;
		platform_buffer_write(buf, sizeof(buf));
	}

	if (ticks % 8) {
		buf[0] |= MPSSE_BITMODE;
		buf[1] = ticks % 8 - 1;
		platform_buffer_write(buf, 2);
	}

	uint8_t res[4] = {0};	/* max 32 bits */
	platform_buffer_read(res, (ticks + 7) / 8);

	uint32_t ret = 0;
	for (int msb = ticks / 8 - 1; msb >= 0; --msb)
		ret = (ret << 8) | res[msb];

	int bits_remaining = ticks % 8;
	ret |= (res[ticks / 8] >> /* remaining byte */
		(8 - bits_remaining)) /* bits come in from MSB */
		<< (ticks - bits_remaining); /* move them to the top */

	/* DEBUG("  read: %08x\n", ret); */

	return (ret);
}
예제 #9
0
파일: swdptap.c 프로젝트: emlid/blackmagic
void swdptap_reset(void)
{
	swdptap_turnaround(0);
	/* 50 clocks with TMS high */
	for(int i = 0; i < 50; i++) swdptap_bit_out(1);
}