PX4 Firmware
PX4 Autopilot Software http://px4.io
safety.c File Reference

Safety button logic. More...

#include <px4_platform_common/px4_config.h>
#include <stdbool.h>
#include <drivers/drv_hrt.h>
#include "px4io.h"
Include dependency graph for safety.c:

Go to the source code of this file.

Macros

#define LED_PATTERN_FMU_OK_TO_ARM   0x0003
 slow blinking More...
 
#define LED_PATTERN_FMU_REFUSE_TO_ARM   0x5555
 fast blinking More...
 
#define LED_PATTERN_IO_ARMED   0x5050
 long off, then double blink More...
 
#define LED_PATTERN_FMU_ARMED   0x5500
 long off, then quad blink More...
 
#define LED_PATTERN_IO_FMU_ARMED   0xffff
 constantly on More...
 
#define ARM_COUNTER_THRESHOLD   10
 

Functions

static void safety_check_button (void *arg)
 
static void failsafe_blink (void *arg)
 
void safety_init (void)
 Safety switch/LED. More...
 
void failsafe_led_init (void)
 

Variables

static struct hrt_call arming_call
 
static struct hrt_call failsafe_call
 
static unsigned counter = 0
 
static unsigned blink_counter = 0
 
static bool safety_button_pressed
 

Detailed Description

Safety button logic.

Author
Lorenz Meier loren.nosp@m.z@px.nosp@m.4.io

Definition in file safety.c.

Macro Definition Documentation

◆ ARM_COUNTER_THRESHOLD

#define ARM_COUNTER_THRESHOLD   10

Definition at line 76 of file safety.c.

Referenced by safety_check_button().

◆ LED_PATTERN_FMU_ARMED

#define LED_PATTERN_FMU_ARMED   0x5500

long off, then quad blink

Definition at line 64 of file safety.c.

Referenced by safety_check_button().

◆ LED_PATTERN_FMU_OK_TO_ARM

#define LED_PATTERN_FMU_OK_TO_ARM   0x0003

slow blinking

Definition at line 61 of file safety.c.

Referenced by safety_check_button().

◆ LED_PATTERN_FMU_REFUSE_TO_ARM

#define LED_PATTERN_FMU_REFUSE_TO_ARM   0x5555

fast blinking

Definition at line 62 of file safety.c.

Referenced by safety_check_button().

◆ LED_PATTERN_IO_ARMED

#define LED_PATTERN_IO_ARMED   0x5050

long off, then double blink

Definition at line 63 of file safety.c.

Referenced by safety_check_button().

◆ LED_PATTERN_IO_FMU_ARMED

#define LED_PATTERN_IO_FMU_ARMED   0xffff

constantly on

Definition at line 65 of file safety.c.

Referenced by safety_check_button().

Function Documentation

◆ failsafe_blink()

static void failsafe_blink ( void *  arg)
static

Definition at line 169 of file safety.c.

References LED_AMBER, PX4IO_P_STATUS_FLAGS_FMU_OK, PX4IO_P_STATUS_FLAGS_INIT_OK, and r_status_flags.

Referenced by failsafe_led_init().

Here is the caller graph for this function:

◆ failsafe_led_init()

void failsafe_led_init ( void  )

Definition at line 91 of file safety.c.

References failsafe_blink(), failsafe_call, and hrt_call_every().

Referenced by user_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ safety_check_button()

static void safety_check_button ( void *  arg)
static

Definition at line 98 of file safety.c.

References ARM_COUNTER_THRESHOLD, atomic_modify_clear(), atomic_modify_or(), blink_counter, BUTTON_SAFETY, counter, LED_PATTERN_FMU_ARMED, LED_PATTERN_FMU_OK_TO_ARM, LED_PATTERN_FMU_REFUSE_TO_ARM, LED_PATTERN_IO_ARMED, LED_PATTERN_IO_FMU_ARMED, LED_SAFETY, PX4IO_P_SETUP_ARMING_FMU_ARMED, PX4IO_P_SETUP_ARMING_IO_ARM_OK, PX4IO_P_STATUS_FLAGS_SAFETY_OFF, r_setup_arming, r_status_flags, and safety_button_pressed.

Referenced by safety_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ safety_init()

void safety_init ( void  )

Safety switch/LED.

Definition at line 84 of file safety.c.

References arming_call, hrt_call_every(), and safety_check_button().

Referenced by user_start().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ arming_call

struct hrt_call arming_call
static

Definition at line 49 of file safety.c.

Referenced by safety_init().

◆ blink_counter

unsigned blink_counter = 0
static

Definition at line 67 of file safety.c.

Referenced by safety_check_button().

◆ counter

◆ failsafe_call

struct hrt_call failsafe_call
static

Definition at line 50 of file safety.c.

Referenced by failsafe_led_init().

◆ safety_button_pressed

bool safety_button_pressed
static

Definition at line 78 of file safety.c.

Referenced by SafetyButton::CheckButton(), and safety_check_button().