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
fa35731e
Commit
fa35731e
authored
6 years ago
by
DanielePettenuzzo
Committed by
Beat Küng
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ms4525_airspeed: add -a flag to scan all i2c busses during start
parent
7a82c777
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/differential_pressure/ms4525/ms4525_airspeed.cpp
+40
-1
40 additions, 1 deletion
src/drivers/differential_pressure/ms4525/ms4525_airspeed.cpp
with
40 additions
and
1 deletion
src/drivers/differential_pressure/ms4525/ms4525_airspeed.cpp
+
40
−
1
View file @
fa35731e
...
...
@@ -81,6 +81,8 @@
#define MEAS_DRIVER_FILTER_FREQ 1.2f
#define CONVERSION_INTERVAL (1000000 / MEAS_RATE)
/* microseconds */
#define PX4_I2C_ALL 0xFF
class
MEASAirspeed
:
public
Airspeed
{
public:
...
...
@@ -373,7 +375,22 @@ namespace meas_airspeed
MEASAirspeed
*
g_dev
=
nullptr
;
int
bus_options
[]
=
{
#ifdef PX4_I2C_BUS_EXPANSION
PX4_I2C_BUS_EXPANSION
,
#endif
#ifdef PX4_I2C_BUS_EXPANSION1
PX4_I2C_BUS_EXPANSION1
,
#endif
#ifdef PX4_I2C_BUS_EXPANSION2
PX4_I2C_BUS_EXPANSION2
,
#endif
};
#define NUM_BUS_OPTIONS (sizeof(bus_options)/sizeof(bus_options[0]))
int
start
(
int
i2c_bus
);
bool
start_bus
(
int
i2c_bus
);
int
stop
();
int
reset
();
...
...
@@ -385,6 +402,23 @@ int reset();
*/
int
start
(
int
i2c_bus
)
{
if
(
i2c_bus
==
PX4_I2C_ALL
)
{
for
(
unsigned
i
=
0
;
i
<
NUM_BUS_OPTIONS
;
i
++
)
{
if
(
start_bus
(
bus_options
[
i
])
==
PX4_OK
)
{
return
PX4_OK
;
}
}
return
PX4_ERROR
;
}
else
{
return
start_bus
(
i2c_bus
);
}
}
bool
start_bus
(
int
i2c_bus
)
{
int
fd
;
...
...
@@ -483,6 +517,7 @@ meas_airspeed_usage()
PX4_INFO
(
"usage: meas_airspeed command [options]"
);
PX4_INFO
(
"options:"
);
PX4_INFO
(
"
\t
-b --bus i2cbus (%d)"
,
PX4_I2C_BUS_DEFAULT
);
PX4_INFO
(
"
\t
-a --all"
);
PX4_INFO
(
"command:"
);
PX4_INFO
(
"
\t
start|stop|reset"
);
}
...
...
@@ -496,12 +531,16 @@ ms4525_airspeed_main(int argc, char *argv[])
int
ch
;
const
char
*
myoptarg
=
nullptr
;
while
((
ch
=
px4_getopt
(
argc
,
argv
,
"b:"
,
&
myoptind
,
&
myoptarg
))
!=
EOF
)
{
while
((
ch
=
px4_getopt
(
argc
,
argv
,
"
a
b:"
,
&
myoptind
,
&
myoptarg
))
!=
EOF
)
{
switch
(
ch
)
{
case
'b'
:
i2c_bus
=
atoi
(
myoptarg
);
break
;
case
'a'
:
i2c_bus
=
PX4_I2C_ALL
;
break
;
default:
meas_airspeed_usage
();
return
0
;
...
...
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