RFC: extension of libi2c to support SPI aswell

Thomas Doerfler Thomas.Doerfler at embedded-brains.de
Mon Sep 3 16:16:58 UTC 2007


some weeks ago, I have implemented a I2C driver based on cpukit/libi2c.
This library is an elegant solution to handle multiple serial (I2C)
devices connected to a I2C bus.

Now I have the task to support an SPI bus as well and I think libi2c
only needs few extensions to also support SPI devices. The differences
are rather small, so I want to avoid copying the code into a separate
libspi.c. Before I really start, I would like to get some feedback from
the list.

Here are the things that should be added to libi2c and its APIs.
Everything can be implemented without breaking the existing API:

API between libi2c and low level driver:

- An optional "readwrite_op" call should be added to allow simultaneous
read/write transfers (since SPI is basically a full duplex interface)

- An optional "setmode_op" call should be added to allow the setting of
baudrate and clock/data relationship (which may differ between different
attached devices)

API between libi2c and high level driver:

- An additional ioctl should be defined to implement a combined
"read_write" call.

- An addition ioctl should be defined to allow the high level driver to
select the proper baudrate and clock/data relationship.

Internals of libi2c:

- libi2c should store the baudrate and clock/data relationship
separately for each high-level driver and apply it to the low level
driver whenever the device is adressed.

- The SPI extension should be documented properly :-)

Any comments concerning my plans?


embedded brains GmbH
Thomas Doerfler           Obere Lagerstr. 30
D-82178 Puchheim          Germany
Tel. : +49-89-18 90 80 79-2
Fax  : +49-89-18 90 80 79-9
email: Thomas.Doerfler at embedded-brains.de
PGP public key available on request

More information about the users mailing list