stm32/uart: Enable UART FIFO for H7 MCUs.
The H7 has a hardware UART FIFO, so it's worth enabling it, to reduce the chance of missed incoming characters. Note that `HAL_UART_Init(&huart)` does not activate the FIFO, it must be done explicitly by calling `HAL_UARTEx_EnableFifoMode(&huart)`. Signed-off-by: ennyKey <ennyKey@fn.de>
This commit is contained in:
parent
5c6da11799
commit
2a46759fe8
3 changed files with 17 additions and 1 deletions
|
|
@ -417,6 +417,12 @@ HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_,\
|
|||
)
|
||||
endif
|
||||
|
||||
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),h7))
|
||||
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_,\
|
||||
hal_uart_ex.c \
|
||||
)
|
||||
endif
|
||||
|
||||
USBDEV_SRC_C += $(addprefix $(USBDEV_DIR)/,\
|
||||
core/src/usbd_core.c \
|
||||
core/src/usbd_ctlreq.c \
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@
|
|||
#include "stm32h7xx_hal_spi.h"
|
||||
#include "stm32h7xx_hal_tim.h"
|
||||
#include "stm32h7xx_hal_uart.h"
|
||||
#include "stm32h7xx_hal_uart_ex.h"
|
||||
#include "stm32h7xx_hal_usart.h"
|
||||
#include "stm32h7xx_hal_wwdg.h"
|
||||
#include "stm32h7xx_ll_adc.h"
|
||||
|
|
|
|||
|
|
@ -653,7 +653,7 @@ bool uart_init(machine_uart_obj_t *uart_obj,
|
|||
huart.Init.HwFlowCtl = flow;
|
||||
huart.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
|
||||
#if defined(STM32G4) // H7 and WB also have fifo..
|
||||
#if defined(STM32G4) || defined(STM32H7) // WB also has a fifo..
|
||||
huart.FifoMode = UART_FIFOMODE_ENABLE;
|
||||
#endif
|
||||
|
||||
|
|
@ -701,6 +701,12 @@ bool uart_init(machine_uart_obj_t *uart_obj,
|
|||
uart_obj->char_width = CHAR_WIDTH_8BIT;
|
||||
}
|
||||
|
||||
#if defined(STM32H7)
|
||||
HAL_UARTEx_SetTxFifoThreshold(&huart, UART_TXFIFO_THRESHOLD_1_8);
|
||||
HAL_UARTEx_SetRxFifoThreshold(&huart, UART_RXFIFO_THRESHOLD_1_8);
|
||||
HAL_UARTEx_EnableFifoMode(&huart);
|
||||
#endif
|
||||
|
||||
uart_obj->mp_irq_trigger = 0;
|
||||
uart_obj->mp_irq_obj = NULL;
|
||||
|
||||
|
|
@ -1141,6 +1147,9 @@ size_t uart_tx_data(machine_uart_obj_t *self, const void *src_in, size_t num_cha
|
|||
// timeout_char by FIFO size + 1.
|
||||
// STM32G4 has 8 words FIFO.
|
||||
timeout = (8 + 1) * self->timeout_char;
|
||||
#elif defined(STM32H7)
|
||||
// STM32H7 has 16 words FIFO.
|
||||
timeout = (16 + 1) * self->timeout_char;
|
||||
#else
|
||||
// The timeout specified here is for waiting for the TX data register to
|
||||
// become empty (ie between chars), as well as for the final char to be
|
||||
|
|
|
|||
Loading…
Reference in a new issue