From owner-freebsd-hackers@FreeBSD.ORG Tue Sep 25 04:39:24 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28E0116A418 for ; Tue, 25 Sep 2007 04:39:24 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.freebsd.org (Postfix) with ESMTP id DA0A713C45A for ; Tue, 25 Sep 2007 04:39:23 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (qevi4km7462weulg@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id l8P4DDsL048481; Mon, 24 Sep 2007 21:13:13 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id l8P4DANK048480; Mon, 24 Sep 2007 21:13:10 -0700 (PDT) (envelope-from jmg) Date: Mon, 24 Sep 2007 21:13:10 -0700 From: John-Mark Gurney To: Ian Smith Message-ID: <20070925041310.GA47467@funkthat.com> Mail-Followup-To: Ian Smith , freebsd-hackers@freebsd.org References: <46F48911.6010106@nimnet.asn.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46F48911.6010106@nimnet.asn.au> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (hydrogen.funkthat.com [127.0.0.1]); Mon, 24 Sep 2007 21:13:13 -0700 (PDT) Cc: freebsd-hackers@freebsd.org Subject: Re: how to use iic(4) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Sep 2007 04:39:24 -0000 Ian Smith wrote this message on Sat, Sep 22, 2007 at 13:16 +1000: > This drew a blank in -questions. I don't know where else to post it, so > I'm hoping someone here might be able to spare me a clue. You should probably have posted this question to -hackers instead.. This is more low level hardware than networking... > We're building a small board with two AVR Tiny MCUs chatting to each > other over an opto-isolated I2C-compatible bus, hopefully at 400kbps. > > Hoping to use the iicbb(4) on lpbb(4) parallel port interface to talk > with either of these MCUs for debugging, control and data acquisition. > > iic(4) says: > ======= > The iic character device driver provides generic i/o to any iicbus(4) > instance. In order to control I2C devices, use /dev/iic? with the fol- > lowing ioctls: > > Ioctl Description > I2CSTART send start condition to the specified device (with 7-bit > address) on the bus > I2CSTOP send stop condition to the bus > I2CRSTCARD reset the bus > > You may also use read/write routines, then I2C start/stop handshake is > managed by the iicbus system. > ======= > > Does the latter statement suggest that ordinary reads from or writes to > /dev/iic? could be performed by redirection of say echo and read from a > script? Or is the device only accessible by ioctl from eg a C program? No, as you need to select (via I2CSTART) the slave device you are talking w/ before you do a read or a write... > Secondly, how does /dev/iic? come to exist? This 5.5-STABLE system > seems to have all the requisite drivers, but there's no /dev/iic*: > paqi% kldstat -v | egrep 'iic|lpbb' > 29 iicbus/ic > 30 iicbus/iic > 31 bktr/iicbb > 32 lpbb/iicbb > 33 viapm/iicbb > 34 pcf/iicbus > 35 envctrl/iicbus > 36 iicbb/iicbus > 37 bti2c/iicbus > 38 iicbus/iicsmb > 86 iicsmb/smbus > 12 1 0xc2456000 3000 lpbb.ko > 247 ppbus/lpbb You need to have a device that connects between your i2c bus hardware and iicbb or iicbus... I'm not familar w/ lpbb, but I have used /dev/iic? w/ some HD capture card drivers I've written, and they are created when the device driver probes them... lpbb may need hints to get it to attach, or may need a properly functioning parallel port.. > Also, iicbb(4) is said to be a master-only interface. I can work with > that, but if anyone knows of any iicbus slave-mode code I'm all eyes .. That's even more complicated as you either need specialized hardware that will detect when your i2c address is on the bus, or you need to poll/interrupt on line changes, which could get a bit expensive... I have a command line iic program that I used to help debug my drivers.. The tool lets you start and then read/write from the device, and then stop the bus... I haven't committed it yet, because a few other developers want it under tools, and I don't like it there, as no one knows about most of the tools under there... Maybe if we had a man page that talked about the tools available there it'd be more attractive... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."