Skip to content

Commit

Permalink
Merge pull request #7265 from aabadie/driver_dht_cleanup
Browse files Browse the repository at this point in the history
drivers/dht: some cleanup
  • Loading branch information
miri64 committed Jun 28, 2017
2 parents ce0a8ac + f1a93bf commit a5d3630
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
7 changes: 2 additions & 5 deletions drivers/dht/include/dht_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,9 @@ static const dht_params_t dht_params[] =
/**
* @brief Allocate and configure entries to the SAUL registry
*/
static const saul_reg_info_t dht_saul_info[][2] =
static const saul_reg_info_t dht_saul_reg_info[] =
{
{
{ .name = "dht-temp" },
{ .name = "dht-hum" }
}
{ .name = "dht" }
};
#endif

Expand Down
9 changes: 0 additions & 9 deletions drivers/include/dht.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include <stdint.h>

#include "saul.h"
#include "periph/gpio.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -78,14 +77,6 @@ typedef struct {
*/
typedef dht_t dht_params_t;

/**
* @brief export SAUL endpoints
* @{
*/
extern const saul_driver_t dht_temp_saul_driver;
extern const saul_driver_t dht_hum_saul_driver;
/** @} */

/**
* @brief auto-initialize all configured DHT devices
*/
Expand Down
22 changes: 15 additions & 7 deletions sys/auto_init/saul/auto_init_dht.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,35 @@

#include "log.h"
#include "saul_reg.h"
#include "dht.h"
#include "dht_params.h"
#include "dht.h"

/**
* @brief Define the number of configured sensors
*/
#define DHT_NUM (sizeof(dht_params) / sizeof(dht_params[0]))
#define DHT_NUMOF (sizeof(dht_params) / sizeof(dht_params[0]))

/**
* @brief Allocate memory for the device descriptors
*/
static dht_t dht_devs[DHT_NUM];
static dht_t dht_devs[DHT_NUMOF];

/**
* @brief Import SAUL endpoints
* @{
*/
extern const saul_driver_t dht_temp_saul_driver;
extern const saul_driver_t dht_hum_saul_driver;
/** @} */

/**
* @brief Memory for the SAUL registry entries
*/
static saul_reg_t saul_entries[DHT_NUM * 2];
static saul_reg_t saul_entries[DHT_NUMOF * 2];

void auto_init_dht(void)
{
for (unsigned int i = 0; i < DHT_NUM; i++) {
for (unsigned int i = 0; i < DHT_NUMOF; i++) {
LOG_DEBUG("[auto_init_saul] initializing dht #%u\n", i);

if (dht_init(&dht_devs[i], &dht_params[i]) != DHT_OK) {
Expand All @@ -52,10 +60,10 @@ void auto_init_dht(void)
}

saul_entries[(i * 2)].dev = &(dht_devs[i]);
saul_entries[(i * 2)].name = dht_saul_info[i][0].name;
saul_entries[(i * 2)].name = dht_saul_reg_info[i].name;
saul_entries[(i * 2)].driver = &dht_temp_saul_driver;
saul_entries[(i * 2) + 1].dev = &(dht_devs[i]);
saul_entries[(i * 2) + 1].name = dht_saul_info[i][1].name;
saul_entries[(i * 2) + 1].name = dht_saul_reg_info[i].name;
saul_entries[(i * 2) + 1].driver = &dht_hum_saul_driver;
saul_reg_add(&(saul_entries[(i * 2)]));
saul_reg_add(&(saul_entries[(i * 2) + 1]));
Expand Down

0 comments on commit a5d3630

Please sign in to comment.