Skip to content

Commit

Permalink
ADD: RI signal reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
r2axz committed Nov 28, 2020
1 parent 62471d9 commit 707d206
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions usb_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ void usb_cdc_reset() {
NVIC_EnableIRQ(DMA1_Channel7_IRQn);
/*
* Disable JTAG interface (SWD is still enabled),
* this frees PA15, PB3, PB4 (needed for DSR inputs).
* this frees PA15, PB3, PB4 (needed for DSR/RI inputs).
*/
RCC->APB2ENR |= RCC_APB2ENR_AFIOEN;
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE;
Expand Down Expand Up @@ -661,13 +661,16 @@ void usb_cdc_frame() {
for (int port = 0; port < USB_CDC_NUM_PORTS; port++) {
const cdc_port_t *port_config = &device_config_get()->cdc_config.port_config[port];
usb_cdc_serial_state_t state = usb_cdc_states[port].serial_state;
state &= ~(USB_CDC_SERIAL_STATE_DSR | USB_CDC_SERIAL_STATE_DCD);
state &= ~(USB_CDC_SERIAL_STATE_DSR | USB_CDC_SERIAL_STATE_DCD | USB_CDC_SERIAL_STATE_RI);
if (gpio_pin_get(&port_config->pins[cdc_pin_dsr])) {
state |= USB_CDC_SERIAL_STATE_DSR;
}
if (gpio_pin_get(&port_config->pins[cdc_pin_dcd])) {
state |= USB_CDC_SERIAL_STATE_DCD;
}
if (gpio_pin_get(&port_config->pins[cdc_pin_ri])) {
state |= USB_CDC_SERIAL_STATE_RI;
}
usb_cdc_notify_port_state_change(port, state);
}
if (gpio_pin_get(&device_config->config_pin) != usb_cdc_config_mode) {
Expand Down
1 change: 1 addition & 0 deletions usb_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ typedef uint16_t usb_cdc_serial_state_t;

#define USB_CDC_SERIAL_STATE_DCD 0x01
#define USB_CDC_SERIAL_STATE_DSR 0x02
#define USB_CDC_SERIAL_STATE_RI 0x08
#define USB_CDC_SERIAL_STATE_PARITY_ERROR 0x20
#define USB_CDC_SERIAL_STATE_OVERRUN 0x40

Expand Down

0 comments on commit 707d206

Please sign in to comment.