Firmware for Digispark Boards to be used as an I²C adapter under Linux.

https://github.com/harbaum/I2C-Tiny-USB/blob/master/digispark
https://github.com/micronucleus/micronucleus/releases

The following commands must be executed as root.

Upload firmware:
micronucleus --run --dump-progress --type intel-hex main.hex

Install I2C Tools and load the kernel driver:
apt install i2c-tools
modprobe i2c-dev

Scan for I2C busses:
root@stefanspc:~# i2cdetect -l
i2c-0  smbus       SMBus I801 adapter at 5040        SMBus adapter
i2c-1  i2c         nvkm-0000:01:00.0-bus-0000        I2C adapter
i2c-2  i2c         nvkm-0000:01:00.0-bus-0001        I2C adapter
i2c-3  i2c         nvkm-0000:01:00.0-bus-0002        I2C adapter
i2c-4  i2c         nvkm-0000:01:00.0-bus-0005        I2C adapter
i2c-5  i2c         nvkm-0000:01:00.0-bus-0006        I2C adapter
i2c-6  i2c         nvkm-0000:01:00.0-bus-0007        I2C adapter
i2c-7  i2c         nvkm-0000:01:00.0-bus-0008        I2C adapter
i2c-8  i2c         nvkm-0000:01:00.0-bus-0009        I2C adapter
i2c-9  i2c         nvkm-0000:01:00.0-aux-000a        I2C adapter
i2c-10  i2c         nvkm-0000:01:00.0-aux-000b        I2C adapter
i2c-11  i2c         nvkm-0000:01:00.0-aux-000c        I2C adapter
i2c-12  i2c         nvkm-0000:01:00.0-aux-000d        I2C adapter
i2c-13  i2c         i915 gmbus dpc                    I2C adapter
i2c-14  i2c         i915 gmbus dpb                    I2C adapter
i2c-15  i2c         i915 gmbus dpd                    I2C adapter
i2c-16  i2c         AUX A/DDI A/PHY A                 I2C adapter
i2c-17  i2c         i2c-tiny-usb at bus 001 device 109  I2C adapter

Check capabilities of the I²C adapter:
root@stefanspc:~# i2cdetect -F 17

Functionalities implemented by /dev/i2c-17:
I2C                              yes
SMBus Quick Command              yes
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               yes
SMBus Block Write                yes
SMBus Block Read                 no
SMBus Block Process Call         no
SMBus PEC                        no
I2C Block Write                  yes
I2C Block Read                   yes

Scan the I2C bus:
root@stefanspc:~# i2cdetect 17

WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-17.
I will probe address range 0x08-0x77.
Continue? [Y/n] Y

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

Send data:
i2cset 17 0x20 0x12 1
This example sends the value 1 to address 0x12 on slave 0x20 at bus 17.

Receive data:
i2cget 17 0x20 0x12 i 5
This example receives 5 bytes from address 0x12 on slave 0x20 at bus 17.
