RIOT-OS / RIOT

RIOT - The friendly OS for IoT
https://riot-os.org
GNU Lesser General Public License v2.1
4.96k stars 1.99k forks source link

Add driver for Honeywell ABP2 series pressure sensors #20233

Open dpcrd opened 11 months ago

dpcrd commented 11 months ago

Description

I would like to use the ABP2 series pressure sensors. This series covers a wide range of sensors, but they all share a common software interface, leveraging the driver code.

They come with 2 interfaces : either SPI or I2C.

Useful links

dpcrd commented 11 months ago

As the interface of these sensors is either SPI or I2C, what is the best strategy to handle dependencies ? For example, FEATURES_REQUIRED += periph_i2c in Makefile.dep doesn't make sense if you want to use the SPI flavor.

dpproto commented 10 months ago

I'm taking over this issue from another GitHub account.

I mostly wrote the SPI driver. I need to do some clean-up.

In the meantime, any idea of how to support SPI and I2C in the same driver the clean way ?

maribu commented 9 months ago

In the meantime, any idea of how to support SPI and I2C in the same driver the clean way ?

This depends a bit on the use case. If it makes no sense to have multiple instances of the same device with different interfaces attached, one could go do it the same as e.g. the BMP280/BME280 driver did with the bmx280_spi module selecting the SPI flavor and the bmx280_i2c selecting the I2C flavor of the driver.

If it would make sense to allow using both, IMO the cleanest would be to split the code over three modules, e.g. abp2_spi for the SPI communication, abp2_i2c for the I2C communication, and abp2_common for conversions, logic etc. The idea would be that abp2_i2c and abp2_spi would be as lean as possible and most of the code would be shared between the two.

dpproto commented 9 months ago

I got a similar answer from a maintainer of the project in the forum. https://forum.riot-os.org/t/how-to-write-a-driver-for-a-sensor-with-either-spi-or-i2c-interface/4102/2