-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sys/auto_init: Added auto initialization for pH OEM driver
- Loading branch information
1 parent
61d0970
commit 89082a3
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2019 University of Applied Sciences Emden / Leer | ||
* | ||
* 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 Atlas Scientific pH OEM sensor | ||
* | ||
* @author igor.knippenberg@gmail.com | ||
* | ||
* @} | ||
*/ | ||
|
||
#ifdef MODULE_PH_OEM | ||
|
||
#include "assert.h" | ||
#include "log.h" | ||
|
||
#include "saul_reg.h" | ||
#include "ph_oem.h" | ||
#include "ph_oem_params.h" | ||
|
||
/** | ||
* @brief Define the number of configured sensors | ||
*/ | ||
#define PH_OEM_NUM (sizeof(ph_oem_params) / sizeof(ph_oem_params[0])) | ||
|
||
/** | ||
* @brief Allocate memory for the device descriptors | ||
*/ | ||
static ph_oem_t ph_oem_devs[PH_OEM_NUM]; | ||
|
||
/** | ||
* @brief Memory for the SAUL registry entries | ||
*/ | ||
static saul_reg_t saul_entries[PH_OEM_NUM]; | ||
|
||
/** | ||
* @brief Define the number of saul info | ||
*/ | ||
#define PH_OEM_INFO_NUM (sizeof(ph_oem_saul_info) / sizeof(ph_oem_saul_info[0])) | ||
|
||
/** | ||
* @brief Reference the driver struct | ||
*/ | ||
extern saul_driver_t ph_oem_saul_driver; | ||
|
||
void auto_init_ph_oem(void) | ||
{ | ||
assert(PH_OEM_INFO_NUM == PH_OEM_NUM); | ||
|
||
for (unsigned i = 0; i < PH_OEM_NUM; i++) { | ||
LOG_DEBUG("[auto_init_saul] initializing ph_oem #%d\n", i); | ||
if (ph_oem_init(&ph_oem_devs[i], &ph_oem_params[i]) < 0) { | ||
LOG_ERROR("[auto_init_saul] error initializing ph_oem #%d\n", i); | ||
continue; | ||
} | ||
|
||
saul_entries[i].dev = &(ph_oem_devs[i]); | ||
saul_entries[i].name = ph_oem_saul_info[i].name; | ||
saul_entries[i].driver = &ph_oem_saul_driver; | ||
saul_reg_add(&(saul_entries[i])); | ||
} | ||
} | ||
|
||
#else | ||
typedef int dont_be_pedantic; | ||
#endif /* MODULE_PH_OEM */ |