mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 14:33:35 +08:00
Addressed compiler warnings and handle non-supported devices properly.
This commit is contained in:
@@ -135,8 +135,8 @@ static int open_uart(const char *device, struct termios *uart_config_original)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the appropriate GPIO pin and control register */
|
/* Get the appropriate GPIO pin and control register */
|
||||||
uint32_t gpio_uart;
|
uint32_t gpio_uart = GPIO_USART2_TX;;
|
||||||
uint32_t uart_cr3;
|
uint32_t uart_cr3 = STM32_USART2_CR3;
|
||||||
|
|
||||||
switch (device[strlen(device) - 1]) {
|
switch (device[strlen(device) - 1]) {
|
||||||
case '0':
|
case '0':
|
||||||
@@ -149,16 +149,16 @@ static int open_uart(const char *device, struct termios *uart_config_original)
|
|||||||
uart_cr3 = STM32_USART2_CR3;
|
uart_cr3 = STM32_USART2_CR3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '2':
|
|
||||||
sprintf(msg, "/dev/ttyS3 is not supported.\n", device);
|
|
||||||
close(uart);
|
|
||||||
FATAL_MSG(msg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '3':
|
case '3':
|
||||||
gpio_uart = GPIO_USART6_TX;
|
gpio_uart = GPIO_USART6_TX;
|
||||||
uart_cr3 = STM32_USART6_CR3;
|
uart_cr3 = STM32_USART6_CR3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sprintf(msg, "%s is not supported.\n", device);
|
||||||
|
close(uart);
|
||||||
|
FATAL_MSG(msg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Change the TX port to be open-drain */
|
/* Change the TX port to be open-drain */
|
||||||
|
|||||||
Reference in New Issue
Block a user