usb_gdb_uart: Renamed cdcacm_get_dtr() -> gdb_uart_get_dtr()
This commit is contained in:
parent
2e5143bb5f
commit
82c83bb77e
|
@ -49,7 +49,8 @@
|
|||
#include <libopencm3/usb/cdc.h>
|
||||
|
||||
static int configured;
|
||||
static int cdcacm_gdb_dtr = 1;
|
||||
|
||||
static int gdb_uart_dtr = 1;
|
||||
|
||||
static void cdcacm_set_modem_state(usbd_device *dev, uint16_t iface, uint8_t ep);
|
||||
|
||||
|
@ -65,7 +66,7 @@ static enum usbd_request_return_codes gdb_uart_control_request(usbd_device *dev,
|
|||
switch (req->bRequest) {
|
||||
case USB_CDC_REQ_SET_CONTROL_LINE_STATE:
|
||||
cdcacm_set_modem_state(dev, req->wIndex, CDCACM_GDB_ENDPOINT);
|
||||
cdcacm_gdb_dtr = req->wValue & 1;
|
||||
gdb_uart_dtr = req->wValue & 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
case USB_CDC_REQ_SET_LINE_CODING:
|
||||
if (*len < sizeof(struct usb_cdc_line_coding))
|
||||
|
@ -107,9 +108,9 @@ int cdcacm_get_config(void)
|
|||
return configured;
|
||||
}
|
||||
|
||||
int cdcacm_get_dtr(void)
|
||||
int gdb_uart_get_dtr(void)
|
||||
{
|
||||
return cdcacm_gdb_dtr;
|
||||
return gdb_uart_dtr;
|
||||
}
|
||||
|
||||
static void cdcacm_set_modem_state(usbd_device *dev, const uint16_t iface, const uint8_t ep)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
void cdcacm_set_config(usbd_device *dev, uint16_t wValue);
|
||||
/* Returns current usb configuration, or 0 if not configured. */
|
||||
int cdcacm_get_config(void);
|
||||
int cdcacm_get_dtr(void);
|
||||
|
||||
int gdb_uart_get_dtr(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,7 +43,7 @@ void gdb_if_putchar(unsigned char c, int flush)
|
|||
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()) {
|
||||
if((cdcacm_get_config() != 1) || !gdb_uart_get_dtr()) {
|
||||
count_in = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ unsigned char gdb_if_getchar(void)
|
|||
|
||||
while (!(out_ptr < count_out)) {
|
||||
/* Detach if port closed */
|
||||
if (!cdcacm_get_dtr()) {
|
||||
if (!gdb_uart_get_dtr()) {
|
||||
__WFI();
|
||||
return 0x04;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ unsigned char gdb_if_getchar_to(int timeout)
|
|||
|
||||
if (!(out_ptr < count_out)) do {
|
||||
/* Detach if port closed */
|
||||
if (!cdcacm_get_dtr()) {
|
||||
if (!gdb_uart_get_dtr()) {
|
||||
__WFI(); /* systick will wake up too!*/
|
||||
return 0x04;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ bool rtt_nodata()
|
|||
/* rtt target to host: write string */
|
||||
uint32_t rtt_write(const char *buf, uint32_t len)
|
||||
{
|
||||
if (len != 0 && usbdev && cdcacm_get_config() && cdcacm_get_dtr()) {
|
||||
if (len != 0 && usbdev && cdcacm_get_config() && gdb_uart_get_dtr()) {
|
||||
for (uint32_t p = 0; p < len; p += CDCACM_PACKET_SIZE) {
|
||||
uint32_t plen = MIN(CDCACM_PACKET_SIZE, len - p);
|
||||
while(usbd_ep_write_packet(usbdev, CDCACM_UART_ENDPOINT, buf + p, plen) <= 0);
|
||||
|
|
|
@ -47,7 +47,7 @@ uint16_t traceswo_decode(usbd_device *usbd_dev, uint8_t addr,
|
|||
if (swo_print) {
|
||||
swo_buf[swo_buf_len++]=ch;
|
||||
if (swo_buf_len == sizeof(swo_buf)) {
|
||||
if (cdcacm_get_config() && cdcacm_get_dtr()) /* silently drop if usb not ready */
|
||||
if (cdcacm_get_config() && gdb_uart_get_dtr()) /* silently drop if usb not ready */
|
||||
usbd_ep_write_packet(usbd_dev, addr, swo_buf, swo_buf_len);
|
||||
swo_buf_len=0;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ void gdb_if_putchar(unsigned char c, int flush)
|
|||
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()) {
|
||||
if((cdcacm_get_config() != 1) || !gdb_uart_get_dtr()) {
|
||||
count_in = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void gdb_usb_out_cb(usbd_device *dev, uint8_t ep)
|
|||
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];
|
||||
|
@ -73,7 +73,7 @@ unsigned char gdb_if_getchar(void)
|
|||
|
||||
while(tail_out == head_out) {
|
||||
/* Detach if port closed */
|
||||
if(!cdcacm_get_dtr())
|
||||
if(!gdb_uart_get_dtr())
|
||||
return 0x04;
|
||||
|
||||
while(cdcacm_get_config() != 1);
|
||||
|
@ -89,7 +89,7 @@ unsigned char gdb_if_getchar_to(int timeout)
|
|||
|
||||
if(head_out == tail_out) do {
|
||||
/* Detach if port closed */
|
||||
if(!cdcacm_get_dtr())
|
||||
if(!gdb_uart_get_dtr())
|
||||
return 0x04;
|
||||
|
||||
while(cdcacm_get_config() != 1);
|
||||
|
@ -100,4 +100,3 @@ unsigned char gdb_if_getchar_to(int timeout)
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue