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
4445d940
You need to sign in or sign up before continuing.
Commit
4445d940
authored
9 years ago
by
Kaspar Schleiser
Browse files
Options
Downloads
Patches
Plain Diff
drivers: sht11: use xtimer
parent
cbd7d42e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile.dep
+4
-0
4 additions, 0 deletions
Makefile.dep
drivers/include/sht11.h
+2
-2
2 additions, 2 deletions
drivers/include/sht11.h
drivers/sht11/sht11.c
+24
-24
24 additions, 24 deletions
drivers/sht11/sht11.c
with
30 additions
and
26 deletions
Makefile.dep
+
4
−
0
View file @
4445d940
...
...
@@ -354,3 +354,7 @@ endif
ifneq
(,$(filter mpu9150,$(USEMODULE)))
USEMODULE
+=
xtimer
endif
ifneq
(,$(filter sht11,$(USEMODULE)))
USEMODULE
+=
xtimer
endif
This diff is collapsed.
Click to expand it.
drivers/include/sht11.h
+
2
−
2
View file @
4445d940
...
...
@@ -37,9 +37,9 @@ extern "C" {
#define SHT11_RESET (0x1E) //000 1111 0
/* time to wait after toggling the data line */
#define SHT11_DATA_WAIT
(HWTIMER_TICKS
(1)
)
#define SHT11_DATA_WAIT (1)
/* time to wait after toggling the clock line */
#define SHT11_CLK_WAIT
(HWTIMER_TICKS
(1)
)
#define SHT11_CLK_WAIT (1)
/* set measurement timeout to 1 second */
#define SHT11_MEASURE_TIMEOUT (1000)
...
...
This diff is collapsed.
Click to expand it.
drivers/sht11/sht11.c
+
24
−
24
View file @
4445d940
...
...
@@ -25,7 +25,7 @@
#include
<stdio.h>
#include
<stdint.h>
#include
"
hw
timer.h"
#include
"
x
timer.h"
#include
"mutex.h"
#include
"sht11.h"
#include
"sht11-board.h"
...
...
@@ -84,9 +84,9 @@ mutex_t sht11_mutex = MUTEX_INIT;
static
inline
void
clk_signal
(
void
)
{
SHT11_SCK_HIGH
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
SHT11_SCK_LOW
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
}
/*---------------------------------------------------------------------------*/
...
...
@@ -101,11 +101,11 @@ static uint8_t write_byte(uint8_t value)
for
(
i
=
0
;
i
<
8
;
i
++
)
{
if
(
value
&
BIT7
)
{
SHT11_DATA_HIGH
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
}
else
{
SHT11_DATA_LOW
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
}
/* trigger clock signal */
...
...
@@ -117,7 +117,7 @@ static uint8_t write_byte(uint8_t value)
/* wait for ack */
SHT11_DATA_IN
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
ack
=
SHT11_DATA
;
clk_signal
();
...
...
@@ -131,13 +131,13 @@ static uint8_t read_byte(uint8_t ack)
uint8_t
value
=
0
;
SHT11_DATA_IN
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
/* read value bit by bit */
for
(
i
=
0
;
i
<
8
;
i
++
)
{
value
=
value
<<
1
;
SHT11_SCK_HIGH
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
if
(
SHT11_DATA
)
{
/* increase data by one when DATA is high */
...
...
@@ -145,7 +145,7 @@ static uint8_t read_byte(uint8_t ack)
}
SHT11_SCK_LOW
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
}
/* send ack if necessary */
...
...
@@ -153,11 +153,11 @@ static uint8_t read_byte(uint8_t ack)
if
(
ack
)
{
SHT11_DATA_LOW
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
}
else
{
SHT11_DATA_HIGH
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
}
clk_signal
();
...
...
@@ -179,27 +179,27 @@ static void transmission_start(void)
/* set initial state */
SHT11_DATA_HIGH
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
SHT11_SCK_LOW
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
SHT11_SCK_HIGH
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
SHT11_DATA_LOW
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
SHT11_SCK_LOW
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
SHT11_SCK_HIGH
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
SHT11_DATA_HIGH
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
SHT11_SCK_LOW
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
}
/*---------------------------------------------------------------------------*/
static
void
connection_reset
(
void
)
...
...
@@ -211,9 +211,9 @@ static void connection_reset(void)
*/
uint8_t
i
;
SHT11_DATA_HIGH
;
hw
timer_
wait
(
SHT11_DATA_WAIT
);
x
timer_
usleep
(
SHT11_DATA_WAIT
);
SHT11_SCK_LOW
;
hw
timer_
wait
(
SHT11_CLK_WAIT
);
x
timer_
usleep
(
SHT11_CLK_WAIT
);
for
(
i
=
0
;
i
<
9
;
i
++
)
{
clk_signal
();
...
...
@@ -231,7 +231,7 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode)
transmission_start
();
error
=
write_byte
(
mode
);
hw
timer_
wait
(
HWTIMER_TICKS
(
1000
)
)
;
x
timer_
usleep
(
1000
);
/* wait untile sensor has finished measurement or timeout */
for
(
i
=
0
;
(
i
<
SHT11_MEASURE_TIMEOUT
)
&&
(
!
error
);
i
++
)
{
...
...
@@ -241,7 +241,7 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode)
break
;
}
hw
timer_
wait
(
HWTIMER_TICKS
(
1000
)
)
;
x
timer_
usleep
(
1000
);
}
error
+=
ack
;
...
...
@@ -260,7 +260,7 @@ void sht11_init(void)
{
sht11_temperature_offset
=
0
;
SHT11_INIT
;
hw
timer_
wait
(
11
*
HWTIMER_TICKS
(
1000
)
)
;
x
timer_
usleep
(
11
*
1000
);
}
/*---------------------------------------------------------------------------*/
uint8_t
sht11_read_status
(
uint8_t
*
p_value
,
uint8_t
*
p_checksum
)
...
...
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