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
bba4d5b3
Commit
bba4d5b3
authored
6 years ago
by
Michel Rottleuthner
Browse files
Options
Downloads
Patches
Plain Diff
drivers/sds011: add saul integration
parent
61dc1920
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
drivers/sds011/sds011_saul.c
+46
-0
46 additions, 0 deletions
drivers/sds011/sds011_saul.c
sys/auto_init/auto_init.c
+4
-0
4 additions, 0 deletions
sys/auto_init/auto_init.c
sys/auto_init/saul/auto_init_sds011.c
+88
-0
88 additions, 0 deletions
sys/auto_init/saul/auto_init_sds011.c
with
138 additions
and
0 deletions
drivers/sds011/sds011_saul.c
0 → 100644
+
46
−
0
View file @
bba4d5b3
/*
* Copyright (C) 2018 HAW-Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*
*/
/**
* @ingroup drivers_sds011
* @{
*
* @file
* @brief SAUL adaption for SDS011 sensor
*
* @author Michel Rottleuthner <michel.rottleuthner@haw-hamburg.de>
*
* @}
*/
#include
<string.h>
#include
"saul.h"
#include
"sds011.h"
#include
"xtimer.h"
static
int
_read
(
const
void
*
dev
,
phydat_t
*
res
)
{
sds011_data_t
data
;
if
(
sds011_read
((
sds011_t
*
)
dev
,
&
data
)
==
SDS011_OK
)
{
res
->
val
[
0
]
=
data
.
pm_2_5
;
res
->
val
[
1
]
=
data
.
pm_10
;
res
->
unit
=
UNIT_GPM3
;
res
->
scale
=
-
7
;
return
2
;
}
return
ECANCELED
;
}
const
saul_driver_t
sds011_saul_driver
=
{
.
read
=
_read
,
.
write
=
saul_notsup
,
.
type
=
SAUL_SENSE_PM
};
This diff is collapsed.
Click to expand it.
sys/auto_init/auto_init.c
+
4
−
0
View file @
bba4d5b3
...
...
@@ -449,6 +449,10 @@ void auto_init(void)
extern
void
auto_init_sht3x
(
void
);
auto_init_sht3x
();
#endif
#ifdef MODULE_SDS011
extern
void
auto_init_sds011
(
void
);
auto_init_sds011
();
#endif
#ifdef MODULE_SI114X
extern
void
auto_init_si114x
(
void
);
auto_init_si114x
();
...
...
This diff is collapsed.
Click to expand it.
sys/auto_init/saul/auto_init_sds011.c
0 → 100644
+
88
−
0
View file @
bba4d5b3
/*
* Copyright (C) 2018 HAW-Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*
*/
/*
* @ingroup sys_auto_init_saul
* @{
*
* @file
* @brief Auto initialization for SDS011 particulate matter sensor
*
* @author Michel Rottleuthner <michel.rottleuthner@haw-hamburg.de>
*
* @}
*/
#ifdef MODULE_SDS011
#include
"assert.h"
#include
"log.h"
#include
"saul_reg.h"
#include
"sds011.h"
#include
"sds011_params.h"
/**
* @brief Define the number of configured sensors
*/
#define SDS011_NUM (sizeof(sds011_params) / sizeof(sds011_params[0]))
/**
* @brief Allocate memory for the device descriptors
*/
static
sds011_t
sds011_devs
[
SDS011_NUM
];
/**
* @brief Memory for the SAUL registry entries
*/
static
saul_reg_t
saul_entries
[
SDS011_NUM
];
/**
* @brief Define the number of saul info
*/
#define SDS011_INFO_NUM (sizeof(sds011_saul_info) / sizeof(sds011_saul_info[0]))
/**
* @name Import SAUL endpoint
* @{
*/
extern
const
saul_driver_t
sds011_saul_driver
;
/** @} */
void
auto_init_sds011
(
void
)
{
assert
(
SDS011_INFO_NUM
==
SDS011_NUM
);
for
(
unsigned
int
i
=
0
;
i
<
SDS011_NUM
;
i
++
)
{
LOG_DEBUG
(
"[auto_init_saul] initializing sds011 #%u
\n
"
,
i
);
if
(
sds011_init
(
&
sds011_devs
[
i
],
&
sds011_params
[
i
])
!=
SDS011_OK
)
{
LOG_ERROR
(
"[auto_init_saul] error initializing sds011 #%u
\n
"
,
i
);
continue
;
}
int
retries
=
0
;
/* sensor must be set to query mode for manual reading by saul */
while
(
sds011_set_reporting_mode
(
&
sds011_devs
[
i
],
SDS011_RMODE_QUERY
)
!=
SDS011_OK
)
{
if
(
retries
++
>=
3
)
{
LOG_ERROR
(
"[auto_init_saul] error setting sds011 to query mode #%u
\n
"
,
i
);
continue
;
}
}
saul_entries
[
i
].
dev
=
&
(
sds011_devs
[
i
]);
saul_entries
[
i
].
name
=
sds011_saul_info
[
i
].
name
;
saul_entries
[
i
].
driver
=
&
sds011_saul_driver
;
saul_reg_add
(
&
saul_entries
[
i
]);
}
}
#else
typedef
int
dont_be_pedantic
;
#endif
/* MODULE_SDS011 */
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