42 #include <px4_platform_common/px4_config.h> 45 #include <sys/types.h> 70 #define FMU_INPUT_DROP_LIMIT_US 500000 96 static int mixer_callback(uintptr_t handle, uint8_t control_group, uint8_t control_index,
float &
control);
123 irqstate_t irq_flags = enter_critical_section();
125 leave_critical_section(irq_flags);
127 if ((fmu_data_received_time == 0) ||
405 uint8_t control_group,
406 uint8_t control_index,
462 if (control_group == actuator_controls_s::GROUP_INDEX_ATTITUDE &&
463 control_index == actuator_controls_s::INDEX_ROLL) {
467 }
else if (control_group == actuator_controls_s::GROUP_INDEX_ATTITUDE &&
468 control_index == actuator_controls_s::INDEX_PITCH) {
472 }
else if (control_group == actuator_controls_s::GROUP_INDEX_ATTITUDE &&
473 control_index == actuator_controls_s::INDEX_YAW) {
480 if (control > 1.0
f) {
483 }
else if (control < -1.0
f) {
489 if ((control_group == actuator_controls_s::GROUP_INDEX_ATTITUDE ||
490 control_group == actuator_controls_s::GROUP_INDEX_ATTITUDE_ALTERNATE) &&
491 control_index == actuator_controls_s::INDEX_THROTTLE) {
501 if ((control_group == actuator_controls_s::GROUP_INDEX_ATTITUDE ||
502 control_group == actuator_controls_s::GROUP_INDEX_ATTITUDE_ALTERNATE) &&
503 control_index == actuator_controls_s::INDEX_THROTTLE) {
621 mixer_text_length += text_length;
623 isr_debug(2,
"buflen %u", mixer_text_length);
670 for (
unsigned i = 0; i < mixed; i++) {
int load_from_buf(Mixer::ControlCallback control_cb, uintptr_t cb_handle, const char *buf, unsigned &buflen)
Adds mixers to the group based on a text description in a buffer.
#define PX4IO_P_SETUP_ARMING_ALWAYS_PWM_ENABLE
#define PX4IO_P_STATUS_FLAGS_FMU_OK
#define FLOAT_TO_REG(_float)
static unsigned mixer_text_length
void reset()
Remove all the mixers from the group.
void output_limit_calc(const bool armed, const bool pre_armed, const unsigned num_channels, const uint16_t reverse_mask, const uint16_t *disarmed_output, const uint16_t *min_output, const uint16_t *max_output, const float *output, uint16_t *effective_output, output_limit_t *limit)
uint16_t get_saturation_status()
#define F2I_MIXER_ACTION_APPEND
#define r_setup_pwm_reverse
static volatile bool mixer_servos_armed
static MixerGroup mixer_group
int mixer_handle_text(const void *buffer, size_t length)
static char mixer_text[PX4IO_MAX_MIXER_LENGTH]
static int mixer_mix_threadsafe(float *outputs, volatile uint16_t *limits)
void isr_debug(uint8_t level, const char *fmt,...)
send a debug message to the console
#define r_setup_scale_yaw
static volatile bool should_arm
static volatile bool should_arm_nothrottle
static volatile mixer_source source
High-resolution timer with callouts and timekeeping.
void atomic_modify_clear(volatile uint16_t *target, uint16_t modification)
unsigned set_trims(int16_t *v, unsigned n)
As-needed mixer data upload.
static char msg[NUM_MSG][CONFIG_USART1_TXBUFSIZE]
void set_max_delta_out_once(float delta_out_max)
Update slew rate parameter.
#define PX4IO_P_SETUP_ARMING_FAILSAFE_CUSTOM
#define REG_TO_FLOAT(_reg)
#define PX4IO_P_STATUS_ALARMS_FMU_LOST
uint16_t r_page_servo_control_max[]
PAGE 107.
enum output_limit_state state
static int mixer_callback(uintptr_t handle, uint8_t control_group, uint8_t control_index, float &control)
#define PX4IO_P_STATUS_FLAGS_FMU_INITIALIZED
#define F2I_MIXER_ACTION_RESET
static bool mixer_update_pending
#define r_setup_flighttermination
void set_thrust_factor(float val)
Sets the thrust factor used to calculate mapping from desired thrust to motor control signal output...
void atomic_modify_or(volatile uint16_t *target, uint16_t modification)
#define PX4IO_P_STATUS_FLAGS_MIXER_OK
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
static hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
Compute the delta between a timestamp taken in the past and now.
__EXPORT int up_pwm_servo_set(unsigned channel, servo_position_t value)
Set the current output value for a channel.
uint16_t r_page_controls[]
PAGE 101.
#define PX4IO_CONTROL_CHANNELS
uint16_t r_page_servo_disarmed[]
PAGE 109.
#define r_setup_trim_pitch
#define PX4IO_P_STATUS_FLAGS_OVERRIDE
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
#define PX4IO_P_STATUS_FLAGS_SAFETY_OFF
#define PX4IO_MAX_MIXER_LENGTH
#define r_setup_scale_roll
int mixer_handle_text_create_mixer()
void mixer_set_failsafe()
#define CONTROL_PAGE_INDEX(_group, _channel)
General defines and structures for the PX4IO module firmware.
struct sys_state_s system_state
uint16_t r_page_servo_control_min[]
PAGE 106.
bool update_mc_thrust_param
#define PX4IO_SERVO_COUNT
#define PX4IO_P_STATUS_FLAGS_RAW_PWM
static uint64_t last_fmu_update
void set_airmode(Mixer::Airmode airmode)
void sbus2_output(int sbus_fd, uint16_t *values, uint16_t num_values)
#define PX4IO_P_SETUP_ARMING_FMU_ARMED
#define PX4IO_P_STATUS_FLAGS_INIT_OK
#define PX4IO_P_SETUP_ARMING_FORCE_FAILSAFE
uint16_t r_page_servos[]
PAGE 3.
uint16_t r_page_actuators[]
PAGE 2.
RC protocol definition for S.BUS.
uint16_t r_page_rc_input[]
PAGE 5.
int16_t r_page_servo_control_trim[]
PAGE 108.
#define r_setup_trim_roll
void sbus1_output(int sbus_fd, uint16_t *values, uint16_t num_values)
#define PX4IO_P_STATUS_FLAGS_FAILSAFE
unsigned mix(float *outputs, unsigned space)
__EXPORT void up_pwm_servo_arm(bool armed)
Arm or disarm servo outputs.
#define PX4IO_P_SETUP_ARMING_FMU_PREARMED
uint16_t r_page_direct_pwm[]
PAGE 8.
#define PX4IO_P_STATUS_FLAGS_OUTPUTS_ARMED
#define REG_TO_SIGNED(_reg)
#define PX4IO_P_SETUP_ARMING_LOCKDOWN
Group of mixers, built up from single mixers and processed in order when mixing.
#define PX4IO_P_SETUP_FEATURES_SBUS2_OUT
enable S.Bus v2 output
uint16_t r_page_servo_failsafe[]
PAGE 105.
Library for output limiting (PWM for example)
static volatile bool should_always_enable_pwm
#define PX4IO_CONTROL_GROUPS
__EXPORT void up_pwm_update(void)
Trigger all timer's channels in Oneshot mode to fire the oneshot with updated values.
#define PX4IO_P_SETUP_FEATURES_SBUS1_OUT
enable S.Bus v1 output
volatile uint64_t fmu_data_received_time
Last FMU receive time, in microseconds since system boot.
#define REG_TO_BOOL(_reg)
static volatile bool in_mixer
#define r_setup_scale_pitch
#define FMU_INPUT_DROP_LIMIT_US