AP_HAL: support up to 9 UARTs

This commit is contained in:
Andrew Tridgell 2021-11-05 14:17:40 +11:00 committed by Peter Barker
parent ccf89c2031
commit 8c2074907b
2 changed files with 5 additions and 2 deletions

View File

@ -17,7 +17,7 @@ AP_HAL::UARTDriver* AP_HAL::HAL::serial(uint8_t sernum) const
{
UARTDriver **uart_array = const_cast<UARTDriver**>(&uartA);
// this mapping captures the historical use of uartB as SERIAL3
const uint8_t mapping[] = { 0, 2, 3, 1, 4, 5, 6, 7, 8 };
const uint8_t mapping[] = { 0, 2, 3, 1, 4, 5, 6, 7, 8, 9 };
static_assert(sizeof(mapping) == num_serial, "num_serial must match mapping");
if (sernum >= num_serial) {
return nullptr;

View File

@ -29,6 +29,7 @@ public:
AP_HAL::UARTDriver* _uartG, // extra2
AP_HAL::UARTDriver* _uartH, // extra3
AP_HAL::UARTDriver* _uartI, // extra4
AP_HAL::UARTDriver* _uartJ, // extra5
AP_HAL::I2CDeviceManager* _i2c_mgr,
AP_HAL::SPIDeviceManager* _spi,
AP_HAL::QSPIDeviceManager* _qspi,
@ -58,6 +59,7 @@ public:
uartG(_uartG),
uartH(_uartH),
uartI(_uartI),
uartJ(_uartJ),
i2c_mgr(_i2c_mgr),
spi(_spi),
qspi(_qspi),
@ -115,6 +117,7 @@ private:
AP_HAL::UARTDriver* uartG;
AP_HAL::UARTDriver* uartH;
AP_HAL::UARTDriver* uartI;
AP_HAL::UARTDriver* uartJ;
public:
AP_HAL::I2CDeviceManager* i2c_mgr;
@ -140,5 +143,5 @@ public:
// access to serial ports using SERIALn_ numbering
UARTDriver* serial(uint8_t sernum) const;
static constexpr uint8_t num_serial = 9;
static constexpr uint8_t num_serial = 10;
};