Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
56ea1a82
Commit
56ea1a82
authored
7 years ago
by
Beat Küng
Committed by
Roman Bapst
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
linux_pwm_out: add MC_AIRMODE support
parent
20c7387c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/drivers/linux_pwm_out/linux_pwm_out.cpp
+45
-6
45 additions, 6 deletions
src/drivers/linux_pwm_out/linux_pwm_out.cpp
with
45 additions
and
6 deletions
src/drivers/linux_pwm_out/linux_pwm_out.cpp
+
45
−
6
View file @
56ea1a82
...
...
@@ -44,6 +44,7 @@
#include
<uORB/topics/actuator_outputs.h>
#include
<uORB/topics/actuator_armed.h>
#include
<uORB/topics/rc_channels.h>
#include
<uORB/topics/parameter_update.h>
#include
<drivers/drv_hrt.h>
#include
<drivers/drv_mixer.h>
...
...
@@ -99,17 +100,19 @@ int32_t _pwm_max;
MixerGroup
*
_mixer_group
=
nullptr
;
void
usage
();
static
void
usage
();
void
start
();
static
void
start
();
void
stop
();
static
void
stop
();
void
task_main_trampoline
(
int
argc
,
char
*
argv
[]);
static
void
task_main_trampoline
(
int
argc
,
char
*
argv
[]);
void
subscribe
();
static
void
subscribe
();
void
task_main
(
int
argc
,
char
*
argv
[]);
static
void
task_main
(
int
argc
,
char
*
argv
[]);
static
void
update_params
(
bool
&
airmode
);
/* mixer initialization */
int
initialize_mixer
(
const
char
*
mixer_filename
);
...
...
@@ -128,6 +131,19 @@ int mixer_control_callback(uintptr_t handle,
}
void
update_params
(
bool
&
airmode
)
{
// multicopter air-mode
param_t
param_handle
=
param_find
(
"MC_AIRMODE"
);
if
(
param_handle
!=
PARAM_INVALID
)
{
int32_t
val
;
param_get
(
param_handle
,
&
val
);
airmode
=
val
>
0
;
}
}
int
initialize_mixer
(
const
char
*
mixer_filename
)
{
char
buf
[
4096
];
...
...
@@ -227,6 +243,10 @@ void task_main(int argc, char *argv[])
// subscribe and set up polling
subscribe
();
bool
airmode
=
false
;
update_params
(
airmode
);
int
params_sub
=
orb_subscribe
(
ORB_ID
(
parameter_update
));
int
rc_channels_sub
=
-
1
;
// Start disarmed
...
...
@@ -244,6 +264,10 @@ void task_main(int argc, char *argv[])
orb_copy
(
ORB_ID
(
actuator_armed
),
_armed_sub
,
&
_armed
);
}
if
(
_mixer_group
)
{
_mixer_group
->
set_airmode
(
airmode
);
}
int
pret
=
px4_poll
(
_poll_fds
,
_poll_fds_num
,
10
);
/* Timed out, do a periodic check for _task_should_exit. */
...
...
@@ -366,6 +390,17 @@ void task_main(int argc, char *argv[])
PX4_ERR
(
"Could not mix output! Exiting..."
);
_task_should_exit
=
true
;
}
/* check for parameter updates */
bool
param_updated
=
false
;
orb_check
(
params_sub
,
&
param_updated
);
if
(
param_updated
)
{
struct
parameter_update_s
update
;
orb_copy
(
ORB_ID
(
parameter_update
),
params_sub
,
&
update
);
update_params
(
airmode
);
}
}
delete
pwm_out
;
...
...
@@ -385,6 +420,10 @@ void task_main(int argc, char *argv[])
orb_unsubscribe
(
rc_channels_sub
);
}
if
(
params_sub
!=
-
1
)
{
orb_unsubscribe
(
params_sub
);
}
_is_running
=
false
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment