From 9b057ee4f1e0e018d8533ebc55aa324e29f0b429 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 8 Jun 2016 14:55:30 +1000 Subject: [PATCH] HAL_Linux: separate out the GPIO table for Disco --- libraries/AP_HAL_Linux/GPIO.h | 4 +++- libraries/AP_HAL_Linux/GPIO_Bebop.cpp | 2 +- libraries/AP_HAL_Linux/GPIO_Disco.cpp | 16 ++++++++++++++++ libraries/AP_HAL_Linux/GPIO_Disco.h | 8 ++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 libraries/AP_HAL_Linux/GPIO_Disco.cpp create mode 100644 libraries/AP_HAL_Linux/GPIO_Disco.h diff --git a/libraries/AP_HAL_Linux/GPIO.h b/libraries/AP_HAL_Linux/GPIO.h index af7d91eb60..c7d079f598 100644 --- a/libraries/AP_HAL_Linux/GPIO.h +++ b/libraries/AP_HAL_Linux/GPIO.h @@ -25,6 +25,8 @@ private: #include "GPIO_RPI.h" #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_MINLURE #include "GPIO_Minnow.h" -#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO +#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP #include "GPIO_Bebop.h" +#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO +#include "GPIO_Disco.h" #endif diff --git a/libraries/AP_HAL_Linux/GPIO_Bebop.cpp b/libraries/AP_HAL_Linux/GPIO_Bebop.cpp index 1e37eed753..58f7cf6ca1 100644 --- a/libraries/AP_HAL_Linux/GPIO_Bebop.cpp +++ b/libraries/AP_HAL_Linux/GPIO_Bebop.cpp @@ -2,7 +2,7 @@ #include "GPIO_Bebop.h" -#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO +#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP const unsigned Linux::GPIO_Sysfs::pin_table[] = { [BEBOP_GPIO_CAMV_NRST] = 129, diff --git a/libraries/AP_HAL_Linux/GPIO_Disco.cpp b/libraries/AP_HAL_Linux/GPIO_Disco.cpp new file mode 100644 index 0000000000..1766f234b8 --- /dev/null +++ b/libraries/AP_HAL_Linux/GPIO_Disco.cpp @@ -0,0 +1,16 @@ +#include + +#include "GPIO_Disco.h" + +#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO + +const unsigned Linux::GPIO_Sysfs::pin_table[] = { + [DISCO_GPIO_MPU6050_DRDY] = 91, +}; + +const uint8_t Linux::GPIO_Sysfs::n_pins = _DISCO_GPIO_MAX; + +static_assert(ARRAY_SIZE(Linux::GPIO_Sysfs::pin_table) == _DISCO_GPIO_MAX, + "GPIO pin_table must have the same size of entries in enum gpio_disco"); + +#endif diff --git a/libraries/AP_HAL_Linux/GPIO_Disco.h b/libraries/AP_HAL_Linux/GPIO_Disco.h new file mode 100644 index 0000000000..b9b34937b0 --- /dev/null +++ b/libraries/AP_HAL_Linux/GPIO_Disco.h @@ -0,0 +1,8 @@ +#pragma once + +#include "GPIO_Sysfs.h" + +enum gpio_disco { + DISCO_GPIO_MPU6050_DRDY, + _DISCO_GPIO_MAX, +};