mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #8680 from aabadie/pr/drivers/params/dht
drivers/dht: apply unified params definition scheme
This commit is contained in:
commit
6aa88d99d9
@ -40,10 +40,14 @@ extern "C" {
|
|||||||
#ifndef DHT_PARAM_PULL
|
#ifndef DHT_PARAM_PULL
|
||||||
#define DHT_PARAM_PULL (GPIO_IN_PU)
|
#define DHT_PARAM_PULL (GPIO_IN_PU)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef DHT_PARAMS
|
||||||
#define DHT_PARAMS_DEFAULT {.pin = DHT_PARAM_PIN, \
|
#define DHT_PARAMS { .pin = DHT_PARAM_PIN, \
|
||||||
.type = DHT_PARAM_TYPE, \
|
.type = DHT_PARAM_TYPE, \
|
||||||
.in_mode = DHT_PARAM_PULL}
|
.in_mode = DHT_PARAM_PULL }
|
||||||
|
#endif
|
||||||
|
#ifndef DHT_SAULINFO
|
||||||
|
#define DHT_SAULINFO { .name = "dht" }
|
||||||
|
#endif
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,27 +55,16 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
static const dht_params_t dht_params[] =
|
static const dht_params_t dht_params[] =
|
||||||
{
|
{
|
||||||
#ifdef DHT_PARAMS_BOARD
|
DHT_PARAMS
|
||||||
DHT_PARAMS_BOARD,
|
|
||||||
#else
|
|
||||||
DHT_PARAMS_DEFAULT,
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the number of configured DHT devices
|
|
||||||
*/
|
|
||||||
#define DHT_NUMOF (sizeof(dht_params) / sizeof(dht_params[0]))
|
|
||||||
|
|
||||||
#ifdef MODULE_SAUL_REG
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocate and configure entries to the SAUL registry
|
* @brief Allocate and configure entries to the SAUL registry
|
||||||
*/
|
*/
|
||||||
static const saul_reg_info_t dht_saul_reg_info[] =
|
static const saul_reg_info_t dht_saul_info[] =
|
||||||
{
|
{
|
||||||
{ .name = "dht" }
|
DHT_SAULINFO
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -29,29 +29,36 @@
|
|||||||
/**
|
/**
|
||||||
* @brief Define the number of configured sensors
|
* @brief Define the number of configured sensors
|
||||||
*/
|
*/
|
||||||
#define DHT_NUMOF (sizeof(dht_params) / sizeof(dht_params[0]))
|
#define DHT_NUM (sizeof(dht_params) / sizeof(dht_params[0]))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocate memory for the device descriptors
|
* @brief Allocate memory for the device descriptors
|
||||||
*/
|
*/
|
||||||
static dht_t dht_devs[DHT_NUMOF];
|
static dht_t dht_devs[DHT_NUM];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Import SAUL endpoints
|
* @brief Memory for the SAUL registry entries
|
||||||
|
*/
|
||||||
|
static saul_reg_t saul_entries[DHT_NUM * 2];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Define the number of saul info
|
||||||
|
*/
|
||||||
|
#define DHT_INFO_NUM (sizeof(dht_saul_info) / sizeof(dht_saul_info[0]))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name Import SAUL endpoints
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
extern const saul_driver_t dht_temp_saul_driver;
|
extern const saul_driver_t dht_temp_saul_driver;
|
||||||
extern const saul_driver_t dht_hum_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_NUMOF * 2];
|
|
||||||
|
|
||||||
void auto_init_dht(void)
|
void auto_init_dht(void)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < DHT_NUMOF; i++) {
|
assert(DHT_INFO_NUM == DHT_NUM);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < DHT_NUM; i++) {
|
||||||
LOG_DEBUG("[auto_init_saul] initializing dht #%u\n", i);
|
LOG_DEBUG("[auto_init_saul] initializing dht #%u\n", i);
|
||||||
|
|
||||||
if (dht_init(&dht_devs[i], &dht_params[i]) != DHT_OK) {
|
if (dht_init(&dht_devs[i], &dht_params[i]) != DHT_OK) {
|
||||||
@ -60,10 +67,10 @@ void auto_init_dht(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
saul_entries[(i * 2)].dev = &(dht_devs[i]);
|
saul_entries[(i * 2)].dev = &(dht_devs[i]);
|
||||||
saul_entries[(i * 2)].name = dht_saul_reg_info[i].name;
|
saul_entries[(i * 2)].name = dht_saul_info[i].name;
|
||||||
saul_entries[(i * 2)].driver = &dht_temp_saul_driver;
|
saul_entries[(i * 2)].driver = &dht_temp_saul_driver;
|
||||||
saul_entries[(i * 2) + 1].dev = &(dht_devs[i]);
|
saul_entries[(i * 2) + 1].dev = &(dht_devs[i]);
|
||||||
saul_entries[(i * 2) + 1].name = dht_saul_reg_info[i].name;
|
saul_entries[(i * 2) + 1].name = dht_saul_info[i].name;
|
||||||
saul_entries[(i * 2) + 1].driver = &dht_hum_saul_driver;
|
saul_entries[(i * 2) + 1].driver = &dht_hum_saul_driver;
|
||||||
saul_reg_add(&(saul_entries[(i * 2)]));
|
saul_reg_add(&(saul_entries[(i * 2)]));
|
||||||
saul_reg_add(&(saul_entries[(i * 2) + 1]));
|
saul_reg_add(&(saul_entries[(i * 2) + 1]));
|
||||||
|
Loading…
Reference in New Issue
Block a user