Source-Changes-D archive

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

Re: CVS commit: src/sys/dev/i2c



Taylor R Campbell <campbell+netbsd-source-changes-d%mumble.net@localhost> writes:

[snip]

> The issue here isn't the duration of the delay -- just the mechanism.
> Sleeping for 35ms with kpause(9) is fine, but busy-waiting on the CPU
> for 35ms with delay(9) is not (unless HZ is set to something absurdly
> low like 10 instead of the usual 100, but I doubt that's an important
> use-case to consider here).
>
> In this case, you should use:
>
> 	kpause("bmx280", /*intr*/false, MAX(1, mstohz(35)), NULL);

All understood..  the above, however, was not quite right either.  That
delay is related to the over sampling that is set and wasn't a fixed
value.  I made adjustments to scale the amount of time actually needed
to wait with the over sampling setting.  This is the proper thing that
needed to be done in this case.  I do agree that kpause is a better
thing to use here too..  no doubt..

There wasn't any real documentation about this, but it clearly was
something that needed to be considered.  The only reference was a single
table that listed some of the typical and max durations for just *SOME*
of the over sampling setting (worse, yet, this table was removed from
later versions of the docs).  It left out a lot and did not include any
sort of formula.  Though some experimentation I can up with one that
should be workable and allowed for some tuning if it wasn't quite right.

>> 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).
>
> Can you put a link to the documentation in the source code, and cite
> the sections where you get the complicated formulas like in
> bmx280_compensate_P_int64?

Ya, I can do that.  The three compensation formulas are pulled mostly
literally from the docs.  All I really did was changed the types to
match the kernel names and unglobal'ed some of the variables for the
factory calibration settings.  Peeking at Adafruit's Ardunio code, they
did the same thing.






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


Home | Main Index | Thread Index | Old Index