AP_HAL_Linux: Use template to generate raspberry pins

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
This commit is contained in:
Patrick José Pereira 2020-03-09 19:43:10 -03:00 committed by Lucas De Marchi
parent 5a4b648cf5
commit e65cc35fb0
3 changed files with 19 additions and 39 deletions

View File

@ -9,37 +9,17 @@
#define PAGE_SIZE (4*1024) #define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024) #define BLOCK_SIZE (4*1024)
// Raspberry Pi GPIO mapping /**
#define RPI_GPIO_2 2 // Pin 3 * @brief Check for valid Raspberry Pi pin range
#define RPI_GPIO_3 3 // Pin 5 *
#define RPI_GPIO_4 4 // Pin 7 * @tparam pin
#define RPI_GPIO_5 5 // Pin 29 * @return uint8_t
#define RPI_GPIO_6 6 // Pin 31 */
#define RPI_GPIO_7 7 // Pin 26 template <uint8_t pin> constexpr uint8_t RPI_GPIO_()
#define RPI_GPIO_8 8 // Pin 24 {
#define RPI_GPIO_9 9 // Pin 21 static_assert(pin > 1 && pin < 32, "Invalid pin value.");
#define RPI_GPIO_10 10 // Pin 19 return pin;
#define RPI_GPIO_11 11 // Pin 23 }
#define RPI_GPIO_12 12 // Pin 32
#define RPI_GPIO_13 13 // Pin 33
#define RPI_GPIO_14 14 // Pin 8
#define RPI_GPIO_15 15 // Pin 10
#define RPI_GPIO_16 16 // Pin 36
#define RPI_GPIO_17 17 // Pin 11
#define RPI_GPIO_18 18 // Pin 12
#define RPI_GPIO_19 19 // Pin 35
#define RPI_GPIO_20 20 // Pin 38
#define RPI_GPIO_21 21 // Pin 40
#define RPI_GPIO_22 22 // Pin 15
#define RPI_GPIO_23 23 // Pin 16
#define RPI_GPIO_24 24 // Pin 18
#define RPI_GPIO_25 25 // Pin 22
#define RPI_GPIO_26 26 // Pin 37
#define RPI_GPIO_27 27 // Pin 13
#define RPI_GPIO_28 28 // Pin 3
#define RPI_GPIO_29 29 // Pin 4
#define RPI_GPIO_30 30 // Pin 5
#define RPI_GPIO_31 31 // Pin 6
namespace Linux { namespace Linux {

View File

@ -179,15 +179,15 @@ static RCOutput_AioPRU rcoutDriver;
*/ */
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \ #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), true, 3, RPI_GPIO_27); static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), true, 3, RPI_GPIO_<27>());
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), true, 3, NAVIO_GPIO_PCA_OE); static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), true, 3, NAVIO_GPIO_PCA_OE);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_QUATENARY_ADDRESS), false, 0, RPI_GPIO_4); static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_QUATENARY_ADDRESS), false, 0, RPI_GPIO_<4>());
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_QUINARY_ADDRESS), false, 0, RPI_GPIO_27); static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_QUINARY_ADDRESS), false, 0, RPI_GPIO_<27>());
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), false, 0, RPI_GPIO_27); static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), false, 0, RPI_GPIO_<27>());
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ZYNQ || \ #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ZYNQ || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OCPOC_ZYNQ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OCPOC_ZYNQ
static RCOutput_ZYNQ rcoutDriver; static RCOutput_ZYNQ rcoutDriver;

View File

@ -44,9 +44,9 @@
// Each gpio stands for a rcinput channel, // Each gpio stands for a rcinput channel,
// the first one in RcChnGpioTbl is channel 1 in receiver // the first one in RcChnGpioTbl is channel 1 in receiver
static uint16_t RcChnGpioTbl[RCIN_RPI_CHN_NUM] = { static uint16_t RcChnGpioTbl[RCIN_RPI_CHN_NUM] = {
RPI_GPIO_5, RPI_GPIO_6, RPI_GPIO_12, RPI_GPIO_<5>(), RPI_GPIO_<6>(), RPI_GPIO_<12>(),
RPI_GPIO_13, RPI_GPIO_19, RPI_GPIO_20, RPI_GPIO_<13>(), RPI_GPIO_<19>(), RPI_GPIO_<20>(),
RPI_GPIO_21, RPI_GPIO_26 RPI_GPIO_<21>(), RPI_GPIO_<26>()
}; };
#else #else
#define RCIN_RPI_SIG_HIGH 1 #define RCIN_RPI_SIG_HIGH 1
@ -56,7 +56,7 @@ static uint16_t RcChnGpioTbl[RCIN_RPI_CHN_NUM] = {
#define PAGE_SIZE (4*1024) #define PAGE_SIZE (4*1024)
NAVIO_GPIO_PPM_IN NAVIO_GPIO_PPM_IN
#else #else
RPI_GPIO_4 RPI_GPIO_<4>()
#endif #endif
}; };
#endif // CONFIG_HAL_BOARD_SUBTYPE #endif // CONFIG_HAL_BOARD_SUBTYPE