[RFC] Driver for Arduino-as-I2C-adapter
Hi, For a project I needed to communicate with external hardware via the I2C protocol. I took a look at the existing drivers in the linux kernel source "drivers/i2c/busses". Instead of buying yet another interface dongle (this time for I2C) I decided to use an Arduino with an apropriate sketch as I2C adapter. Currently I access the I2C adapter (Arduino) via a custom program reading/writing to /dev/ttyACM0. Do you think it would make sense to add an I2C driver to the Linux kernel for an "Arduino as I2C adapter" solution? Or could you propose another solution? Maybe just an "external" module like the nvidia kernel module? greetings, Bernhard -- Wer nicht gelegentlich auch einmal kausalwidrige Dinge zu denken vermag, wird seine Wissenschaft nie um eine neue Idee bereichern können. Max Planck (1858-1947) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [RFC] Driver for Arduino-as-I2C-adapter
Hi, On 2015-05-18 15:00, Alex Beregszaszi wrote: There are many cheap I2C adapter projects (mostly USB though). One of the simple ones (i2c-tiny-usb) is included in the kernel [...] I knew of the OpenSource project i2c-tiny-usb. But sadly the hardware ist not sold anywhere (At least I didn't find vendors). As regarding to cheap serial line based adapters, there are two I have seen before [...] None of them seems to have kernel drivers available. So I could stick to my own homebrewn Arduino solution. I am afraid handling serial devices within a i2c kernel driver might be tricky and purists probably dislike the idea. Currently there is at least one driver for such a case already in the kernel: drivers/i2c/busses/i2c-taos-evm.c I found it by "grep serio.h" in i2c/busses/. But this driver rather only supports SMBus which is kind of subset of I2C. Or you could call it I2C with more strict requirements upon timing and protocol. In fact this would have been the driver I would have based my work on if someone said: Go on, this is a good thing to include in the kernel. But for now I think I will just publish the Arduino sketch and a sample implementation on how to access I2C devices with it. greetings, Bernhard -- Wer nicht gelegentlich auch einmal kausalwidrige Dinge zu denken vermag, wird seine Wissenschaft nie um eine neue Idee bereichern können. Max Planck (1858-1947) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [RFC] Driver for Arduino-as-I2C-adapter
Hi Alex, On 2015-05-19 14:20, Alex Beregszaszi wrote: So I sat down and wrote an Arduino implementation of that specification just to see what the performance would be. You can find it at: https://github.com/axic/dtiic I already took a look at the robot-electronics.co.uk link yesterday. I wasn't very fond of the serial protocol. It seems they implemented some kind of timeout which determines the start and end of a message. Quote: http://www.robot-electronics.co.uk/htm/usb_iss_i2c_tech.htm "A gap will result in the USB-ISS re-starting its internal command synchronization loop and ignoring the message." Hence my implementation uses as ERROR character. Whenever one of the devices PC/Arduino looses sync or notices another problem it sends an on to the serial line (0x1B). The character is even valid through data transfers. This requires a literal character to get escaped somehow. For this reason I introduced a quoting character (indeed it is an escape character - maybe I should use another character than for signaling an error). The quoting character (currently '\') can quote itself and the character. Every other combination of '\' and another character is invalid and causes the other end to send (error). I don't know if this protocol is clever but it can get implemented using a layered approach and synchronization can get achieved without the need of other lines. Using the escaped mechanism also software flow control like XON/XOFF could get implemented: http://en.wikipedia.org/wiki/Software_flow_control (I didn't knew Xon was a Star Trek character :) Here a link to my current Arduino sketch: https://gist.github.com/kraftb/8c0bbcc35a9778608d74 I think to create a nice and useful sketch the communication would have to get a layer for supporting different client side (Arduino) features (I2C, SPI, GPIO). Is it a problem that we discuss this issue here? I see mostly patches going around. If someone feels annoyed please post and we move to some other list. greetings, Bernhard -- Wer nicht gelegentlich auch einmal kausalwidrige Dinge zu denken vermag, wird seine Wissenschaft nie um eine neue Idee bereichern können. Max Planck (1858-1947) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel