Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
ada06e9d
Commit
ada06e9d
authored
9 years ago
by
Kaspar Schleiser
Browse files
Options
Downloads
Patches
Plain Diff
drivers: dht: adapt to xtimer
parent
7d2286e3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile.dep
+4
-0
4 additions, 0 deletions
Makefile.dep
drivers/dht/dht.c
+7
-7
7 additions, 7 deletions
drivers/dht/dht.c
with
11 additions
and
7 deletions
Makefile.dep
+
4
−
0
View file @
ada06e9d
...
@@ -341,3 +341,7 @@ endif
...
@@ -341,3 +341,7 @@ endif
ifneq
(,$(filter srf02,$(USEMODULE)))
ifneq
(,$(filter srf02,$(USEMODULE)))
USEMODULE
+=
xtimer
USEMODULE
+=
xtimer
endif
endif
ifneq
(,$(filter dht,$(USEMODULE)))
USEMODULE
+=
xtimer
endif
This diff is collapsed.
Click to expand it.
drivers/dht/dht.c
+
7
−
7
View file @
ada06e9d
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#include
<stdint.h>
#include
<stdint.h>
#include
"
hw
timer.h"
#include
"
x
timer.h"
#include
"timex.h"
#include
"timex.h"
#include
"periph/gpio.h"
#include
"periph/gpio.h"
...
@@ -79,9 +79,9 @@ static void dht_read_data(gpio_t dev, uint32_t *data, uint8_t *checksum)
...
@@ -79,9 +79,9 @@ static void dht_read_data(gpio_t dev, uint32_t *data, uint8_t *checksum)
{
{
/* send init signal to device */
/* send init signal to device */
gpio_clear
(
dev
);
gpio_clear
(
dev
);
hw
timer_
wait
(
HWTIMER_TICKS
(
20
*
MS_IN_USEC
)
)
;
x
timer_
usleep
(
20
*
MS_IN_USEC
);
gpio_set
(
dev
);
gpio_set
(
dev
);
hw
timer_
wait
(
HWTIMER_TICKS
(
40
)
)
;
x
timer_
usleep
(
40
);
/* sync on device */
/* sync on device */
gpio_init
(
dev
,
GPIO_DIR_IN
,
GPIO_PULLUP
);
gpio_init
(
dev
,
GPIO_DIR_IN
,
GPIO_PULLUP
);
...
@@ -101,14 +101,14 @@ static void dht_read_data(gpio_t dev, uint32_t *data, uint8_t *checksum)
...
@@ -101,14 +101,14 @@ static void dht_read_data(gpio_t dev, uint32_t *data, uint8_t *checksum)
we must not shift the last bit */
we must not shift the last bit */
/* wait for start of bit */
/* wait for start of bit */
while
(
!
gpio_read
(
dev
))
;
while
(
!
gpio_read
(
dev
))
;
unsigned
long
start
=
hw
timer_now
();
unsigned
long
start
=
x
timer_now
();
/* wait for end of bit */
/* wait for end of bit */
while
(
gpio_read
(
dev
))
;
while
(
gpio_read
(
dev
))
;
/* calculate bit length (long 1, short 0) */
/* calculate bit length (long 1, short 0) */
unsigned
long
stop
=
hw
timer_now
();
unsigned
long
stop
=
x
timer_now
();
/* compensate for overflow if needed */
/* compensate for overflow if needed */
if
(
stop
<
start
)
{
if
(
stop
<
start
)
{
stop
=
HWTIMER_MAXTICKS
-
stop
;
stop
=
UINT32_MAX
-
stop
;
start
=
0
;
start
=
0
;
}
}
if
((
stop
-
start
)
>
40
)
{
if
((
stop
-
start
)
>
40
)
{
...
@@ -143,7 +143,7 @@ int dht_init(dht_t *dev, dht_type_t type, gpio_t gpio)
...
@@ -143,7 +143,7 @@ int dht_init(dht_t *dev, dht_type_t type, gpio_t gpio)
}
}
gpio_set
(
gpio
);
gpio_set
(
gpio
);
hw
timer_
wait
(
HWTIMER_TICKS
(
2000
*
MS_IN_USEC
)
)
;
x
timer_
usleep
(
2000
*
MS_IN_USEC
);
DEBUG
(
"dht_init: success
\n
"
);
DEBUG
(
"dht_init: success
\n
"
);
return
0
;
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