Enable medium GPI speed and 8bit sampling on high baud rates only

This commit is contained in:
Paul Kendall
2021-09-13 15:08:30 +10:00
committed by Peter Feerick
parent 542213de11
commit 1c84b6d0e8
2 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -65,12 +65,14 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_Speed = baudrate <= 400000 ? GPIO_Speed_2MHz : GPIO_Speed_25MHz;
GPIO_Init(TELEMETRY_GPIO, &GPIO_InitStructure);
telemetryInitDirPin();
USART_OverSampling8Cmd(TELEMETRY_USART, ENABLE);
USART_DeInit(TELEMETRY_USART);
USART_OverSampling8Cmd(TELEMETRY_USART, baudrate <= 400000 ? DISABLE : ENABLE);
USART_InitStructure.USART_BaudRate = baudrate;
if (mode & TELEMETRY_SERIAL_8E2) {
@@ -57,14 +57,14 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_Speed = baudrate <= 400000 ? GPIO_Speed_2MHz : GPIO_Speed_25MHz;
GPIO_Init(TELEMETRY_GPIO, &GPIO_InitStructure);
telemetryInitDirPin();
USART_DeInit(TELEMETRY_USART);
USART_OverSampling8Cmd(TELEMETRY_USART, ENABLE);
USART_OverSampling8Cmd(TELEMETRY_USART, baudrate <= 400000 ? DISABLE : ENABLE);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = baudrate;