diff options
author | Andrew Tridgell <tridge@samba.org> | 2013-02-18 14:16:09 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2013-02-18 14:16:09 +1100 |
commit | 317515fb6a3d6e469681b53316d69c7669efdaf0 (patch) | |
tree | 8b7a08491c482c0d335e60b2c76a99ef68d4a60a /apps | |
parent | 1670b8afe13ba6c845800228d1c8829aa1bf31c9 (diff) | |
download | px4-firmware-317515fb6a3d6e469681b53316d69c7669efdaf0.tar.gz px4-firmware-317515fb6a3d6e469681b53316d69c7669efdaf0.tar.bz2 px4-firmware-317515fb6a3d6e469681b53316d69c7669efdaf0.zip |
px4io: added INAIR_RESTART enable/disable flags
the autopilot code needs to know that in-air restart may happen, so it
should be something that is enabled, rather than on by default.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/drivers/drv_pwm_output.h | 6 | ||||
-rw-r--r-- | apps/drivers/px4io/px4io.cpp | 18 | ||||
-rw-r--r-- | apps/px4io/protocol.h | 1 | ||||
-rw-r--r-- | apps/px4io/registers.c | 3 |
4 files changed, 26 insertions, 2 deletions
diff --git a/apps/drivers/drv_pwm_output.h b/apps/drivers/drv_pwm_output.h index 64bb540b4..f3f753ebe 100644 --- a/apps/drivers/drv_pwm_output.h +++ b/apps/drivers/drv_pwm_output.h @@ -109,6 +109,12 @@ ORB_DECLARE(output_pwm); /** set debug level for servo IO */ #define PWM_SERVO_SET_DEBUG _IOC(_PWM_SERVO_BASE, 4) +/** enable in-air restart */ +#define PWM_SERVO_INAIR_RESTART_ENABLE _IOC(_PWM_SERVO_BASE, 5) + +/** disable in-air restart */ +#define PWM_SERVO_INAIR_RESTART_DISABLE _IOC(_PWM_SERVO_BASE, 6) + /** set a single servo to a specific value */ #define PWM_SERVO_SET(_servo) _IOC(_PWM_SERVO_BASE, 0x20 + _servo) diff --git a/apps/drivers/px4io/px4io.cpp b/apps/drivers/px4io/px4io.cpp index b2e0c6ee4..adb894371 100644 --- a/apps/drivers/px4io/px4io.cpp +++ b/apps/drivers/px4io/px4io.cpp @@ -367,7 +367,12 @@ PX4IO::init() if (ret != OK) return ret; - if (reg & PX4IO_P_SETUP_ARMING_ARM_OK) { + /* + * in-air restart is only tried if the IO board reports it is + * already armed, and has been configured for in-air restart + */ + if ((reg & PX4IO_P_SETUP_ARMING_INAIR_RESTART_OK) && + (reg & PX4IO_P_SETUP_ARMING_ARM_OK)) { /* WARNING: COMMANDER app/vehicle status must be initialized. * If this fails (or the app is not started), worst-case IO @@ -450,6 +455,7 @@ PX4IO::init() /* dis-arm IO before touching anything */ io_reg_modify(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_ARMING, PX4IO_P_SETUP_ARMING_ARM_OK | + PX4IO_P_SETUP_ARMING_INAIR_RESTART_OK | PX4IO_P_SETUP_ARMING_MANUAL_OVERRIDE_OK | PX4IO_P_SETUP_ARMING_VECTOR_FLIGHT_OK, 0); @@ -1164,6 +1170,16 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg) ret = io_reg_modify(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_ARMING, PX4IO_P_SETUP_ARMING_ARM_OK, 0); break; + case PWM_SERVO_INAIR_RESTART_ENABLE: + /* set the 'in-air restart' bit */ + ret = io_reg_modify(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_ARMING, 0, PX4IO_P_SETUP_ARMING_INAIR_RESTART_OK); + break; + + case PWM_SERVO_INAIR_RESTART_DISABLE: + /* unset the 'in-air restart' bit */ + ret = io_reg_modify(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_ARMING, PX4IO_P_SETUP_ARMING_INAIR_RESTART_OK, 0); + break; + case PWM_SERVO_SET_UPDATE_RATE: /* set the requested rate */ if ((arg >= 50) && (arg <= 400)) { diff --git a/apps/px4io/protocol.h b/apps/px4io/protocol.h index a957a9e79..0ee6d2c4b 100644 --- a/apps/px4io/protocol.h +++ b/apps/px4io/protocol.h @@ -142,6 +142,7 @@ #define PX4IO_P_SETUP_ARMING_ARM_OK (1 << 0) /* OK to arm */ #define PX4IO_P_SETUP_ARMING_MANUAL_OVERRIDE_OK (1 << 2) /* OK to switch to manual override via override RC channel */ #define PX4IO_P_SETUP_ARMING_VECTOR_FLIGHT_OK (1 << 3) /* OK to perform position / vector control (= position lock) */ +#define PX4IO_P_SETUP_ARMING_INAIR_RESTART_OK (1 << 4) /* OK to try in-air restart */ #define PX4IO_P_SETUP_PWM_RATES 2 /* bitmask, 0 = low rate, 1 = high rate */ #define PX4IO_P_SETUP_PWM_LOWRATE 3 /* 'low' PWM frame output rate in Hz */ diff --git a/apps/px4io/registers.c b/apps/px4io/registers.c index 23ad4aa88..ec1980aaa 100644 --- a/apps/px4io/registers.c +++ b/apps/px4io/registers.c @@ -142,7 +142,8 @@ volatile uint16_t r_page_setup[] = #define PX4IO_P_SETUP_FEATURES_VALID (0) #define PX4IO_P_SETUP_ARMING_VALID (PX4IO_P_SETUP_ARMING_ARM_OK | \ - PX4IO_P_SETUP_ARMING_MANUAL_OVERRIDE_OK) + PX4IO_P_SETUP_ARMING_MANUAL_OVERRIDE_OK | \ + PX4IO_P_SETUP_ARMING_INAIR_RESTART_OK) #define PX4IO_P_SETUP_RATES_VALID ((1 << IO_SERVO_COUNT) - 1) #define PX4IO_P_SETUP_RELAYS_VALID ((1 << PX4IO_RELAY_CHANNELS) - 1) |