Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
7c42e69c
Commit
7c42e69c
authored
7 years ago
by
bbartels
Browse files
Options
Downloads
Patches
Plain Diff
quad: add lidar to virtual quad inputs
parent
0dc0caad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quad/src/virt_quad/hw_impl_unix_i2c.c
+16
-5
16 additions, 5 deletions
quad/src/virt_quad/hw_impl_unix_i2c.c
with
16 additions
and
5 deletions
quad/src/virt_quad/hw_impl_unix_i2c.c
+
16
−
5
View file @
7c42e69c
...
...
@@ -5,6 +5,8 @@
#include
<pthread.h>
#include
"iic_utils.h"
#define NUM_INPUTS 7
void
*
update_i2c_input_cache
(
void
*
);
union
val
{
...
...
@@ -12,16 +14,16 @@ union val {
unsigned
short
s
;
};
static
char
*
input_names
[
6
];
static
int
fifos
[
6
];
static
union
val
cache
[
6
];
static
char
*
input_names
[
NUM_INPUTS
];
static
int
fifos
[
NUM_INPUTS
];
static
union
val
cache
[
NUM_INPUTS
];
static
short
last_dev
;
static
short
last_reg
;
static
short
last_val
;
static
int
nums
[]
=
{
0
,
1
,
2
,
3
,
4
,
5
};
static
pthread_t
workers
[
6
];
static
pthread_t
workers
[
NUM_INPUTS
];
int
unix_i2c_reset
(
struct
I2CDriver
*
self
)
{
input_names
[
0
]
=
"i2c-mpu-accel-x"
;
...
...
@@ -30,12 +32,13 @@ int unix_i2c_reset(struct I2CDriver *self) {
input_names
[
3
]
=
"i2c-mpu-gryo-x"
;
input_names
[
4
]
=
"i2c-mpu-gryo-y"
;
input_names
[
5
]
=
"i2c-mpu-gyro-z"
;
input_names
[
6
]
=
"i2c-lidar"
;
mkdir
(
VIRT_QUAD_FIFOS_DIR
,
0777
);
// Start up worker thread whose job is to update the caches
int
i
;
for
(
i
=
0
;
i
<
6
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
NUM_INPUTS
;
i
+=
1
)
{
pthread_create
(
&
workers
[
i
],
0
,
update_i2c_input_cache
,
&
nums
[
i
]);
}
...
...
@@ -45,6 +48,7 @@ int unix_i2c_reset(struct I2CDriver *self) {
cache
[
3
].
s
=
0
;
cache
[
4
].
s
=
0
;
cache
[
5
].
s
=
0
;
cache
[
6
].
s
=
0
;
return
0
;
}
...
...
@@ -87,6 +91,13 @@ int unix_i2c_read(struct I2CDriver *self,
buff
[
12
]
=
cache
[
5
].
b
[
0
];
buff
[
13
]
=
cache
[
5
].
b
[
1
];
}
else
if
(
last_reg
==
LIDARLITE_DEVICE_ADDR
)
{
buff
[
0
]
=
cache
[
6
].
b
[
0
];
buff
[
1
]
=
cache
[
6
].
b
[
0
];
}
else
{
return
-
1
;
}
}
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