From ffa8412df599f13910d39d172ebc8e096855c8ae Mon Sep 17 00:00:00 2001 From: Mohammad Hefny Date: Tue, 7 Sep 2021 07:17:32 +0200 Subject: [PATCH] AP_HAL_Linux: define board features on Linux module --- libraries/AP_HAL/board/linux.h | 37 ++++++++++++++++++++++ libraries/AP_HAL_Linux/GPIO.h | 3 +- libraries/AP_HAL_Linux/GPIO_RPI.cpp | 3 +- libraries/AP_HAL_Linux/HAL_Linux_Class.cpp | 14 +++++--- libraries/AP_HAL_Linux/RCInput_RPI.cpp | 11 ++++++- libraries/AP_HAL_Linux/RCInput_RPI.h | 2 ++ libraries/AP_HAL_Linux/SPIDevice.cpp | 5 +++ libraries/AP_HAL_Linux/Scheduler.cpp | 3 ++ libraries/AP_HAL_Linux/Util_RPI.cpp | 3 +- 9 files changed, 73 insertions(+), 8 deletions(-) diff --git a/libraries/AP_HAL/board/linux.h b/libraries/AP_HAL/board/linux.h index 74847f28d8..d9833b4368 100644 --- a/libraries/AP_HAL/board/linux.h +++ b/libraries/AP_HAL/board/linux.h @@ -292,6 +292,43 @@ #define HAL_HAVE_GETTIME_SETTIME 1 +#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 + + //#define HAL_BARO_ALLOW_INIT_NO_BARO + + // Activate SUB Model Configuratopm + #define HAL_BOARD_SUBTYPE_LINUX_OBAL_V1_MPU_9250_SPI + + // Define Notify + #define OBAL_NOTIFY_LED + + + // GY-91 SPI Connection + #ifdef HAL_BOARD_SUBTYPE_LINUX_OBAL_V1_MPU_9250_SPI + #define HAL_BOARD_LOG_DIRECTORY "/home/pi/ardupilot/logs" + #define HAL_BOARD_TERRAIN_DIRECTORY "/home/pi/ardupilot/terrain" + #define HAL_BOARD_STORAGE_DIRECTORY "/home/pi/ardupilot" + #define HAL_PARAM_DEFAULTS_PATH "/home/pi/ardupilot.parm" + + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE) + #define HAL_MAG_PROBE_LIST PROBE_MAG_IMU(AK8963, mpu9250, 0, ROTATION_NONE) + #define HAL_BARO_PROBE_LIST PROBE_BARO_I2C(BMP085, 1, 0x77) + //#define HAL_MAG_PROBE_LIST PROBE_MAG_I2C(QMC5883L, 1, 0x0d,true , ROTATION_NONE) + + #define HAL_PROBE_EXTERNAL_I2C_COMPASSES + #endif + + + #ifdef OBAL_NOTIFY_LED + #define HAL_GPIO_A_LED_PIN 27 // You can choose between 27,22,4,12 + #define HAL_GPIO_C_LED_PIN 22 // You can choose between 27,22,4,12 + #define HAL_GPIO_B_LED_PIN 4 // You can choose between 27,22,4,12 + #define HAL_GPIO_LED_ON 1 + #define HAL_GPIO_LED_OFF 0 + #endif + #define HAL_BUZZER_PIN 12 // You can choose between 27,22,4,12 + #define OBAL_ALLOW_ADC 1 + #else #error "no Linux board subtype set" #endif diff --git a/libraries/AP_HAL_Linux/GPIO.h b/libraries/AP_HAL_Linux/GPIO.h index d63a675a35..c63cb4c026 100644 --- a/libraries/AP_HAL_Linux/GPIO.h +++ b/libraries/AP_HAL_Linux/GPIO.h @@ -28,7 +28,8 @@ private: CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR || \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 #include "GPIO_RPI.h" #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO #include "GPIO_Navio.h" diff --git a/libraries/AP_HAL_Linux/GPIO_RPI.cpp b/libraries/AP_HAL_Linux/GPIO_RPI.cpp index bdd0b9c1c5..5186e48816 100644 --- a/libraries/AP_HAL_Linux/GPIO_RPI.cpp +++ b/libraries/AP_HAL_Linux/GPIO_RPI.cpp @@ -4,7 +4,8 @@ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR || \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 #include #include diff --git a/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp b/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp index fe30a4b483..109b655731 100644 --- a/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp +++ b/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp @@ -55,7 +55,8 @@ using namespace Linux; CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR || \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 static UtilRPI utilInstance; #else static Util utilInstance; @@ -86,7 +87,8 @@ static UARTDriver uartBDriver(false); CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR|| \ + ((CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1) && (OBAL_ALLOW_ADC ==1)) static AnalogIn_ADS1115 analogIn; #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD || \ @@ -119,7 +121,8 @@ static GPIO_BBB gpioDriver; CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR || \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 static GPIO_RPI gpioDriver; #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \ @@ -147,7 +150,8 @@ static RCInput_Multi rcinDriver{2, new RCInput_AioPRU, new RCInput_RCProtocol(NU CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 static RCInput_RPI rcinDriver; #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ZYNQ || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OCPOC_ZYNQ @@ -209,6 +213,8 @@ static ap::RCOutput_Tap rcoutDriver; static RCOutput_Sysfs rcoutDriver(0, 0, 15); #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ static RCOutput_Sysfs rcoutDriver(0, 0, 8); +#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 +static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), 0, 0, RPI_GPIO_<17>()); #else static Empty::RCOutput rcoutDriver; #endif diff --git a/libraries/AP_HAL_Linux/RCInput_RPI.cpp b/libraries/AP_HAL_Linux/RCInput_RPI.cpp index 60e94f0977..d34dbafe2d 100644 --- a/libraries/AP_HAL_Linux/RCInput_RPI.cpp +++ b/libraries/AP_HAL_Linux/RCInput_RPI.cpp @@ -4,7 +4,8 @@ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 #include #include #include @@ -50,6 +51,14 @@ static uint16_t RcChnGpioTbl[RCIN_RPI_CHN_NUM] = { RPI_GPIO_<13>(), RPI_GPIO_<19>(), RPI_GPIO_<20>(), RPI_GPIO_<21>(), RPI_GPIO_<26>() }; +#elif (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1) +#define RCIN_RPI_SIG_HIGH 0 +#define RCIN_RPI_SIG_LOW 1 +static uint16_t RcChnGpioTbl[RCIN_RPI_CHN_NUM] = { + RPI_GPIO_<5>(), RPI_GPIO_<6>(), RPI_GPIO_<13>(), + RPI_GPIO_<19>(), RPI_GPIO_<26>(), RPI_GPIO_<21>(), + RPI_GPIO_<20>(), RPI_GPIO_<16>() +}; #else #define RCIN_RPI_SIG_HIGH 1 #define RCIN_RPI_SIG_LOW 0 diff --git a/libraries/AP_HAL_Linux/RCInput_RPI.h b/libraries/AP_HAL_Linux/RCInput_RPI.h index 57d7f8476d..04808af443 100644 --- a/libraries/AP_HAL_Linux/RCInput_RPI.h +++ b/libraries/AP_HAL_Linux/RCInput_RPI.h @@ -23,6 +23,8 @@ #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH #define RCIN_RPI_CHN_NUM 8 +#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 +#define RCIN_RPI_CHN_NUM 8 #else #define RCIN_RPI_CHN_NUM 1 #endif diff --git a/libraries/AP_HAL_Linux/SPIDevice.cpp b/libraries/AP_HAL_Linux/SPIDevice.cpp index db7092576e..6fffa5ac4d 100644 --- a/libraries/AP_HAL_Linux/SPIDevice.cpp +++ b/libraries/AP_HAL_Linux/SPIDevice.cpp @@ -144,6 +144,11 @@ SPIDesc SPIDeviceManager::_device[] = { SPIDesc("rst_a", 0, 2, SPI_MODE_3, 8, SPI_CS_KERNEL, 1*MHZ, 10*MHZ), SPIDesc("ms5611", 0, 3, SPI_MODE_3, 8, SPI_CS_KERNEL, 1*MHZ, 10*MHZ), }; +#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 && \ + defined (HAL_BOARD_SUBTYPE_LINUX_OBAL_V1_MPU_9250_SPI) +SPIDesc SPIDeviceManager::_device[] = { + SPIDesc("mpu9250", 0, 0, SPI_MODE_3, 8, SPI_CS_KERNEL, 1*MHZ, 10*MHZ), +}; #else // empty device table SPIDesc SPIDeviceManager::_device[] = { diff --git a/libraries/AP_HAL_Linux/Scheduler.cpp b/libraries/AP_HAL_Linux/Scheduler.cpp index f2780d852e..4c0e7020ab 100644 --- a/libraries/AP_HAL_Linux/Scheduler.cpp +++ b/libraries/AP_HAL_Linux/Scheduler.cpp @@ -40,6 +40,9 @@ extern const AP_HAL::HAL& hal; CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI #define APM_LINUX_RCIN_RATE 500 #define APM_LINUX_IO_RATE 50 +#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 +#define APM_LINUX_RCIN_RATE 50 +#define APM_LINUX_IO_RATE 50 #else #define APM_LINUX_RCIN_RATE 100 #define APM_LINUX_IO_RATE 50 diff --git a/libraries/AP_HAL_Linux/Util_RPI.cpp b/libraries/AP_HAL_Linux/Util_RPI.cpp index aac886397a..ecbf789023 100644 --- a/libraries/AP_HAL_Linux/Util_RPI.cpp +++ b/libraries/AP_HAL_Linux/Util_RPI.cpp @@ -7,7 +7,8 @@ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR || \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 #include #include