usbuart: Begun refactoring the physical UART code to seperate out the mixed interests

This commit is contained in:
dragonmux 2022-08-18 22:51:59 +01:00 committed by Piotr Esden-Tempski
parent 9570b7d21e
commit 24ac50ff60
13 changed files with 17 additions and 15 deletions

View File

@ -69,7 +69,7 @@ void platform_init(void)
platform_timing_init();
blackmagic_usb_init();
usbuart_init();
aux_serial_init();
}
void platform_nrst_set_val(bool assert)

View File

@ -108,7 +108,7 @@ void platform_init(void)
platform_timing_init();
blackmagic_usb_init();
usbuart_init();
aux_serial_init();
// https://github.com/libopencm3/libopencm3/pull/1256#issuecomment-779424001
OTG_FS_GCCFG |= OTG_GCCFG_NOVBUSSENS | OTG_GCCFG_PWRDWN;

View File

@ -23,7 +23,7 @@
#include <libopencm3/usb/usbd.h>
#include <libopencm3/usb/cdc.h>
void usbuart_init(void);
void aux_serial_init(void);
void usbuart_set_line_coding(struct usb_cdc_line_coding *coding);
void usbuart_usb_out_cb(usbd_device *dev, uint8_t ep);

View File

@ -85,7 +85,7 @@ void platform_init(void)
GPIO_OSPEED_2MHZ, NRST_PIN);
platform_timing_init();
blackmagic_usb_init();
usbuart_init();
aux_serial_init();
}
void platform_nrst_set_val(bool assert)

View File

@ -89,7 +89,7 @@ void platform_init(void)
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO11 | GPIO12);
gpio_set_af(GPIOA, GPIO_AF14, GPIO11 | GPIO12);
blackmagic_usb_init();
usbuart_init();
aux_serial_init();
}
void platform_nrst_set_val(bool assert)

View File

@ -107,7 +107,7 @@ void platform_init(void)
platform_timing_init();
blackmagic_usb_init();
usbuart_init();
aux_serial_init();
}
void platform_nrst_set_val(bool assert) { (void)assert; }

View File

@ -77,7 +77,7 @@ void platform_init(void)
platform_timing_init();
blackmagic_usb_init();
usbuart_init();
aux_serial_init();
}
void platform_nrst_set_val(bool assert) { (void)assert; }

View File

@ -82,7 +82,7 @@ void platform_init(void)
__asm__("nop"); __asm__("nop"); __asm__("nop");
gpio_mode_setup(GPIOD_BASE, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4|GPIO5);
blackmagic_usb_init();
usbuart_init();
aux_serial_init();
usb_enable_interrupts(USB_INT_RESET | USB_INT_DISCON |
USB_INT_RESUME | USB_INT_SUSPEND, 0xff, 0xff);

View File

@ -221,7 +221,7 @@ void platform_init(void)
/* On hardware version 1 and 2, UART and SWD share connector pins.
* Don't enable UART if we're being debugged. */
if (platform_hwversion() == 0 || platform_hwversion() >= 3 || !(SCS_DEMCR & SCS_DEMCR_TRCENA))
usbuart_init();
aux_serial_init();
setup_vbus_irq();
}

View File

@ -89,8 +89,8 @@ void platform_init(void)
/* Don't enable UART if we're being debugged. */
if (!(SCS_DEMCR & SCS_DEMCR_TRCENA))
usbuart_init();
adc_init();
aux_serial_init();
adc_init();
}
void platform_nrst_set_val(bool assert)

View File

@ -105,7 +105,7 @@ static void usbuart_set_led_state(uint8_t ledn, bool state)
}
}
void usbuart_init(void)
void aux_serial_init(void)
{
/* Enable clocks */
rcc_periph_clock_enable(USBUSART_CLK);

View File

@ -110,7 +110,7 @@ void platform_init(void)
platform_timing_init();
blackmagic_usb_init();
usbuart_init();
aux_serial_init();
}
void platform_nrst_set_val(bool assert)

View File

@ -39,12 +39,14 @@ static uint8_t buf_rx_in;
/* Fifo out pointer, writes assumed to be atomic, should be only incremented outside RX ISR */
static uint8_t buf_rx_out;
void usbuart_init(void)
void aux_serial_init(void)
{
UART_PIN_SETUP();
periph_clock_enable(USBUART_CLK);
__asm__("nop"); __asm__("nop"); __asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
uart_disable(USBUART);