1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-17 18:43:50 +01:00
RIOT/drivers/saul/init_devs/auto_init_abp2.c
David Picard d2f8d4df22 drivers/abp2: driver for SPI sensors, prepare for I2C
Honeywell ABP2 pressure sensors series.
Implement all sensors features, only supporting the SPI version
of the sensor.
Prepare future support for the I2C interface by emphasizing where
to implement the code that will support the I2C bus version.
2025-05-04 10:28:58 +02:00

72 lines
1.8 KiB
C

/*
* Copyright (C) 2024 CNRS, France
*
* 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 Honeywell ABP2 series
* pressure and temperature sensor
*
* @author David Picard <david.picard@clermont.in2p3.fr>
* @}
*/
#include "container.h"
#include "log.h"
#include "saul_reg.h"
#include "abp2.h"
#include "abp2_params.h"
/**
* @brief Define the number of configured sensors
*/
#define ABP2_NUM ARRAY_SIZE(abp2_params)
/**
* @brief Allocate memory for the device descriptors
*/
static abp2_t abp2_devs[ABP2_NUM];
/**
* @brief Memory for the SAUL registry entries
*/
static saul_reg_t saul_entries[ABP2_NUM * 2];
/**
* @brief Reference the driver struct
*/
extern saul_driver_t abp2_saul_driver_press;
extern saul_driver_t abp2_saul_driver_temp;
void auto_init_abp2(void)
{
for (unsigned int i = 0; i < ABP2_NUM; i++) {
LOG_DEBUG("[auto_init_saul] initializing abp2 #%u\n", i);
int res = abp2_init(&abp2_devs[i], &abp2_params[i]);
if (res) {
LOG_ERROR("[auto_init_saul] error initializing abp2 #%u\n", i);
continue;
}
/* pressure */
saul_entries[(i * 2)].dev = &(abp2_devs[i]);
saul_entries[(i * 2)].name = abp2_saul_info[i][0].name;
saul_entries[(i * 2)].driver = &abp2_saul_driver_press;
saul_reg_add(&(saul_entries[i]));
/* temperature */
saul_entries[(i * 2) + 1].dev = &(abp2_devs[i]);
saul_entries[(i * 2) + 1].name = abp2_saul_info[i][1].name;
saul_entries[(i * 2) + 1].driver = &abp2_saul_driver_temp;
saul_reg_add(&(saul_entries[(i * 2) + 1]));
}
}