HAL_ChibiOS: auto-generate UART driver declarations
This commit is contained in:
parent
8e87c30a33
commit
468cadca45
@ -24,16 +24,14 @@
|
||||
#include <AP_HAL_ChibiOS/AP_HAL_ChibiOS_Private.h>
|
||||
#include "shared_dma.h"
|
||||
|
||||
static ChibiOS::ChibiUARTDriver uartADriver(0);
|
||||
static ChibiOS::ChibiUARTDriver uartBDriver(1);
|
||||
static ChibiOS::ChibiUARTDriver uartCDriver(2);
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_SKYVIPER_F412
|
||||
static Empty::UARTDriver uartDDriver;
|
||||
static Empty::UARTDriver uartEDriver;
|
||||
#else
|
||||
static ChibiOS::ChibiUARTDriver uartDDriver(3);
|
||||
static ChibiOS::ChibiUARTDriver uartEDriver(4);
|
||||
#endif
|
||||
#include <hwdef.h>
|
||||
|
||||
static HAL_UARTA_DRIVER;
|
||||
static HAL_UARTB_DRIVER;
|
||||
static HAL_UARTC_DRIVER;
|
||||
static HAL_UARTD_DRIVER;
|
||||
static HAL_UARTE_DRIVER;
|
||||
static HAL_UARTF_DRIVER;
|
||||
static ChibiOS::I2CDeviceManager i2cDeviceManager;
|
||||
static ChibiOS::SPIDeviceManager spiDeviceManager;
|
||||
static ChibiOS::ChibiAnalogIn analogIn;
|
||||
@ -49,8 +47,8 @@ static FATFS SDC_FS; // FATFS object
|
||||
#endif
|
||||
|
||||
#if HAL_WITH_IO_MCU
|
||||
HAL_UART_IO_DRIVER;
|
||||
#include <AP_IOMCU/AP_IOMCU.h>
|
||||
ChibiOS::ChibiUARTDriver uart_io(HAL_UART_IOMCU_IDX);
|
||||
AP_IOMCU iomcu(uart_io);
|
||||
#endif
|
||||
|
||||
@ -61,7 +59,7 @@ HAL_ChibiOS::HAL_ChibiOS() :
|
||||
&uartCDriver,
|
||||
&uartDDriver,
|
||||
&uartEDriver,
|
||||
nullptr, /* no uartF */
|
||||
&uartFDriver,
|
||||
&i2cDeviceManager,
|
||||
&spiDeviceManager,
|
||||
&analogIn,
|
||||
|
@ -346,12 +346,24 @@ def write_UART_config(f):
|
||||
uart_list = config['UART_ORDER']
|
||||
f.write('\n// UART configuration\n')
|
||||
|
||||
# write out driver declarations for HAL_ChibOS_Class.cpp
|
||||
devnames = "ABCDEFGH"
|
||||
for dev in uart_list:
|
||||
idx = uart_list.index(dev)
|
||||
f.write('#define HAL_UART%s_DRIVER ChibiOS::ChibiUARTDriver uart%sDriver(%u)\n' % (devnames[idx], devnames[idx], idx))
|
||||
for idx in range(len(uart_list), 6):
|
||||
f.write('#define HAL_UART%s_DRIVER Empty::UARTDriver uart%sDriver\n' % (devnames[idx], devnames[idx]))
|
||||
|
||||
|
||||
if 'IOMCU_UART' in config:
|
||||
f.write('#define HAL_WITH_IO_MCU 1\n')
|
||||
f.write('#define HAL_UART_IOMCU_IDX %u\n' % len(uart_list))
|
||||
idx = len(uart_list)
|
||||
f.write('#define HAL_UART_IOMCU_IDX %u\n' % idx)
|
||||
f.write('#define HAL_UART_IO_DRIVER ChibiOS::ChibiUARTDriver uart_io(HAL_UART_IOMCU_IDX)\n')
|
||||
uart_list.append(config['IOMCU_UART'][0])
|
||||
else:
|
||||
f.write('#define HAL_WITH_IO_MCU 0\n')
|
||||
f.write('\n')
|
||||
|
||||
devlist = []
|
||||
for dev in uart_list:
|
||||
@ -376,6 +388,8 @@ def write_UART_config(f):
|
||||
f.write("STM32_%s_RX_DMA_CONFIG, STM32_%s_TX_DMA_CONFIG, %s}\n" % (dev, dev, rts_line))
|
||||
f.write('#define HAL_UART_DEVICE_LIST %s\n\n' % ','.join(devlist))
|
||||
|
||||
|
||||
|
||||
def write_I2C_config(f):
|
||||
'''write I2C config defines'''
|
||||
get_config('I2C_ORDER')
|
||||
|
Loading…
Reference in New Issue
Block a user