NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: I cannot make i2c work in raspberry pi Zero W



Hello Brad,

El jue, 11 jul 2024 a las 12:25, Brad Spencer
(<brad%anduin.eldar.org@localhost>) escribió:
>
> Ramiro Aceves <ea1abz%gmail.com@localhost> writes:
>
> [snip]
>
> > Just a probably silly question: If I want to read the sensor that is
> > being used by the bmh280thp driver, should I stop the driver first or
> > the sensor can be inquired by the driver and my program ?
> >
> > Regards.
> > Ramiro.
>
>
> That question is device and driver dependent, but just speaking
> generally, you would not want the kernel driver present if you are
> messing with the device from userland.  If you used modules, simply
> unload it, or don't load it in the first place.  You can probably also
> use 'drvctl -d <device>' to detach the driver.  For the Bosch 280
> devices, you can probably get away with not doing this, as there is very
> little set up that the kernel driver does and there isn't any sort of
> periodic update mode that is used that might have a kernel thread
> polling the device.  As long as you didn't try running envstat at the
> same time you were messing with the device from userland, you may be
> fine.  The kernel driver only holds a i2c lock on the device when it is
> doing a i2c read or write.
>

I greatly appreciate the extensive and detailed response. At this
stage all of this is aimed to do some programming exercise on NetBSD
and learn how to interact with the C functions before I can do
something really useful.


>
> On the BM[EP]280 device itself....  depending on what you are trying to
> actually do...  there are chip specific values that much be read out of
> each chip individually and used in the raw value -> usable value
> conversion routines.  These values are factory set and unique to each
> chip.  You can look at the source for the kernel driver and see how
> these values are pulled out of the chip in the attach function.  To get
> a usable output you need these calibration values and the conversion
> algorithm which is published in the Bosch data sheet in order to get a
> usable values from the sensor.  All other drivers for other devices,
> like the Ardunio, will do something simular.  The Bosch 280 is more
> complicated in this respect then most of the devices it competes with in
> that the consumer of the device's raw output must apply chip specific
> calibration when converting the raw values to something useable.
>
>

Yes I know... I have a BME280, SGP30 and SDC40 sensors connected to an
 Atmel Atmega328 with 2x16 char display (Arduino nano cheap chineese
board) that I programmed with avr-lib and gcc C compiler. I used some
github libraries for the display and BME280 and adapted some code from
Sensirion for the other chips. So I think I can reuse parts of it just
in case. Those chips datasheets are a bit "diabolical"  :-)

Thanks so much.
Ramiro.



>
>
>
> --
> Brad Spencer - brad%anduin.eldar.org@localhost - KC8VKS - http://anduin.eldar.org
>


Home | Main Index | Thread Index | Old Index