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 <AP_HAL_ChibiOS/AP_HAL_ChibiOS_Private.h>
|
||||||
#include "shared_dma.h"
|
#include "shared_dma.h"
|
||||||
|
|
||||||
static ChibiOS::ChibiUARTDriver uartADriver(0);
|
#include <hwdef.h>
|
||||||
static ChibiOS::ChibiUARTDriver uartBDriver(1);
|
|
||||||
static ChibiOS::ChibiUARTDriver uartCDriver(2);
|
static HAL_UARTA_DRIVER;
|
||||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_SKYVIPER_F412
|
static HAL_UARTB_DRIVER;
|
||||||
static Empty::UARTDriver uartDDriver;
|
static HAL_UARTC_DRIVER;
|
||||||
static Empty::UARTDriver uartEDriver;
|
static HAL_UARTD_DRIVER;
|
||||||
#else
|
static HAL_UARTE_DRIVER;
|
||||||
static ChibiOS::ChibiUARTDriver uartDDriver(3);
|
static HAL_UARTF_DRIVER;
|
||||||
static ChibiOS::ChibiUARTDriver uartEDriver(4);
|
|
||||||
#endif
|
|
||||||
static ChibiOS::I2CDeviceManager i2cDeviceManager;
|
static ChibiOS::I2CDeviceManager i2cDeviceManager;
|
||||||
static ChibiOS::SPIDeviceManager spiDeviceManager;
|
static ChibiOS::SPIDeviceManager spiDeviceManager;
|
||||||
static ChibiOS::ChibiAnalogIn analogIn;
|
static ChibiOS::ChibiAnalogIn analogIn;
|
||||||
@ -49,8 +47,8 @@ static FATFS SDC_FS; // FATFS object
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAL_WITH_IO_MCU
|
#if HAL_WITH_IO_MCU
|
||||||
|
HAL_UART_IO_DRIVER;
|
||||||
#include <AP_IOMCU/AP_IOMCU.h>
|
#include <AP_IOMCU/AP_IOMCU.h>
|
||||||
ChibiOS::ChibiUARTDriver uart_io(HAL_UART_IOMCU_IDX);
|
|
||||||
AP_IOMCU iomcu(uart_io);
|
AP_IOMCU iomcu(uart_io);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -61,7 +59,7 @@ HAL_ChibiOS::HAL_ChibiOS() :
|
|||||||
&uartCDriver,
|
&uartCDriver,
|
||||||
&uartDDriver,
|
&uartDDriver,
|
||||||
&uartEDriver,
|
&uartEDriver,
|
||||||
nullptr, /* no uartF */
|
&uartFDriver,
|
||||||
&i2cDeviceManager,
|
&i2cDeviceManager,
|
||||||
&spiDeviceManager,
|
&spiDeviceManager,
|
||||||
&analogIn,
|
&analogIn,
|
||||||
|
@ -346,12 +346,24 @@ def write_UART_config(f):
|
|||||||
uart_list = config['UART_ORDER']
|
uart_list = config['UART_ORDER']
|
||||||
f.write('\n// UART configuration\n')
|
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:
|
if 'IOMCU_UART' in config:
|
||||||
f.write('#define HAL_WITH_IO_MCU 1\n')
|
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])
|
uart_list.append(config['IOMCU_UART'][0])
|
||||||
else:
|
else:
|
||||||
f.write('#define HAL_WITH_IO_MCU 0\n')
|
f.write('#define HAL_WITH_IO_MCU 0\n')
|
||||||
|
f.write('\n')
|
||||||
|
|
||||||
devlist = []
|
devlist = []
|
||||||
for dev in uart_list:
|
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("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))
|
f.write('#define HAL_UART_DEVICE_LIST %s\n\n' % ','.join(devlist))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def write_I2C_config(f):
|
def write_I2C_config(f):
|
||||||
'''write I2C config defines'''
|
'''write I2C config defines'''
|
||||||
get_config('I2C_ORDER')
|
get_config('I2C_ORDER')
|
||||||
|
Loading…
Reference in New Issue
Block a user