AP_HAL_Linux: use GPIO_Sysfs for Edge

This commit is contained in:
Georgii Staroselskii 2017-10-31 19:36:51 +03:00 committed by Lucas De Marchi
parent 8fcd30c611
commit 5254ee03c2
6 changed files with 55 additions and 6 deletions

View File

@ -24,7 +24,6 @@ private:
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE
#include "GPIO_BBB.h"
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE || \
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 || \
@ -32,6 +31,8 @@ private:
#include "GPIO_RPI.h"
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2
#include "GPIO_Navio2.h"
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
#include "GPIO_Edge.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

View File

@ -0,0 +1,28 @@
#include <AP_Common/AP_Common.h>
#include "GPIO_Edge.h"
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
const unsigned Linux::GPIO_Sysfs::pin_table[] = {
[EDGE_GPIO_PWM1] = 500,
[EDGE_GPIO_PWM2] = 501,
[EDGE_GPIO_PWM3] = 502,
[EDGE_GPIO_PWM4] = 503,
[EDGE_GPIO_PWM5] = 504,
[EDGE_GPIO_PWM6] = 505,
[EDGE_GPIO_PWM7] = 506,
[EDGE_GPIO_PWM8] = 507,
[EDGE_GPIO_PWM9] = 508,
[EDGE_GPIO_PWM10] = 509,
[EDGE_GPIO_PWM11] = 510,
[EDGE_GPIO_PWM12] = 511,
[EDGE_GPIO_HEAT_ENABLE] = 26,
};
const uint8_t Linux::GPIO_Sysfs::n_pins = _EDGE_GPIO_MAX;
static_assert(ARRAY_SIZE(Linux::GPIO_Sysfs::pin_table) == _EDGE_GPIO_MAX,
"GPIO pin_table must have the same size of entries in enum gpio_minnow");
#endif

View File

@ -0,0 +1,20 @@
#pragma once
#include "GPIO_Sysfs.h"
enum gpio_edge {
EDGE_GPIO_PWM1,
EDGE_GPIO_PWM2,
EDGE_GPIO_PWM3,
EDGE_GPIO_PWM4,
EDGE_GPIO_PWM5,
EDGE_GPIO_PWM6,
EDGE_GPIO_PWM7,
EDGE_GPIO_PWM8,
EDGE_GPIO_PWM9,
EDGE_GPIO_PWM10,
EDGE_GPIO_PWM11,
EDGE_GPIO_PWM12,
EDGE_GPIO_HEAT_ENABLE,
_EDGE_GPIO_MAX,
};

View File

@ -4,7 +4,6 @@
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_EDGE || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
#include <errno.h>

View File

@ -111,13 +111,13 @@ static GPIO_BBB gpioDriver;
use the RPI gpio driver on Navio
*/
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE || \
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
static GPIO_RPI gpioDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
static GPIO_Sysfs gpioDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_MINLURE || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP || \

View File

@ -30,6 +30,7 @@
#include <unistd.h>
#include "Heat_Pwm.h"
#include "GPIO.h"
extern const AP_HAL::HAL& hal;
@ -42,8 +43,8 @@ HeatPwm::HeatPwm(uint8_t pwm_num, float Kp, float Ki, uint32_t period_ns) :
{
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
_pwm = new PWM_Sysfs(0, pwm_num);
hal.gpio->pinMode(26, HAL_GPIO_OUTPUT);
hal.gpio->write(26, 1);
hal.gpio->pinMode(EDGE_GPIO_HEAT_ENABLE, HAL_GPIO_OUTPUT);
hal.gpio->write(EDGE_GPIO_HEAT_ENABLE, 1);
#else
_pwm = new PWM_Sysfs_Bebop(pwm_num);
#endif