Merge pull request #8674 from aabadie/pr/drivers/params/grove_ledbar

drivers/grove_ledbar: apply unified params definition scheme
This commit is contained in:
Martine Lenders 2018-03-07 14:07:54 +01:00 committed by GitHub
commit f7d3532b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 13 deletions

View File

@ -54,23 +54,24 @@ extern "C"
/**
* @brief Default parameter settings
*/
#define GROVE_LEDBAR_PARAMS { \
.leds = 10, \
#ifndef GROVE_LEDBAR_PARAMS
#define GROVE_LEDBAR_PARAMS { .leds = 10, \
.dir = GROVE_LEDBAR_DIR, \
.clk = GROVE_LEDBAR_CLK, \
.dat = GROVE_LEDBAR_DAT, \
}
.dat = GROVE_LEDBAR_DAT }
#endif
/**
* @brief SAUL info
*/
#define GROVE_LEDBAR_SAUL_INFO { .name = "Grove LED bar" }
/**
* @brief Grove LED bar configuration
*/
static const grove_ledbar_params_t grove_ledbar_params[] =
{
#ifdef GROVE_LEDBAR_CUSTOM
GROVE_LEDBAR_CUSTOM,
#else
GROVE_LEDBAR_PARAMS,
#endif
};
/**
@ -78,9 +79,7 @@ static const grove_ledbar_params_t grove_ledbar_params[] =
*/
static const saul_reg_info_t grove_ledbar_saul_info[] =
{
{
.name = "Grove LED bar"
}
GROVE_LEDBAR_SAUL_INFO
};
#ifdef __cplusplus

View File

@ -42,6 +42,11 @@ static grove_ledbar_t grove_ledbar_devs[GROVE_LEDBAR_NUM];
*/
static saul_reg_t saul_entries[GROVE_LEDBAR_NUM];
/**
* @brief Define the number of saul info
*/
#define GROVE_LEDBAR_INFO_NUM (sizeof(grove_ledbar_saul_info) / sizeof(grove_ledbar_saul_info[0]))
/**
* @brief Reference the driver struct
*/
@ -49,6 +54,8 @@ extern const saul_driver_t grove_ledbar_saul_driver;
void auto_init_grove_ledbar(void)
{
assert(GROVE_LEDBAR_NUM == GROVE_LEDBAR_INFO_NUM);
for (unsigned i = 0; i < GROVE_LEDBAR_NUM; i++) {
LOG_DEBUG("[auto_init_saul] initializing Grove LED bar #%u: ", i);