diff --git a/drivers/saul/init_devs/auto_init_efm32_coretemp.c b/drivers/saul/init_devs/auto_init_efm32_coretemp.c new file mode 100644 index 0000000000..b79f989216 --- /dev/null +++ b/drivers/saul/init_devs/auto_init_efm32_coretemp.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2020 Bas Stottelaar + * + * 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 of EFM32 core temperature driver + * + * @author Bas Stottelaar + * + * @} + */ + +#include "log.h" +#include "saul_reg.h" +#include "saul/periph.h" +#include "coretemp.h" + +/** + * @brief Memory for the SAUL registry entry + */ +static saul_reg_t saul_reg_entry; + +/** + * @brief Reference the driver struct + */ +extern saul_driver_t efm32_coretemp_saul_driver; + +/** + * @brief Reference the information for saul registry + */ +extern saul_reg_info_t efm32_coretemp_saul_info; + +void auto_init_efm32_coretemp(void) +{ + LOG_DEBUG("[auto_init_saul] initializing EFM32 coretemp\n"); + + /* initialize driver */ + if (coretemp_init() != 0) { + LOG_ERROR("[auto_init_saul] error initializing EFM32 coretemp\n"); + return; + } + + /* add to registry */ + saul_reg_entry.dev = NULL; + saul_reg_entry.name = efm32_coretemp_saul_info.name; + saul_reg_entry.driver = &efm32_coretemp_saul_driver; + + saul_reg_add(&(saul_reg_entry)); +} diff --git a/drivers/saul/init_devs/init.c b/drivers/saul/init_devs/init.c index 45b95e7f3c..dda33a68e8 100644 --- a/drivers/saul/init_devs/init.c +++ b/drivers/saul/init_devs/init.c @@ -95,6 +95,10 @@ void saul_init_devs(void) extern void auto_init_ds75lx(void); auto_init_ds75lx(); } + if (IS_USED(MODULE_EFM32_CORETEMP)) { + extern void auto_init_efm32_coretemp(void); + auto_init_efm32_coretemp(); + } if (IS_USED(MODULE_FXOS8700)) { extern void auto_init_fxos8700(void); auto_init_fxos8700();