From a85fbd2c75d5e58acc32a0a5defab19d198604dd Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 28 Feb 2018 17:10:46 +0100 Subject: [PATCH] sys/auto_init: update tcs37727 auto_init --- drivers/include/tcs37727.h | 5 ----- sys/auto_init/saul/auto_init_tcs37727.c | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/include/tcs37727.h b/drivers/include/tcs37727.h index 933398e847..f28d4b3247 100644 --- a/drivers/include/tcs37727.h +++ b/drivers/include/tcs37727.h @@ -81,11 +81,6 @@ enum { TCS37727_NODEV = -2 /**< no TCS37727 device found on the bus */ }; -/** - * @brief Export the sensor's SAUL interface - */ -extern const saul_driver_t tcs37727_saul_driver; - /** * @brief Initialize the given TCS37727 sensor * diff --git a/sys/auto_init/saul/auto_init_tcs37727.c b/sys/auto_init/saul/auto_init_tcs37727.c index 4d7069027a..cfa9d5fa12 100644 --- a/sys/auto_init/saul/auto_init_tcs37727.c +++ b/sys/auto_init/saul/auto_init_tcs37727.c @@ -41,13 +41,25 @@ static tcs37727_t tcs37727_devs[TCS37727_NUM]; */ static saul_reg_t saul_entries[TCS37727_NUM]; +/** + * @brief Define the number of saul info + */ +#define TCS37727_INFO_NUM (sizeof(tcs37727_saul_info) / sizeof(tcs37727_saul_info[0])) + +/** + * @brief Export the sensor's SAUL interface + */ +extern const saul_driver_t tcs37727_saul_driver; + void auto_init_tcs37727(void) { + assert(TCS37727_NUM == TCS37727_INFO_NUM); + for (unsigned i = 0; i < TCS37727_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing tcs29020 #%u\n", i); - int res = tcs37727_init(&tcs37727_devs[i], &tcs37727_params[i]); - if (res != TCS37727_OK) { + if (tcs37727_init(&tcs37727_devs[i], + &tcs37727_params[i]) != TCS37727_OK) { LOG_ERROR("[auto_init_saul] error initializing tcs37727 #%u\n", i); continue; }