Beispiel #1
0
void gdb_usb_out_cb(usbd_device *dev, uint8_t ep)
{
	(void)ep;
	usbd_ep_nak_set(dev, CDCACM_GDB_ENDPOINT, 1);
	count_new = usbd_ep_read_packet(dev, CDCACM_GDB_ENDPOINT,
	                                double_buffer_out, CDCACM_PACKET_SIZE);
	if(!count_new) {
		usbd_ep_nak_set(dev, CDCACM_GDB_ENDPOINT, 0);
	}
}
Beispiel #2
0
void gdb_usb_out_cb(usbd_device *dev, uint8_t ep)
{
	(void)ep;
	static uint8_t buf[CDCACM_PACKET_SIZE];

	usbd_ep_nak_set(dev, CDCACM_GDB_ENDPOINT, 1);
        uint32_t count = usbd_ep_read_packet(dev, CDCACM_GDB_ENDPOINT,
                                        (uint8_t *)buf, CDCACM_PACKET_SIZE);

	
	uint32_t idx;
	for (idx=0; idx<count; idx++) {
		buffer_out[head_out++ % sizeof(buffer_out)] = buf[idx];
	}

	usbd_ep_nak_set(dev, CDCACM_GDB_ENDPOINT, 0);
}
Beispiel #3
0
static void gdb_if_update_buf(void)
{
	while (cdcacm_get_config() != 1);
#ifdef STM32F4
	asm volatile ("cpsid i; isb");
	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);
	}
	asm volatile ("cpsie i; isb");
#else
	count_out = usbd_ep_read_packet(usbdev, CDCACM_GDB_ENDPOINT,
	                                buffer_out, CDCACM_PACKET_SIZE);
	out_ptr = 0;
#endif
}
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++];
}
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;
}