From 4d171ec19a9a235a1c86a6f90a6ffbca53d60dd4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 26 Nov 2020 17:48:59 +1100 Subject: [PATCH] AP_HAL_ChibiOS: support uartI, allowing a total of 9 uarts this allows for OTG2 on the MatekH743 board, which makes SLCAN much easier --- libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp | 3 +++ libraries/AP_HAL_ChibiOS/UARTDriver.h | 4 ++-- libraries/AP_HAL_ChibiOS/hwdef/MatekF765-Wing/hwdef.dat | 6 +++--- libraries/AP_HAL_ChibiOS/hwdef/MatekH743/hwdef.dat | 2 +- libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 6 +++--- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp index 4169a1067b..ecbdf133c5 100644 --- a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp +++ b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp @@ -45,6 +45,7 @@ static HAL_UARTE_DRIVER; static HAL_UARTF_DRIVER; static HAL_UARTG_DRIVER; static HAL_UARTH_DRIVER; +static HAL_UARTI_DRIVER; #else static Empty::UARTDriver uartADriver; static Empty::UARTDriver uartBDriver; @@ -54,6 +55,7 @@ static Empty::UARTDriver uartEDriver; static Empty::UARTDriver uartFDriver; static Empty::UARTDriver uartGDriver; static Empty::UARTDriver uartHDriver; +static Empty::UARTDriver uartIDriver; #endif #if HAL_USE_I2C == TRUE && defined(HAL_I2C_DEVICE_LIST) @@ -124,6 +126,7 @@ HAL_ChibiOS::HAL_ChibiOS() : &uartFDriver, &uartGDriver, &uartHDriver, + &uartIDriver, &i2cDeviceManager, &spiDeviceManager, &analogIn, diff --git a/libraries/AP_HAL_ChibiOS/UARTDriver.h b/libraries/AP_HAL_ChibiOS/UARTDriver.h index b7ab901194..50c3159126 100644 --- a/libraries/AP_HAL_ChibiOS/UARTDriver.h +++ b/libraries/AP_HAL_ChibiOS/UARTDriver.h @@ -25,8 +25,8 @@ #define RX_BOUNCE_BUFSIZE 64U #define TX_BOUNCE_BUFSIZE 64U -// enough for uartA to uartH, plus IOMCU -#define UART_MAX_DRIVERS 9 +// enough for uartA to uartI, plus IOMCU +#define UART_MAX_DRIVERS 10 class ChibiOS::UARTDriver : public AP_HAL::UARTDriver { public: diff --git a/libraries/AP_HAL_ChibiOS/hwdef/MatekF765-Wing/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/MatekF765-Wing/hwdef.dat index fcb9d62970..0737fce714 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/MatekF765-Wing/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/MatekF765-Wing/hwdef.dat @@ -23,7 +23,7 @@ define CH_CFG_ST_RESOLUTION 16 I2C_ORDER I2C2 I2C1 # order of UARTs (and USB) -SERIAL_ORDER OTG1 UART7 USART1 USART2 USART3 UART8 UART4 USART6 +SERIAL_ORDER OTG1 UART7 USART1 USART2 USART3 UART8 UART4 USART6 UART5 # tonealarm support PB9 TIM11_CH1 TIM11 GPIO(32) ALARM @@ -108,8 +108,8 @@ PD8 USART3_TX USART3 NODMA PD1 UART4_TX UART4 NODMA PD0 UART4_RX UART4 NODMA -# UART5 (RX only, for ESC telem), disabled for now until we add uartH support -# PB8 UART5_RX UART5 NODMA +# UART5 (RX only, for ESC telem) +PB8 UART5_RX UART5 NODMA # USART6 (RC input), SERIAL7 PC7 TIM3_CH2 TIM3 RCININT FLOAT LOW diff --git a/libraries/AP_HAL_ChibiOS/hwdef/MatekH743/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/MatekH743/hwdef.dat index fb6104b001..6f69658a7a 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/MatekH743/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/MatekH743/hwdef.dat @@ -97,7 +97,7 @@ define HAL_GPIO_B_LED_PIN 90 define HAL_GPIO_LED_OFF 1 # order of UARTs (and USB) -SERIAL_ORDER OTG1 UART7 USART1 USART2 USART3 UART8 UART4 USART6 +SERIAL_ORDER OTG1 UART7 USART1 USART2 USART3 UART8 UART4 USART6 OTG2 # USART1 (telem2) PA10 USART1_RX USART1 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 6d989c8d90..8e8434ca7f 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -1154,7 +1154,7 @@ def write_UART_config(f): f.write('\n// UART configuration\n') # write out driver declarations for HAL_ChibOS_Class.cpp - devnames = "ABCDEFGH" + devnames = "ABCDEFGHI" sdev = 0 idx = 0 num_empty_uarts = 0 @@ -1262,8 +1262,8 @@ def write_UART_config(f): num_uarts = len(devlist) if 'IOMCU_UART' in config: num_uarts -= 1 - if num_uarts > 8: - error("Exceeded max num UARTs of 8 (%u)" % num_uarts) + if num_uarts > 9: + error("Exceeded max num UARTs of 9 (%u)" % num_uarts) f.write('#define HAL_UART_NUM_SERIAL_PORTS %u\n' % (num_uarts+num_empty_uarts))