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
fd675084
Commit
fd675084
authored
6 years ago
by
DanielePettenuzzo
Committed by
Beat Küng
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ms5525_airspeed: add -a flag to scan all i2c busses during start
parent
cf816fe5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/drivers/differential_pressure/ms4525/ms4525_airspeed.cpp
+13
-5
13 additions, 5 deletions
src/drivers/differential_pressure/ms4525/ms4525_airspeed.cpp
src/drivers/differential_pressure/ms5525/MS5525_main.cpp
+56
-7
56 additions, 7 deletions
src/drivers/differential_pressure/ms5525/MS5525_main.cpp
with
69 additions
and
12 deletions
src/drivers/differential_pressure/ms4525/ms4525_airspeed.cpp
+
13
−
5
View file @
fd675084
...
...
@@ -394,11 +394,13 @@ int stop();
int
reset
();
/**
* Start the driver.
*
* This function call only returns once the driver is up and running
* or failed to detect the sensor.
*/
* Attempt to start driver on all available I2C busses.
*
* This function will return as soon as the first sensor
* is detected on one of the available busses or if no
* sensors are detected.
*
*/
int
start
()
{
...
...
@@ -412,6 +414,12 @@ start()
}
/**
* Start the driver on a specific bus.
*
* This function call only returns once the driver is up and running
* or failed to detect the sensor.
*/
int
start_bus
(
int
i2c_bus
)
{
...
...
This diff is collapsed.
Click to expand it.
src/drivers/differential_pressure/ms5525/MS5525_main.cpp
+
56
−
7
View file @
fd675084
...
...
@@ -43,15 +43,53 @@ namespace ms5525_airspeed
{
MS5525
*
g_dev
=
nullptr
;
int
start
(
uint8_t
i2c_bus
);
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
start_bus
(
uint8_t
i2c_bus
);
int
stop
();
int
reset
();
// Start the driver.
// This function call only returns once the driver is up and running
// or failed to detect the sensor.
/**
* Attempt to start driver on all available I2C busses.
*
* This function will return as soon as the first sensor
* is detected on one of the available busses or if no
* sensors are detected.
*
*/
int
start
(
uint8_t
i2c_bus
)
start
()
{
for
(
unsigned
i
=
0
;
i
<
NUM_BUS_OPTIONS
;
i
++
)
{
if
(
start_bus
(
bus_options
[
i
])
==
PX4_OK
)
{
return
PX4_OK
;
}
}
return
PX4_ERROR
;
}
/**
* Start the driver on a specific bus.
*
* This function call only returns once the driver is up and running
* or failed to detect the sensor.
*/
int
start_bus
(
uint8_t
i2c_bus
)
{
int
fd
=
-
1
;
...
...
@@ -144,6 +182,7 @@ ms5525_airspeed_usage()
PX4_WARN
(
"usage: ms5525_airspeed command [options]"
);
PX4_WARN
(
"options:"
);
PX4_WARN
(
"
\t
-b --bus i2cbus (%d)"
,
PX4_I2C_BUS_DEFAULT
);
PX4_INFO
(
"
\t
-a --all"
);
PX4_WARN
(
"command:"
);
PX4_WARN
(
"
\t
start|stop|reset"
);
}
...
...
@@ -156,13 +195,18 @@ ms5525_airspeed_main(int argc, char *argv[])
int
myoptind
=
1
;
int
ch
;
const
char
*
myoptarg
=
nullptr
;
bool
start_all
=
false
;
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'
:
start_all
=
true
;
break
;
default:
ms5525_airspeed_usage
();
return
0
;
...
...
@@ -178,7 +222,12 @@ ms5525_airspeed_main(int argc, char *argv[])
* Start/load the driver.
*/
if
(
!
strcmp
(
argv
[
myoptind
],
"start"
))
{
return
ms5525_airspeed
::
start
(
i2c_bus
);
if
(
start_all
)
{
return
ms5525_airspeed
::
start
();
}
else
{
return
ms5525_airspeed
::
start_bus
(
i2c_bus
);
}
}
/*
...
...
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