stm32: portability enhancements

Needed for e.g. stlinkv3
This commit is contained in:
Uwe Bonnes 2021-05-10 19:27:58 +02:00 committed by UweBonnes
parent 87acd99fe4
commit 90534b3cf6
2 changed files with 14 additions and 4 deletions

View File

@ -39,6 +39,7 @@ static inline void _gpio_set(uint32_t gpioport, uint16_t gpios)
{
GPIO_BSRR(gpioport) = gpios;
#ifdef STM32F4
/* FIXME: Check if doubling is still needed */
GPIO_BSRR(gpioport) = gpios;
#endif
}
@ -46,11 +47,14 @@ static inline void _gpio_set(uint32_t gpioport, uint16_t gpios)
static inline void _gpio_clear(uint32_t gpioport, uint16_t gpios)
{
#ifndef STM32F4
#if defined(STM32F4)
GPIO_BSRR(gpioport) = gpios<<16;
/* FIXME: Check if doubling is still needed */
GPIO_BSRR(gpioport) = gpios<<16;
#elif defined(GPIO_BRR)
GPIO_BRR(gpioport) = gpios;
#else
GPIO_BSRR(gpioport) = gpios<<16;
GPIO_BSRR(gpioport) = gpios<<16;
#endif
}
#define gpio_clear _gpio_clear

View File

@ -118,8 +118,14 @@ void usbuart_init(void)
USBUSART_CR1 |= USART_CR1_IDLEIE;
/* Setup USART TX DMA */
#if !defined(USBUSART_TDR) && defined(USBUSART_DR)
# define USBUSART_TDR USBUSART_DR
#endif
#if !defined(USBUSART_RDR) && defined(USBUSART_DR)
# define USBUSART_RDR USBUSART_DR
#endif
dma_channel_reset(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN);
dma_set_peripheral_address(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN, (uint32_t)&USBUSART_DR);
dma_set_peripheral_address(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN, (uint32_t)&USBUSART_TDR);
dma_enable_memory_increment_mode(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN);
dma_set_peripheral_size(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN, DMA_PSIZE_8BIT);
dma_set_memory_size(USBUSART_DMA_BUS, USBUSART_DMA_TX_CHAN, DMA_MSIZE_8BIT);
@ -136,7 +142,7 @@ void usbuart_init(void)
/* Setup USART RX DMA */
dma_channel_reset(USBUSART_DMA_BUS, USBUSART_DMA_RX_CHAN);
dma_set_peripheral_address(USBUSART_DMA_BUS, USBUSART_DMA_RX_CHAN, (uint32_t)&USBUSART_DR);
dma_set_peripheral_address(USBUSART_DMA_BUS, USBUSART_DMA_RX_CHAN, (uint32_t)&USBUSART_RDR);
dma_set_memory_address(USBUSART_DMA_BUS, USBUSART_DMA_RX_CHAN, (uint32_t)buf_rx);
dma_set_number_of_data(USBUSART_DMA_BUS, USBUSART_DMA_RX_CHAN, RX_FIFO_SIZE);
dma_enable_memory_increment_mode(USBUSART_DMA_BUS, USBUSART_DMA_RX_CHAN);