forked from Archive/PX4-Autopilot
FMU driver: auto param update
This commit is contained in:
parent
129aa35fcd
commit
2dd94b7f0f
|
@ -171,9 +171,10 @@ private:
|
||||||
uint8_t control_group,
|
uint8_t control_group,
|
||||||
uint8_t control_index,
|
uint8_t control_index,
|
||||||
float &input);
|
float &input);
|
||||||
void subscribe();
|
void subscribe();
|
||||||
int set_pwm_rate(unsigned rate_map, unsigned default_rate, unsigned alt_rate);
|
int set_pwm_rate(unsigned rate_map, unsigned default_rate, unsigned alt_rate);
|
||||||
int pwm_ioctl(file *filp, int cmd, unsigned long arg);
|
int pwm_ioctl(file *filp, int cmd, unsigned long arg);
|
||||||
|
void update_pwm_rev_mask();
|
||||||
|
|
||||||
struct GPIOConfig {
|
struct GPIOConfig {
|
||||||
uint32_t input;
|
uint32_t input;
|
||||||
|
@ -549,6 +550,26 @@ PX4FMU::subscribe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PX4FMU::update_pwm_rev_mask()
|
||||||
|
{
|
||||||
|
_reverse_pwm_mask = 0;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < _max_actuators; i++) {
|
||||||
|
char pname[16];
|
||||||
|
int32_t ival;
|
||||||
|
|
||||||
|
/* fill the channel reverse mask from parameters */
|
||||||
|
sprintf(pname, "PWM_AUX_REV%d", i + 1);
|
||||||
|
param_t param_h = param_find(pname);
|
||||||
|
|
||||||
|
if (param_h != PARAM_INVALID) {
|
||||||
|
param_get(param_h, &ival);
|
||||||
|
_reverse_pwm_mask |= ((int16_t)(ival != 0)) << i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PX4FMU::task_main()
|
PX4FMU::task_main()
|
||||||
{
|
{
|
||||||
|
@ -574,7 +595,7 @@ PX4FMU::task_main()
|
||||||
/* initialize PWM limit lib */
|
/* initialize PWM limit lib */
|
||||||
pwm_limit_init(&_pwm_limit);
|
pwm_limit_init(&_pwm_limit);
|
||||||
|
|
||||||
log("starting");
|
update_pwm_rev_mask();
|
||||||
|
|
||||||
/* loop until killed */
|
/* loop until killed */
|
||||||
while (!_task_should_exit) {
|
while (!_task_should_exit) {
|
||||||
|
@ -731,25 +752,11 @@ PX4FMU::task_main()
|
||||||
}
|
}
|
||||||
|
|
||||||
orb_check(_param_sub, &updated);
|
orb_check(_param_sub, &updated);
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
parameter_update_s pupdate;
|
parameter_update_s pupdate;
|
||||||
orb_copy(ORB_ID(parameter_update), _param_sub, &pupdate);
|
orb_copy(ORB_ID(parameter_update), _param_sub, &pupdate);
|
||||||
_reverse_pwm_mask = 0;
|
|
||||||
|
update_pwm_rev_mask();
|
||||||
for (unsigned i = 0; i < _max_actuators; i++) {
|
|
||||||
char pname[16];
|
|
||||||
int32_t ival;
|
|
||||||
|
|
||||||
/* fill the channel reverse mask from parameters */
|
|
||||||
sprintf(pname, "PWM_AUX_REV%d", i + 1);
|
|
||||||
param_t param_h = param_find(pname);
|
|
||||||
|
|
||||||
if (param_h != PARAM_INVALID) {
|
|
||||||
param_get(param_h, &ival);
|
|
||||||
_reverse_pwm_mask |= ((int16_t)(ival != 0)) << i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HRT_PPM_CHANNEL
|
#ifdef HRT_PPM_CHANNEL
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
* @max 1
|
* @max 1
|
||||||
* @group PWM Outputs
|
* @group PWM Outputs
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(PWM_AUX_REV1, 1);
|
PARAM_DEFINE_INT32(PWM_AUX_REV1, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverter for main output channel 2
|
* Inverter for main output channel 2
|
||||||
|
@ -62,7 +62,7 @@ PARAM_DEFINE_INT32(PWM_AUX_REV1, 1);
|
||||||
* @max 1
|
* @max 1
|
||||||
* @group PWM Outputs
|
* @group PWM Outputs
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(PWM_AUX_REV2, 1);
|
PARAM_DEFINE_INT32(PWM_AUX_REV2, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverter for main output channel 3
|
* Inverter for main output channel 3
|
||||||
|
@ -73,7 +73,7 @@ PARAM_DEFINE_INT32(PWM_AUX_REV2, 1);
|
||||||
* @max 1
|
* @max 1
|
||||||
* @group PWM Outputs
|
* @group PWM Outputs
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(PWM_AUX_REV3, 1);
|
PARAM_DEFINE_INT32(PWM_AUX_REV3, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverter for main output channel 4
|
* Inverter for main output channel 4
|
||||||
|
@ -84,7 +84,7 @@ PARAM_DEFINE_INT32(PWM_AUX_REV3, 1);
|
||||||
* @max 1
|
* @max 1
|
||||||
* @group PWM Outputs
|
* @group PWM Outputs
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(PWM_AUX_REV4, 1);
|
PARAM_DEFINE_INT32(PWM_AUX_REV4, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverter for main output channel 5
|
* Inverter for main output channel 5
|
||||||
|
@ -95,7 +95,7 @@ PARAM_DEFINE_INT32(PWM_AUX_REV4, 1);
|
||||||
* @max 1
|
* @max 1
|
||||||
* @group PWM Outputs
|
* @group PWM Outputs
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(PWM_AUX_REV5, 1);
|
PARAM_DEFINE_INT32(PWM_AUX_REV5, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverter for main output channel 6
|
* Inverter for main output channel 6
|
||||||
|
@ -106,4 +106,4 @@ PARAM_DEFINE_INT32(PWM_AUX_REV5, 1);
|
||||||
* @max 1
|
* @max 1
|
||||||
* @group PWM Outputs
|
* @group PWM Outputs
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(PWM_AUX_REV6, 1);
|
PARAM_DEFINE_INT32(PWM_AUX_REV6, 0);
|
||||||
|
|
Loading…
Reference in New Issue