Example #1
0
void gdb_if_putchar(unsigned char c, int flush)
{
	buffer_in[count_in++] = c;
	if(flush || (count_in == CDCACM_PACKET_SIZE)) {
		/* Refuse to send if USB isn't configured, and
		 * don't bother if nobody's listening */
		if((cdcacm_get_config() != 1) || !cdcacm_get_dtr()) {
			count_in = 0;
			return;
		}
		while(usbd_ep_write_packet(usbdev, CDCACM_GDB_ENDPOINT,
			buffer_in, count_in) <= 0);

		if (flush && (count_in == CDCACM_PACKET_SIZE)) {
			/* We need to send an empty packet for some hosts
			 * to accept this as a complete transfer. */
			/* libopencm3 needs a change for us to confirm when
			 * that transfer is complete, so we just send a packet
			 * containing a null byte for now.
			 */
			while (usbd_ep_write_packet(usbdev, CDCACM_GDB_ENDPOINT,
				"\0", 1) <= 0);
		}

		count_in = 0;
	}
}
Example #2
0
unsigned char gdb_if_getchar(void)
{

	while (!(out_ptr < count_out)) {
		/* Detach if port closed */
		if (!cdcacm_get_dtr())
			return 0x04;

		gdb_if_update_buf();
	}

	return buffer_out[out_ptr++];
}
Example #3
0
unsigned char gdb_if_getchar(void)
{

	while(tail_out == head_out) {
		/* Detach if port closed */
		if(!cdcacm_get_dtr())
			return 0x04;

		while(cdcacm_get_config() != 1);
	}

	return buffer_out[tail_out++ % sizeof(buffer_out)];
}
Example #4
0
void gdb_if_putchar(unsigned char c, int flush)
{
	buffer_in[count_in++] = c;
	if(flush || (count_in == CDCACM_PACKET_SIZE)) {
		/* Refuse to send if USB isn't configured, and
		 * don't bother if nobody's listening */
		if((cdcacm_get_config() != 1) || !cdcacm_get_dtr()) {
			count_in = 0;
			return;
		}
		while(usbd_ep_write_packet(usbdev, CDCACM_GDB_ENDPOINT,
			buffer_in, count_in) <= 0);
		count_in = 0;
	}
}
Example #5
0
unsigned char gdb_if_getchar(void)
{
	while(!(out_ptr < count_out)) {
		/* Detach if port closed */
		if(!cdcacm_get_dtr())
			return 0x04;

		while(cdcacm_get_config() != 1);
		count_out = usbd_ep_read_packet(usbdev, CDCACM_GDB_ENDPOINT,
					buffer_out, CDCACM_PACKET_SIZE);
		out_ptr = 0;
	}

	return buffer_out[out_ptr++];
}
Example #6
0
unsigned char gdb_if_getchar_to(int timeout)
{
	platform_timeout_set(timeout);

	if (!(out_ptr < count_out)) do {
		/* Detach if port closed */
		if (!cdcacm_get_dtr())
			return 0x04;

		gdb_if_update_buf();
	} while (!platform_timeout_is_expired() && !(out_ptr < count_out));

	if(out_ptr < count_out)
		return gdb_if_getchar();

	return -1;
}
Example #7
0
unsigned char gdb_if_getchar_to(int timeout)
{
	platform_timeout t;
	platform_timeout_set(&t, timeout);

	if(head_out == tail_out) do {
		/* Detach if port closed */
		if(!cdcacm_get_dtr())
			return 0x04;

		while(cdcacm_get_config() != 1);
	} while(!platform_timeout_is_expired(&t) && head_out == tail_out);

	if(head_out != tail_out)
		return gdb_if_getchar();

	return -1;
}
Example #8
0
unsigned char gdb_if_getchar_to(int timeout)
{
	timeout_counter = timeout/100;

	if(!(out_ptr < count_out)) do {
		/* Detach if port closed */
		if(!cdcacm_get_dtr())
			return 0x04;

		count_out = usbd_ep_read_packet(usbdev, CDCACM_GDB_ENDPOINT,
					buffer_out, CDCACM_PACKET_SIZE);
		out_ptr = 0;
	} while(timeout_counter && !(out_ptr < count_out));

	if(out_ptr < count_out)
		return gdb_if_getchar();

	return -1;
}
Example #9
0
unsigned char gdb_if_getchar(void)
{

	while(!(out_ptr < count_out)) {
		/* Detach if port closed */
		if(!cdcacm_get_dtr())
			return 0x04;

		while(cdcacm_get_config() != 1);
                if (count_new) {
                    memcpy(buffer_out, double_buffer_out,count_new);
		    count_out = count_new;
                    count_new = 0;
                    out_ptr = 0;
                    usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
                }
	}

	return buffer_out[out_ptr++];
}
Example #10
0
unsigned char gdb_if_getchar_to(int timeout)
{
	timeout_counter = timeout/100;

	if(!(out_ptr < count_out)) do {
		/* Detach if port closed */
		if(!cdcacm_get_dtr())
			return 0x04;

		while(cdcacm_get_config() != 1);
                if (count_new) {
                    memcpy(buffer_out, double_buffer_out,count_new);
		    count_out = count_new;
                    count_new = 0;
                    out_ptr = 0;
                    usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
                }
	} while(timeout_counter && !(out_ptr < count_out));

	if(out_ptr < count_out)
		return gdb_if_getchar();

	return -1;
}