usbuart: Moved usbuart_change_dma_tx_buf() into aux_serial.c

This commit is contained in:
dragonmux 2022-08-19 10:24:35 +01:00 committed by Piotr Esden-Tempski
parent 693c408b98
commit 8eea6110b8
2 changed files with 22 additions and 19 deletions

View File

@ -20,6 +20,7 @@
#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
#include <libopencm3/stm32/usart.h>
#include <libopencm3/stm32/dma.h>
#elif defined(LM4F)
#include <libopencm3/lm4f/uart.h>
#else
@ -72,3 +73,24 @@ void aux_serial_set_encoding(struct usb_cdc_line_coding *coding)
break;
}
}
#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
/*
* Changes USBUSART TX buffer in which data is accumulated from USB.
* Filled buffer is submitted to DMA for transfer.
*/
void usbuart_change_dma_tx_buf(void)
{
/* Select buffer for transmission */
char *const tx_buf_ptr = &buf_tx[buf_tx_act_idx * TX_BUF_SIZE];
/* Configure DMA */
dma_set_memory_address(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN, (uintptr_t)tx_buf_ptr);
dma_set_number_of_data(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN, buf_tx_act_sz);
dma_enable_channel(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN);
/* Change active buffer */
buf_tx_act_sz = 0;
buf_tx_act_idx ^= 1;
}
#endif

View File

@ -182,25 +182,6 @@ void aux_serial_init(void)
usart_enable_rx_dma(USBUSART);
}
/*
* Changes USBUSART TX buffer in which data is accumulated from USB.
* Filled buffer is submitted to DMA for transfer.
*/
void usbuart_change_dma_tx_buf(void)
{
/* Select buffer for transmission */
char *const tx_buf_ptr = &buf_tx[buf_tx_act_idx * TX_BUF_SIZE];
/* Configure DMA */
dma_set_memory_address(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN, (uintptr_t)tx_buf_ptr);
dma_set_number_of_data(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN, buf_tx_act_sz);
dma_enable_channel(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN);
/* Change active buffer */
buf_tx_act_sz = 0;
buf_tx_act_idx ^= 1;
}
#if defined(USART_ICR)
#define USBUSART_ISR_TEMPLATE(USART, DMA_IRQ) do { \
nvic_disable_irq(DMA_IRQ); \