mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 13:53: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
+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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user