Simon Burge <sim...@netbsd.org> writes: > Hi Brad, > >> Module Name: src >> Committed By: brad >> Date: Tue Nov 22 19:40:31 UTC 2022 >> >> Modified Files: >> >> src/sys/dev/i2c: bmx280.c >> >> Log Message: >> >> Read the datasheet more closely and put in some delays. The chip will >> just return junk if the wait is not long enough to allow a measurement >> to start. > > > + /* Hmm... this delay is not documented well.. mostly just a guess... > + * If it is too short, you will get junk returned as it is possible > to try > + * to ask for the data before the chip has even started... it seems... > + */ > + delay(35000); > > This will spin for 35 milliseconds (per sensor read if I read this > correctly). Can you please look at using kpause(9) for this delay? > See some other i2c drivers for examples of this. > > Cheers, > Simon.
Probably possible, may be a couple of days before I can get to it.... (or not, depends on how holiday prep goes)... I have used some of the cv_timedwait stuff in the past and didn't know about kpause which seems to be suited to what I need to do. Almost all sensor chips require some sort of wait after a command is sent, but this one was particularly frustrating about it. To give out too much information, all of the other sensors I have worked with NACK the I2C bus during the measurement cycle. This one, and probably all of Bosch's chips, do not do that. You have to read back a status register and check to see if it is busy doing something or other. If you just go ahead and read the data registers when it is busy you get junk with no hint that it is junk. But a big "however" is that it is possible (even for a RPI) to read the status register BEFORE the chip has even started to do its measurements, get a positive response (i.e. not busy) and then read the data registers and get junk. This was, as one might say, a "surprising development" as the documentation really does not hint that this sort of thing goes on (or was even possible to do). -- Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org