flipperzero-firmware icon indicating copy to clipboard operation
flipperzero-firmware copied to clipboard

Feature Request: i2c and SPI bridge to USB

Open Patronics opened this issue 3 years ago • 9 comments

Similarly to the USB-UART bridge, it'd be really useful to have an option to use flipper as a i2c device (Ideally both as a master and a slave that shares the memory to the host computer). Similarly a SPI Bridge option would be useful.

Patronics avatar Mar 17 '22 22:03 Patronics

Hi. What protocol do you propose?

skotopes avatar Mar 20 '22 15:03 skotopes

Hmm, I'm not too familiar with the specific options, but perhaps it'd make sense to emulate the FTDI FT232H? It is used for i2c and SPI, in addition to some other protocols like JTAG and UART. If there's another option that's easier to implement that'd be fine too, as long as the functionality of enabling i2c and SPI communication from the computer is available. https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232H.pdf

Patronics avatar Mar 20 '22 16:03 Patronics

@Patronics FTDI is closed source product, it's not very good idea.

skotopes avatar Mar 20 '22 16:03 skotopes

Hmm, what about this open source project? https://github.com/harbaum/I2C-Tiny-USB

Patronics avatar Mar 20 '22 16:03 Patronics

Looks like they have their own protocol and using low level access to USB. Theoretically possible. I think it is a good topic for research, it will be nice to find all available options before implementing it.

skotopes avatar Mar 20 '22 16:03 skotopes

I found another good option, the "Binho Nova Multi-Protocol USB Host Adapter" with a pretty friendly and intuitive (though not open source, sadly) implementation, emulating a UART adapter/virtual com port that implements the other commands internally, so there wouldn't need to be any new drivers on the host device, and it already has integration with python libraries). The ascii interface is documented here: https://support.binho.io/user-guide/ascii-interface.

Patronics avatar Apr 19 '22 03:04 Patronics

Conversion to text and back will be slow. We will add option to work with i2c and spi throw protobuf and provide library to work with it.

skotopes avatar Apr 19 '22 07:04 skotopes

I2C master can (more or less) be implemented in a similar fashion to the i2cget/i2cset/i2cdetect commands on Linux: https://linux.die.net/man/8/i2cdetect That shouldn’t be terribly hard. I2C slave probably can be done by defining static a map of register/value. Not sure how that should work for dynamic data.

tiagogala avatar Jul 14 '22 07:07 tiagogala

https://www.adafruit.com/product/4267

Something like this ? Here is the source:

https://github.com/jamesbowman/i2cdriver

incyi avatar Jul 14 '22 08:07 incyi