From 4e8f1e60929bc6832c1f17efb134f8f831dcfaa7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 6 Jul 2024 09:16:56 +1000 Subject: [PATCH] AP_HAL: added QURT board type and header --- libraries/AP_HAL/AP_HAL_Boards.h | 3 + libraries/AP_HAL/Device.h | 4 ++ libraries/AP_HAL/board/qurt.h | 108 +++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 libraries/AP_HAL/board/qurt.h diff --git a/libraries/AP_HAL/AP_HAL_Boards.h b/libraries/AP_HAL/AP_HAL_Boards.h index cd9dab2565..e077143549 100644 --- a/libraries/AP_HAL/AP_HAL_Boards.h +++ b/libraries/AP_HAL/AP_HAL_Boards.h @@ -14,6 +14,7 @@ #define HAL_BOARD_CHIBIOS 10 #define HAL_BOARD_F4LIGHT 11 // reserved #define HAL_BOARD_ESP32 12 +#define HAL_BOARD_QURT 13 #define HAL_BOARD_EMPTY 99 /* Default board subtype is -1 */ @@ -139,6 +140,8 @@ #include #elif CONFIG_HAL_BOARD == HAL_BOARD_ESP32 #include +#elif CONFIG_HAL_BOARD == HAL_BOARD_QURT + #include #else #error "Unknown CONFIG_HAL_BOARD type" #endif diff --git a/libraries/AP_HAL/Device.h b/libraries/AP_HAL/Device.h index fd62184f67..74d2c910a0 100644 --- a/libraries/AP_HAL/Device.h +++ b/libraries/AP_HAL/Device.h @@ -20,8 +20,12 @@ #include "AP_HAL_Namespace.h" #include "utility/functor.h" +#include "AP_HAL_Boards.h" +#if CONFIG_HAL_BOARD != HAL_BOARD_QURT +// we need utility for std::move, but not on QURT due to a include error in hexagon SDK #include +#endif /* * This is an interface abstracting I2C and SPI devices diff --git a/libraries/AP_HAL/board/qurt.h b/libraries/AP_HAL/board/qurt.h new file mode 100644 index 0000000000..b4bd9cc13f --- /dev/null +++ b/libraries/AP_HAL/board/qurt.h @@ -0,0 +1,108 @@ +#pragma once + +#include + +#define HAL_BOARD_NAME "QURT" +#define HAL_CPU_CLASS HAL_CPU_CLASS_1000 +#define HAL_MEM_CLASS HAL_MEM_CLASS_1000 +#define HAL_STORAGE_SIZE 32768 +#define HAL_STORAGE_SIZE_AVAILABLE HAL_STORAGE_SIZE + +// only include if compiling C++ code +#ifdef __cplusplus +#include +#define HAL_Semaphore QURT::Semaphore +#define HAL_BinarySemaphore QURT::BinarySemaphore +#endif + +#ifndef HAL_HAVE_HARDWARE_DOUBLE +#define HAL_HAVE_HARDWARE_DOUBLE 0 +#endif + +#ifndef HAL_WITH_EKF_DOUBLE +#define HAL_WITH_EKF_DOUBLE HAL_HAVE_HARDWARE_DOUBLE +#endif + +#ifndef HAL_GYROFFT_ENABLED +#define HAL_GYROFFT_ENABLED 0 +#endif + +/* + disable features for initial port + */ +#define HAL_HAVE_BOARD_VOLTAGE 0 +#define HAL_HAVE_SERVO_VOLTAGE 0 +#define HAL_HAVE_SAFETY_SWITCH 0 +#define HAL_WITH_MCU_MONITORING 0 +#define HAL_USE_QUADSPI 0 +#define HAL_WITH_DSP 0 + +#define HAL_CANFD_SUPPORTED 0 +#define HAL_NUM_CAN_IFACES 0 + +#define AP_CRASHDUMP_ENABLED 0 +#define HAL_ENABLE_DFU_BOOT 0 + + +#define HAL_LOGGING_MAVLINK_ENABLED 0 + +#define HAL_LOGGING_FILESYSTEM_ENABLED 1 + +#define AP_FILESYSTEM_POSIX_HAVE_UTIME 0 +#define AP_FILESYSTEM_POSIX_HAVE_FSYNC 0 +#define AP_FILESYSTEM_POSIX_HAVE_STATFS 0 +#define AP_FILESYSTEM_HAVE_DIRENT_DTYPE 0 + +#define AP_FILESYSTEM_POSIX_MAP_FILENAME_ALLOC 1 +#define AP_FILESYSTEM_POSIX_MAP_FILENAME_BASEDIR "/data" +#define HAL_BOARD_STORAGE_DIRECTORY "APM" +#define HAL_BOARD_LOG_DIRECTORY "APM/logs" +#define HAL_BOARD_TERRAIN_DIRECTORY "APM/terrain" + +#define SCRIPTING_DIRECTORY "APM/scripts" + +/* + a defaults file for this vehicle + */ +#ifndef HAL_PARAM_DEFAULTS_PATH +// this is an absolute path, as required by AP_Param +#define HAL_PARAM_DEFAULTS_PATH AP_FILESYSTEM_POSIX_MAP_FILENAME_BASEDIR "/APM/defaults.parm" +#endif + +#define USE_LIBC_REALLOC 1 + +#define HAL_WITH_ESC_TELEM 1 + +/* + battery monitoring setup, comes in via ESCs + */ +#define HAL_BATT_VOLT_PIN 1 +#define HAL_BATT_CURR_PIN 2 +#define HAL_BATT_MONITOR_DEFAULT 4 +#define HAL_BATT_VOLT_SCALE 1 +#define HAL_BATT_CURR_SCALE 1 + +/* + compass list + */ +#define PROBE_MAG_I2C(driver, bus, addr, args ...) ADD_BACKEND(DRIVER_ ##driver, AP_Compass_ ## driver::probe(GET_I2C_DEVICE(bus, addr),##args)) +#define HAL_MAG_PROBE_LIST PROBE_MAG_I2C(QMC5883L, 0, 0x0d, false, ROTATION_PITCH_180_YAW_90) + +/* + barometer list + */ +#define PROBE_BARO_I2C(driver, bus, addr, args ...) ADD_BACKEND(AP_Baro_ ## driver::probe(*this,std::move(GET_I2C_DEVICE(bus, addr)),##args)) +#define HAL_BARO_PROBE_LIST PROBE_BARO_I2C(ICP101XX, 3, 0x63) + +/* + IMU list + */ +#define PROBE_IMU_SPI(driver, devname, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,hal.spi->get_device(devname),##args)) +#define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensensev3, "INV3", ROTATION_ROLL_180) + +/* + bring in missing standard library functions + */ +#include + +#define DEFAULT_SERIAL4_PROTOCOL 23 // RC input