Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 May 2019 15:14:52 -0700 (PDT)
From:      "Rodney W. Grimes" <freebsd-rwg@gndrsh.dnsmgr.net>
To:        Ian Lepore <ian@freebsd.org>
Cc:        Karl Denninger <karl@denninger.net>, freebsd-arm@freebsd.org, Prasad M <mprasad9689@gmail.com>
Subject:   Re: FreeBsd I2C utility gives same value as MSB and LSB from DS75 sensor 16bit register.
Message-ID:  <201905222214.x4MMEq9b086987@gndrsh.dnsmgr.net>
In-Reply-To: <e430da11ed01f26197adf92c3ab53aba0813ee02.camel@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> On Wed, 2019-05-08 at 14:06 -0500, Karl Denninger wrote:
> > On 5/3/2019 06:43, Prasad M wrote:
> > > Hi Folks,
> > > 
> > > I am trying to access a DS75 I2C temperature sensor. It kind of works with
> > > the default i2c utility. But it returns twice the high byte instead of the
> > > high and low byte for the temperature. Probably because it does 1 byte
> > > reads on the I2C bus, sending a stop condition after every byte.
> > > 
> > > The device expects continuous reads and no stop/start in between the 2
> > > bytes. Trying all options i2c, most notably the -m mode switch, yields the
> > > same results all the time. Looking at the code in i2c.c
> > > 
> > > Could any one help to solve this problem with working I2CRDWR utility.
> > 
> > I don't know if you can do it with that utility, but coding up a simple
> > (~10-15 lines of "C") that reads two bytes is trivially easy.
> > 
> > You simply stuff a message buffer requesting 2 bytes in response and
> > call ioctl; you get back two bytes.
> > 
> 
> This should now be fixed as of r348120 in 13-current, which I will MFC
> to 12-stable after it gets some testing.  The fix adds a new "-m tr"
> mode.  'tr' is for "transfer", a mode in which the complete set of i2c
> operations are all handed to the driver at once using I2CRDWR, rather
> than doing a set of individual START/REPEAT/STOP commands from
> userland.  Some drivers (such as rpi) only work with complete
> transfers.
> 
> So, to read the temperature from a DS75, it should now work like:
> 
>  i2c -m tr -a 0x40 -d r -o 0 -w 8 -c 2

Thank you, I think this is going to be well used!

> -- Ian
-- 
Rod Grimes                                                 rgrimes@freebsd.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905222214.x4MMEq9b086987>