Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit 4cc6120

Browse files
committed
drivers: allow forcing the safety switch on
This allows forcing the safety switch to the on position from software which stops the pwm outputs
1 parent 23a11fc commit 4cc6120

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

src/drivers/drv_pwm_output.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ ORB_DECLARE(output_pwm);
202202
/** force safety switch off (to disable use of safety switch) */
203203
#define PWM_SERVO_SET_FORCE_SAFETY_OFF _IOC(_PWM_SERVO_BASE, 23)
204204

205+
/** force safety switch on (to enable use of safety switch) */
206+
#define PWM_SERVO_SET_FORCE_SAFETY_ON _IOC(_PWM_SERVO_BASE, 24)
207+
205208
/*
206209
*
207210
*

src/drivers/px4fmu/fmu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg)
737737
case PWM_SERVO_SET_ARM_OK:
738738
case PWM_SERVO_CLEAR_ARM_OK:
739739
case PWM_SERVO_SET_FORCE_SAFETY_OFF:
740+
case PWM_SERVO_SET_FORCE_SAFETY_ON:
740741
// these are no-ops, as no safety switch
741742
break;
742743

src/drivers/px4io/px4io.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,6 +2128,11 @@ PX4IO::ioctl(file * filep, int cmd, unsigned long arg)
21282128
ret = io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_FORCE_SAFETY_OFF, PX4IO_FORCE_SAFETY_MAGIC);
21292129
break;
21302130

2131+
case PWM_SERVO_SET_FORCE_SAFETY_ON:
2132+
/* force safety switch on */
2133+
ret = io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_FORCE_SAFETY_ON, PX4IO_FORCE_SAFETY_MAGIC);
2134+
break;
2135+
21312136
case DSM_BIND_START:
21322137

21332138
/* only allow DSM2, DSM-X and DSM-X with more than 7 channels */

src/modules/px4iofirmware/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ enum { /* DSM bind states */
211211

212212
#define PX4IO_P_SETUP_FORCE_SAFETY_OFF 12 /* force safety switch into
213213
'armed' (PWM enabled) state */
214+
#define PX4IO_P_SETUP_FORCE_SAFETY_ON 13 /* force safety switch into 'disarmed' (PWM disabled state) */
214215
#define PX4IO_FORCE_SAFETY_MAGIC 22027 /* required argument for force safety (random) */
215216

216217
/* autopilot control values, -10000..10000 */

src/modules/px4iofirmware/registers.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,12 @@ registers_set_one(uint8_t page, uint8_t offset, uint16_t value)
569569
dsm_bind(value & 0x0f, (value >> 4) & 0xF);
570570
break;
571571

572+
case PX4IO_P_SETUP_FORCE_SAFETY_ON:
573+
if (value == PX4IO_FORCE_SAFETY_MAGIC) {
574+
r_status_flags &= ~PX4IO_P_STATUS_FLAGS_SAFETY_OFF;
575+
}
576+
break;
577+
572578
case PX4IO_P_SETUP_FORCE_SAFETY_OFF:
573579
if (value == PX4IO_FORCE_SAFETY_MAGIC) {
574580
r_status_flags |= PX4IO_P_STATUS_FLAGS_SAFETY_OFF;

0 commit comments

Comments
 (0)