PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Implementation of the PX4IO register space. More...
#include <px4_platform_common/px4_config.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <drivers/drv_hrt.h>
#include <drivers/drv_pwm_output.h>
#include <stm32_pwr.h>
#include <rc/dsm.h>
#include <rc/sbus.h>
#include "px4io.h"
#include "protocol.h"
Go to the source code of this file.
Macros | |
#define | PX4IO_P_SETUP_FEATURES_VALID |
#define | PX4IO_P_SETUP_ARMING_VALID |
#define | PX4IO_P_SETUP_RATES_VALID ((1 << PX4IO_SERVO_COUNT) - 1) |
#define | PX4IO_P_SETUP_RELAYS_VALID ((1 << PX4IO_RELAY_CHANNELS) - 1) |
#define | PX4IO_P_RC_CONFIG_OPTIONS_VALID (PX4IO_P_RC_CONFIG_OPTIONS_REVERSE | PX4IO_P_RC_CONFIG_OPTIONS_ENABLED) |
#define | SELECT_PAGE(_page_name) |
Functions | |
static int | registers_set_one (uint8_t page, uint8_t offset, uint16_t value) |
static void | pwm_configure_rates (uint16_t map, uint16_t defaultrate, uint16_t altrate) |
int | registers_set (uint8_t page, uint8_t offset, const uint16_t *values, unsigned num_values) |
Register space. More... | |
int | registers_get (uint8_t page, uint8_t offset, uint16_t **values, unsigned *num_values) |
Implementation of the PX4IO register space.
Definition in file registers.c.
#define PX4IO_P_RC_CONFIG_OPTIONS_VALID (PX4IO_P_RC_CONFIG_OPTIONS_REVERSE | PX4IO_P_RC_CONFIG_OPTIONS_ENABLED) |
Definition at line 227 of file registers.c.
Referenced by registers_set_one().
#define PX4IO_P_SETUP_ARMING_VALID |
Definition at line 193 of file registers.c.
Referenced by registers_set_one().
#define PX4IO_P_SETUP_FEATURES_VALID |
Definition at line 188 of file registers.c.
Referenced by registers_set_one().
#define PX4IO_P_SETUP_RATES_VALID ((1 << PX4IO_SERVO_COUNT) - 1) |
Definition at line 205 of file registers.c.
Referenced by registers_set_one().
#define PX4IO_P_SETUP_RELAYS_VALID ((1 << PX4IO_RELAY_CHANNELS) - 1) |
Definition at line 206 of file registers.c.
#define SELECT_PAGE | ( | _page_name | ) |
Referenced by registers_get().
|
static |
Definition at line 1054 of file registers.c.
References OK, PX4IO_P_STATUS_ALARMS_PWM_ERROR, PX4IO_SERVO_COUNT, r_setup_pwm_altrate, r_setup_pwm_defaultrate, r_setup_pwm_rates, r_status_alarms, up_pwm_servo_get_rate_group(), and up_pwm_servo_set_rate_group_update().
Referenced by registers_set_one().
int registers_get | ( | uint8_t | page, |
uint8_t | offset, | ||
uint16_t ** | values, | ||
unsigned * | num_values | ||
) |
Definition at line 844 of file registers.c.
References adc_measure(), ADC_RSSI, ADC_VSERVO, last_offset, last_page, PX4IO_P_STATUS_VRSSI, PX4IO_P_STATUS_VSERVO, PX4IO_PAGE_ACTUATORS, PX4IO_PAGE_CONFIG, PX4IO_PAGE_CONTROL_MAX_PWM, PX4IO_PAGE_CONTROL_MIN_PWM, PX4IO_PAGE_CONTROL_TRIM_PWM, PX4IO_PAGE_CONTROLS, PX4IO_PAGE_DIRECT_PWM, PX4IO_PAGE_DISARMED_PWM, PX4IO_PAGE_FAILSAFE_PWM, PX4IO_PAGE_PWM_INFO, PX4IO_PAGE_RAW_ADC_INPUT, PX4IO_PAGE_RAW_RC_INPUT, PX4IO_PAGE_RC_CONFIG, PX4IO_PAGE_RC_INPUT, PX4IO_PAGE_SERVOS, PX4IO_PAGE_SETUP, PX4IO_PAGE_STATUS, PX4IO_RATE_MAP_BASE, PX4IO_SERVO_COUNT, r_page_actuators, r_page_config, r_page_controls, r_page_direct_pwm, r_page_raw_rc_input, r_page_rc_input, r_page_rc_input_config, r_page_scratch, r_page_servo_control_max, r_page_servo_control_min, r_page_servo_control_trim, r_page_servo_disarmed, r_page_servo_failsafe, r_page_servos, r_page_setup, r_page_status, SELECT_PAGE, and up_pwm_servo_get_rate_group().
Referenced by rx_handle_packet().
int registers_set | ( | uint8_t | page, |
uint8_t | offset, | ||
const uint16_t * | values, | ||
unsigned | num_values | ||
) |
Register space.
Definition at line 275 of file registers.c.
References sys_state_s::fmu_data_received_time, hrt_absolute_time(), mixer_handle_text(), PWM_HIGHEST_MAX, PWM_HIGHEST_MIN, PWM_IGNORE_THIS_CHANNEL, PWM_LOWEST_MAX, PWM_LOWEST_MIN, PX4IO_CONTROL_CHANNELS, PX4IO_CONTROL_GROUPS, PX4IO_P_SETUP_ARMING_ALWAYS_PWM_ENABLE, PX4IO_P_SETUP_ARMING_FAILSAFE_CUSTOM, PX4IO_P_STATUS_FLAGS_RAW_PWM, PX4IO_PAGE_CONTROL_MAX_PWM, PX4IO_PAGE_CONTROL_MIN_PWM, PX4IO_PAGE_CONTROL_TRIM_PWM, PX4IO_PAGE_CONTROLS, PX4IO_PAGE_DIRECT_PWM, PX4IO_PAGE_DISARMED_PWM, PX4IO_PAGE_FAILSAFE_PWM, PX4IO_PAGE_MIXERLOAD, PX4IO_SERVO_COUNT, r_page_controls, r_page_direct_pwm, r_page_servo_control_max, r_page_servo_control_min, r_page_servo_control_trim, r_page_servo_disarmed, r_page_servo_failsafe, r_setup_arming, r_status_flags, registers_set_one(), system_state, up_pwm_update(), and update_trims.
Referenced by rx_handle_packet().
|
static |
do not allow a RC config change while safety is off
Definition at line 490 of file registers.c.
References ENABLE_SBUS_OUT, isr_debug(), LED_AMBER, mixer_set_failsafe(), pwm_configure_rates(), PX4IO_FORCE_SAFETY_MAGIC, PX4IO_P_RC_CONFIG_ASSIGNMENT, PX4IO_P_RC_CONFIG_ASSIGNMENT_MODESWITCH, PX4IO_P_RC_CONFIG_CENTER, PX4IO_P_RC_CONFIG_DEADZONE, PX4IO_P_RC_CONFIG_MAX, PX4IO_P_RC_CONFIG_MIN, PX4IO_P_RC_CONFIG_OPTIONS, PX4IO_P_RC_CONFIG_OPTIONS_ENABLED, PX4IO_P_RC_CONFIG_OPTIONS_VALID, PX4IO_P_RC_CONFIG_STRIDE, PX4IO_P_SETUP_AIRMODE, PX4IO_P_SETUP_ARMING, PX4IO_P_SETUP_ARMING_FORCE_FAILSAFE, PX4IO_P_SETUP_ARMING_RC_HANDLING_DISABLED, PX4IO_P_SETUP_ARMING_TERMINATION_FAILSAFE, PX4IO_P_SETUP_ARMING_VALID, PX4IO_P_SETUP_DSM, PX4IO_P_SETUP_ENABLE_FLIGHTTERMINATION, PX4IO_P_SETUP_FEATURES, PX4IO_P_SETUP_FEATURES_ADC_RSSI, PX4IO_P_SETUP_FEATURES_PWM_RSSI, PX4IO_P_SETUP_FEATURES_SBUS1_OUT, PX4IO_P_SETUP_FEATURES_SBUS2_OUT, PX4IO_P_SETUP_FEATURES_VALID, PX4IO_P_SETUP_FORCE_SAFETY_OFF, PX4IO_P_SETUP_FORCE_SAFETY_ON, PX4IO_P_SETUP_MOTOR_SLEW_MAX, PX4IO_P_SETUP_PWM_ALTRATE, PX4IO_P_SETUP_PWM_DEFAULTRATE, PX4IO_P_SETUP_PWM_RATES, PX4IO_P_SETUP_PWM_REVERSE, PX4IO_P_SETUP_RATES_VALID, PX4IO_P_SETUP_RC_THR_FAILSAFE_US, PX4IO_P_SETUP_REBOOT_BL, PX4IO_P_SETUP_SBUS_RATE, PX4IO_P_SETUP_SCALE_PITCH, PX4IO_P_SETUP_SCALE_ROLL, PX4IO_P_SETUP_SCALE_YAW, PX4IO_P_SETUP_SET_DEBUG, PX4IO_P_SETUP_THERMAL, PX4IO_P_SETUP_THR_MDL_FAC, PX4IO_P_SETUP_TRIM_PITCH, PX4IO_P_SETUP_TRIM_ROLL, PX4IO_P_SETUP_TRIM_YAW, PX4IO_P_STATUS_ALARMS, PX4IO_P_STATUS_FLAGS, PX4IO_P_STATUS_FLAGS_ARM_SYNC, PX4IO_P_STATUS_FLAGS_INIT_OK, PX4IO_P_STATUS_FLAGS_MIXER_OK, PX4IO_P_STATUS_FLAGS_SAFETY_OFF, PX4IO_P_TEST_LED, PX4IO_PAGE_RC_CONFIG, PX4IO_PAGE_SETUP, PX4IO_PAGE_STATUS, PX4IO_PAGE_TEST, PX4IO_RC_INPUT_CHANNELS, PX4IO_RC_MAPPED_CONTROL_CHANNELS, PX4IO_REBOOT_BL_MAGIC, r_page_rc_input_config, r_page_setup, r_setup_arming, r_setup_features, r_setup_pwm_altrate, r_setup_pwm_defaultrate, r_setup_pwm_rates, r_status_alarms, r_status_flags, sbus1_set_output_rate_hz(), schedule_reboot(), and update_mc_thrust_param.
Referenced by registers_set().
uint8_t last_offset |
Definition at line 841 of file registers.c.
Referenced by registers_get().
uint8_t last_page |
Definition at line 840 of file registers.c.
Referenced by registers_get().
uint16_t r_page_actuators[PX4IO_SERVO_COUNT] |
PAGE 2.
Post-mixed actuator values.
Definition at line 101 of file registers.c.
Referenced by mixer_tick(), and registers_get().
|
static |
PAGE 0.
Static configuration parameters.
Definition at line 68 of file registers.c.
Referenced by registers_get().
uint16_t r_page_controls[PX4IO_CONTROL_GROUPS *PX4IO_CONTROL_CHANNELS] |
PAGE 101.
Control values from the FMU.
Definition at line 213 of file registers.c.
Referenced by mixer_callback(), registers_get(), and registers_set().
uint16_t r_page_direct_pwm[PX4IO_SERVO_COUNT] |
PAGE 8.
RAW PWM values
Definition at line 148 of file registers.c.
Referenced by mixer_tick(), registers_get(), and registers_set().
uint16_t r_page_raw_rc_input[] |
PAGE 4.
Raw RC input
Definition at line 115 of file registers.c.
Referenced by controls_tick(), and registers_get().
uint16_t r_page_rc_input[] |
PAGE 5.
Scaled/routed RC input
Definition at line 130 of file registers.c.
Referenced by mixer_callback(), and registers_get().
uint16_t r_page_rc_input_config[PX4IO_RC_INPUT_CHANNELS *PX4IO_P_RC_CONFIG_STRIDE] |
PAGE 103.
R/C channel input configuration.
Definition at line 224 of file registers.c.
Referenced by controls_init(), controls_tick(), registers_get(), and registers_set_one().
uint16_t r_page_scratch[32] |
Scratch page; used for registers that are constructed as-read.
PAGE 6 Raw ADC input. PAGE 7 PWM rate maps.
Definition at line 141 of file registers.c.
Referenced by registers_get().
uint16_t r_page_servo_control_max[PX4IO_SERVO_COUNT] = { PWM_DEFAULT_MAX, PWM_DEFAULT_MAX, PWM_DEFAULT_MAX, PWM_DEFAULT_MAX, PWM_DEFAULT_MAX, PWM_DEFAULT_MAX, PWM_DEFAULT_MAX, PWM_DEFAULT_MAX } |
PAGE 107.
maximum PWM values when armed
Definition at line 256 of file registers.c.
Referenced by mixer_set_failsafe(), mixer_tick(), MixerTest::mixerTest(), registers_get(), and registers_set().
uint16_t r_page_servo_control_min[PX4IO_SERVO_COUNT] = { PWM_DEFAULT_MIN, PWM_DEFAULT_MIN, PWM_DEFAULT_MIN, PWM_DEFAULT_MIN, PWM_DEFAULT_MIN, PWM_DEFAULT_MIN, PWM_DEFAULT_MIN, PWM_DEFAULT_MIN } |
PAGE 106.
minimum PWM values when armed
Definition at line 248 of file registers.c.
Referenced by mixer_set_failsafe(), mixer_tick(), MixerTest::mixerTest(), registers_get(), and registers_set().
int16_t r_page_servo_control_trim[PX4IO_SERVO_COUNT] = { PWM_DEFAULT_TRIM, PWM_DEFAULT_TRIM, PWM_DEFAULT_TRIM, PWM_DEFAULT_TRIM, PWM_DEFAULT_TRIM, PWM_DEFAULT_TRIM, PWM_DEFAULT_TRIM, PWM_DEFAULT_TRIM } |
PAGE 108.
trim values for center position
Definition at line 264 of file registers.c.
Referenced by mixer_tick(), registers_get(), and registers_set().
uint16_t r_page_servo_disarmed[PX4IO_SERVO_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0 } |
PAGE 109.
disarmed PWM values for difficult ESCs
Definition at line 272 of file registers.c.
Referenced by mixer_tick(), MixerTest::mixerTest(), registers_get(), and registers_set().
uint16_t r_page_servo_failsafe[PX4IO_SERVO_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0 } |
PAGE 105.
Failsafe servo PWM values
Disable pulses as default.
Definition at line 240 of file registers.c.
Referenced by mixer_set_failsafe(), mixer_tick(), registers_get(), and registers_set().
uint16_t r_page_servos[PX4IO_SERVO_COUNT] |
PAGE 3.
Servo PWM values
Definition at line 108 of file registers.c.
Referenced by mixer_tick(), MixerTest::mixerTest(), and registers_get().
volatile uint16_t r_page_setup[] |
PAGE 100.
Setup registers
Definition at line 155 of file registers.c.
Referenced by calculate_fw_crc(), isr_debug(), registers_get(), registers_set_one(), and user_start().
volatile uint16_t r_page_status[] |
PAGE 1.
Status values.
Definition at line 85 of file registers.c.
Referenced by registers_get(), update_mem_usage(), and user_start().
bool update_mc_thrust_param |
Definition at line 60 of file registers.c.
Referenced by mixer_handle_text(), mixer_set_failsafe(), mixer_tick(), and registers_set_one().
bool update_trims |
Definition at line 61 of file registers.c.
Referenced by mixer_handle_text(), mixer_tick(), and registers_set().