1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

Remove reference to USART_TypeDef in io, refactor uartOpen and serialUART

This commit is contained in:
jflyper 2017-05-08 13:27:27 +09:00
parent c31fb92ad5
commit 0cf5161ec4
10 changed files with 85 additions and 186 deletions

View file

@ -100,40 +100,13 @@ static void uartReconfigure(uartPort_t *uartPort)
USART_Cmd(uartPort->USARTx, ENABLE);
}
serialPort_t *uartOpen(USART_TypeDef *USARTx, serialReceiveCallbackPtr rxCallback, uint32_t baudRate, portMode_t mode, portOptions_t options)
serialPort_t *uartOpen(UARTDevice device, serialReceiveCallbackPtr rxCallback, uint32_t baudRate, portMode_t mode, portOptions_t options)
{
uartPort_t *s = NULL;
uartPort_t *s = serialUART(device, baudRate, mode, options);
if (false) {
#ifdef USE_UART1
} else if (USARTx == USART1) {
s = serialUART1(baudRate, mode, options);
#endif
#ifdef USE_UART2
} else if (USARTx == USART2) {
s = serialUART2(baudRate, mode, options);
#endif
#ifdef USE_UART3
} else if (USARTx == USART3) {
s = serialUART3(baudRate, mode, options);
#endif
#ifdef USE_UART4
} else if (USARTx == UART4) {
s = serialUART4(baudRate, mode, options);
#endif
#ifdef USE_UART5
} else if (USARTx == UART5) {
s = serialUART5(baudRate, mode, options);
#endif
#ifdef USE_UART6
} else if (USARTx == USART6) {
s = serialUART6(baudRate, mode, options);
#endif
} else {
if (!s)
return (serialPort_t *)s;
}
s->txDMAEmpty = true;
// common serial initialisation code should move to serialPort::init()