added RTS and DTR to UART interface
This commit is contained in:
parent
7dc01e96e8
commit
6656284728
|
@ -450,13 +450,21 @@ static enum usbd_request_return_codes cdcacm_control_request(usbd_device *dev,
|
|||
switch(req->bRequest) {
|
||||
case USB_CDC_REQ_SET_CONTROL_LINE_STATE:
|
||||
cdcacm_set_modem_state(dev, req->wIndex, true, true);
|
||||
/* Ignore if not for GDB interface */
|
||||
if(req->wIndex != GDB_IF_NO)
|
||||
switch(req->wIndex) {
|
||||
case UART_IF_NO:
|
||||
#ifdef USBUSART_DTR_PIN
|
||||
gpio_set_val(USBUSART_PORT, USBUSART_DTR_PIN, !(req->wValue & 1));
|
||||
#endif
|
||||
#ifdef USBUSART_RTS_PIN
|
||||
gpio_set_val(USBUSART_PORT, USBUSART_RTS_PIN, !((req->wValue >> 1) & 1));
|
||||
#endif
|
||||
return USBD_REQ_HANDLED;
|
||||
|
||||
case GDB_IF_NO:
|
||||
cdcacm_gdb_dtr = req->wValue & 1;
|
||||
|
||||
return USBD_REQ_HANDLED;
|
||||
default:
|
||||
return USBD_REQ_NOTSUPP;
|
||||
}
|
||||
case USB_CDC_REQ_SET_LINE_CODING:
|
||||
if(*len < sizeof(struct usb_cdc_line_coding))
|
||||
return USBD_REQ_NOTSUPP;
|
||||
|
|
|
@ -88,6 +88,8 @@ int usbuart_debug_write(const char *buf, size_t len);
|
|||
gpio_set_mode(USBUSART_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_CNF_INPUT_PULL_UPDOWN, USBUSART_RX_PIN); \
|
||||
gpio_set(USBUSART_PORT, USBUSART_RX_PIN); \
|
||||
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, USBUSART_RTS_PIN | USBUSART_DTR_PIN); \
|
||||
} while(0)
|
||||
|
||||
#define USB_DRIVER st_usbfs_v1_usb_driver
|
||||
|
@ -110,6 +112,8 @@ int usbuart_debug_write(const char *buf, size_t len);
|
|||
#define USBUSART_PORT GPIOB
|
||||
#define USBUSART_TX_PIN GPIO6
|
||||
#define USBUSART_RX_PIN GPIO7
|
||||
#define USBUSART_RTS_PIN GPIO8
|
||||
#define USBUSART_DTR_PIN GPIO9
|
||||
#define USBUSART_ISR(x) usart1_isr(x)
|
||||
#define USBUSART_DMA_BUS DMA1
|
||||
#define USBUSART_DMA_CLK RCC_DMA1
|
||||
|
|
Loading…
Reference in New Issue