mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-02 02:40:34 +08:00
delete drv_gpio.h, modules/gpio_led, and fmu GPIO ioctls
This commit is contained in:
committed by
Lorenz Meier
parent
c303e36ed0
commit
d4e06e517a
@@ -232,14 +232,6 @@
|
||||
#define BOARD_BATTERY2_A_PER_V 0.0f
|
||||
#endif
|
||||
|
||||
/* Conditional use of FMU GPIO
|
||||
* If the board use the PX4FMU driver and the board provides
|
||||
* BOARD_FMU_GPIO_TAB then we publish the logical BOARD_HAS_FMU_GPIO
|
||||
*/
|
||||
#if defined(BOARD_FMU_GPIO_TAB)
|
||||
# define BOARD_HAS_FMU_GPIO
|
||||
#endif
|
||||
|
||||
/* Conditional use of PX4 PIO is Used to determine if the board
|
||||
* has a PX4IO processor.
|
||||
* We then publish the logical BOARD_USES_PX4IO
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file drv_gpio.h
|
||||
*
|
||||
* Generic GPIO ioctl interface.
|
||||
*/
|
||||
|
||||
#ifndef _DRV_GPIO_H
|
||||
#define _DRV_GPIO_H
|
||||
|
||||
#include <px4_config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/**
|
||||
* Device paths for devices that support the GPIO ioctl protocol.
|
||||
*/
|
||||
#define PX4FMU_DEVICE_PATH "/dev/px4fmu"
|
||||
#define PX4IO_DEVICE_PATH "/dev/px4io"
|
||||
|
||||
/*
|
||||
* IOCTL definitions.
|
||||
*
|
||||
* For all ioctls, the (arg) argument is a bitmask of GPIOs to be affected
|
||||
* by the operation, with the LSB being the lowest-numbered GPIO.
|
||||
*
|
||||
* Note that there may be board-specific relationships between GPIOs;
|
||||
* applications using GPIOs should be aware of this.
|
||||
*/
|
||||
#define _GPIOCBASE 0x2700
|
||||
#define GPIOC(_x) _IOC(_GPIOCBASE, _x)
|
||||
|
||||
/** reset all board GPIOs to their default state */
|
||||
#define GPIO_RESET GPIOC(0)
|
||||
|
||||
/** configure the board GPIOs in (arg) as outputs */
|
||||
#define GPIO_SET_OUTPUT GPIOC(1)
|
||||
|
||||
/** set the GPIOs in (arg) */
|
||||
#define GPIO_SET GPIOC(10)
|
||||
|
||||
/** clear the GPIOs in (arg) */
|
||||
#define GPIO_CLEAR GPIOC(11)
|
||||
|
||||
#endif /* _DRV_GPIO_H */
|
||||
+2
-164
@@ -42,7 +42,6 @@
|
||||
#include <board_config.h>
|
||||
#include <drivers/device/device.h>
|
||||
#include <drivers/device/i2c.h>
|
||||
#include <drivers/drv_gpio.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_input_capture.h>
|
||||
#include <drivers/drv_mixer.h>
|
||||
@@ -101,6 +100,8 @@ enum PortMode {
|
||||
# error "board_config.h needs to define BOARD_HAS_PWM"
|
||||
#endif
|
||||
|
||||
#define PX4FMU_DEVICE_PATH "/dev/px4fmu"
|
||||
|
||||
class PX4FMU : public cdev::CDev, public ModuleBase<PX4FMU>
|
||||
{
|
||||
public:
|
||||
@@ -263,23 +264,8 @@ private:
|
||||
|
||||
void update_params();
|
||||
|
||||
struct GPIOConfig {
|
||||
uint32_t input;
|
||||
uint32_t output;
|
||||
uint32_t alt;
|
||||
};
|
||||
|
||||
#if defined(BOARD_HAS_FMU_GPIO)
|
||||
static const GPIOConfig _gpio_tab[];
|
||||
static const unsigned _ngpio;
|
||||
#endif
|
||||
static void sensor_reset(int ms);
|
||||
static void peripheral_reset(int ms);
|
||||
int gpio_reset(void);
|
||||
int gpio_set_function(uint32_t gpios, int function);
|
||||
int gpio_write(uint32_t gpios, int function);
|
||||
int gpio_read(uint32_t *value);
|
||||
int gpio_ioctl(file *filp, int cmd, unsigned long arg);
|
||||
|
||||
int capture_ioctl(file *filp, int cmd, unsigned long arg);
|
||||
|
||||
@@ -296,11 +282,6 @@ private:
|
||||
inline void reorder_outputs(uint16_t values[MAX_ACTUATORS]);
|
||||
};
|
||||
|
||||
#if defined(BOARD_HAS_FMU_GPIO)
|
||||
const PX4FMU::GPIOConfig PX4FMU::_gpio_tab[] = BOARD_FMU_GPIO_TAB;
|
||||
|
||||
const unsigned PX4FMU::_ngpio = arraySize(PX4FMU::_gpio_tab);
|
||||
#endif
|
||||
pwm_limit_t PX4FMU::_pwm_limit;
|
||||
actuator_armed_s PX4FMU::_armed = {};
|
||||
work_s PX4FMU::_work = {};
|
||||
@@ -1464,13 +1445,6 @@ PX4FMU::ioctl(file *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* try it as a GPIO ioctl first */
|
||||
ret = gpio_ioctl(filp, cmd, arg);
|
||||
|
||||
if (ret != -ENOTTY) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* try it as a Capture ioctl next */
|
||||
ret = capture_ioctl(filp, cmd, arg);
|
||||
|
||||
@@ -2311,100 +2285,6 @@ PX4FMU::peripheral_reset(int ms)
|
||||
board_peripheral_reset(ms);
|
||||
}
|
||||
|
||||
int
|
||||
PX4FMU::gpio_reset(void)
|
||||
{
|
||||
#if !defined(BOARD_HAS_FMU_GPIO)
|
||||
return -EINVAL;
|
||||
#else
|
||||
|
||||
/*
|
||||
* Setup default GPIO config - all pins as GPIOs, input if
|
||||
* possible otherwise output if possible.
|
||||
*/
|
||||
for (unsigned i = 0; i < _ngpio; i++) {
|
||||
if (_gpio_tab[i].input != 0) {
|
||||
px4_arch_configgpio(_gpio_tab[i].input);
|
||||
|
||||
} else if (_gpio_tab[i].output != 0) {
|
||||
px4_arch_configgpio(_gpio_tab[i].output);
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(GPIO_GPIO_DIR)
|
||||
/* if we have a GPIO direction control, set it to zero (input) */
|
||||
px4_arch_gpiowrite(GPIO_GPIO_DIR, 0);
|
||||
px4_arch_configgpio(GPIO_GPIO_DIR);
|
||||
# endif
|
||||
return OK;
|
||||
#endif // !defined(BOARD_HAS_FMU_GPIO)
|
||||
}
|
||||
|
||||
int
|
||||
PX4FMU::gpio_set_function(uint32_t gpios, int function)
|
||||
{
|
||||
#if !defined(BOARD_HAS_FMU_GPIO)
|
||||
return -EINVAL;
|
||||
#else
|
||||
|
||||
/* configure selected GPIOs as required */
|
||||
for (unsigned i = 0; i < _ngpio; i++) {
|
||||
if (gpios & (1 << i)) {
|
||||
switch (function) {
|
||||
case GPIO_SET_OUTPUT:
|
||||
if (_gpio_tab[i].output) {
|
||||
px4_arch_configgpio(_gpio_tab[i].output);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
#endif // !defined(BOARD_HAS_FMU_GPIO)
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
PX4FMU::gpio_write(uint32_t gpios, int function)
|
||||
{
|
||||
#if !defined(BOARD_HAS_FMU_GPIO)
|
||||
return -EINVAL;
|
||||
#else
|
||||
int value = (function == GPIO_SET) ? 1 : 0;
|
||||
|
||||
for (unsigned i = 0; i < _ngpio; i++) {
|
||||
if (gpios & (1 << i)) {
|
||||
if (_gpio_tab[i].output) {
|
||||
px4_arch_gpiowrite(_gpio_tab[i].output, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
PX4FMU::gpio_read(uint32_t *value)
|
||||
{
|
||||
#if !defined(BOARD_HAS_FMU_GPIO)
|
||||
return -EINVAL;
|
||||
#else
|
||||
uint32_t bits = 0;
|
||||
|
||||
for (unsigned i = 0; i < _ngpio; i++) {
|
||||
if (_gpio_tab[i].input != 0 && px4_arch_gpioread(_gpio_tab[i].input)) {
|
||||
bits |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
*value = bits;
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
PX4FMU::capture_ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
@@ -2551,37 +2431,6 @@ PX4FMU::capture_ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
PX4FMU::gpio_ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
lock();
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
case GPIO_RESET:
|
||||
ret = gpio_reset();
|
||||
break;
|
||||
|
||||
case GPIO_SET_OUTPUT:
|
||||
ret = gpio_set_function(arg, cmd);
|
||||
break;
|
||||
|
||||
case GPIO_SET:
|
||||
case GPIO_CLEAR:
|
||||
ret = gpio_write(arg, cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
}
|
||||
|
||||
unlock();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
PX4FMU::fmu_new_mode(PortMode new_mode)
|
||||
{
|
||||
@@ -2590,7 +2439,6 @@ PX4FMU::fmu_new_mode(PortMode new_mode)
|
||||
}
|
||||
|
||||
PX4FMU::Mode servo_mode;
|
||||
bool mode_with_input = false;
|
||||
|
||||
servo_mode = PX4FMU::MODE_NONE;
|
||||
|
||||
@@ -2645,7 +2493,6 @@ PX4FMU::fmu_new_mode(PortMode new_mode)
|
||||
case PORT_PWM5CAP1:
|
||||
/* select 5-pin PWM mode 1 capture */
|
||||
servo_mode = PX4FMU::MODE_5PWM1CAP;
|
||||
mode_with_input = true;
|
||||
break;
|
||||
# endif
|
||||
|
||||
@@ -2659,7 +2506,6 @@ PX4FMU::fmu_new_mode(PortMode new_mode)
|
||||
case PORT_PWM4CAP1:
|
||||
/* select 4-pin PWM mode 1 capture */
|
||||
servo_mode = PX4FMU::MODE_4PWM1CAP;
|
||||
mode_with_input = true;
|
||||
break;
|
||||
# endif
|
||||
|
||||
@@ -2673,7 +2519,6 @@ PX4FMU::fmu_new_mode(PortMode new_mode)
|
||||
case PORT_PWM3CAP1:
|
||||
/* select 3-pin PWM mode 1 capture */
|
||||
servo_mode = PX4FMU::MODE_3PWM1CAP;
|
||||
mode_with_input = true;
|
||||
break;
|
||||
# endif
|
||||
|
||||
@@ -2687,7 +2532,6 @@ PX4FMU::fmu_new_mode(PortMode new_mode)
|
||||
case PORT_PWM2CAP2:
|
||||
/* select 2-pin PWM mode 2 capture */
|
||||
servo_mode = PX4FMU::MODE_2PWM2CAP;
|
||||
mode_with_input = true;
|
||||
break;
|
||||
# endif
|
||||
#endif
|
||||
@@ -2699,12 +2543,6 @@ PX4FMU::fmu_new_mode(PortMode new_mode)
|
||||
PX4FMU *object = get_instance();
|
||||
|
||||
if (servo_mode != object->get_mode()) {
|
||||
|
||||
/* reset to all-inputs */
|
||||
if (mode_with_input) {
|
||||
object->ioctl(0, GPIO_RESET, 0);
|
||||
}
|
||||
|
||||
/* (re)set the PWM output mode */
|
||||
object->set_mode(servo_mode);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@
|
||||
#include <drivers/drv_rc_input.h>
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
#include <drivers/drv_sbus.h>
|
||||
#include <drivers/drv_gpio.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_mixer.h>
|
||||
|
||||
@@ -449,6 +448,8 @@ namespace
|
||||
PX4IO *g_dev = nullptr;
|
||||
}
|
||||
|
||||
#define PX4IO_DEVICE_PATH "/dev/px4io"
|
||||
|
||||
PX4IO::PX4IO(device::Device *interface) :
|
||||
CDev(PX4IO_DEVICE_PATH),
|
||||
_interface(interface),
|
||||
@@ -2749,19 +2750,6 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg)
|
||||
ret = (arg == PWM_SERVO_ENTER_TEST_MODE || PWM_SERVO_EXIT_TEST_MODE) ? 0 : -EINVAL;
|
||||
break;
|
||||
|
||||
case GPIO_RESET: {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
case GPIO_SET:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
|
||||
case GPIO_CLEAR:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
|
||||
case MIXERIOCGETOUTPUTCOUNT:
|
||||
*(unsigned *)arg = _max_actuators;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user