This circuit uses the general purpose microcontroller PIC32MX250 to read audio data from an Android device and to output a corresponding SPDIF audio stream over an SPI port.
The SPDIF bitstream is generated in software. As a consequence, no special encoder chip is needed. An optical SPDIF transmitter can directly connected to the SPI/I2S port of the microcontroller.
In contrast to many USB audio dongles made for personal computers, this circuit behaves as an USB host (as opposed to an USB device). In the Android documentation, this is referred to as "Host Mode", see https://source.android.com/devices/audio/usb. Using the host mode allows to power the Android device by simply applying 5V to the USB port.
A working prototype has been made using a small breadboard as shown on the project picture. On the bottom of the project picture you can see the USB port to which the Android device is connected. At the top of the picture, the optical SPDIF transmitter is shown.
In addition, an IR receiver (bottom left of the picture) has been added so that a few control commands (skip and pause) can received from an IR remote control and forwarded to the Android devices (may not work when the device is screen locked).
The SPDIF part of the software running on the microcontroller has been written by myself. For the USB related part, driver software developed by Microchip has been used. No special software is required to be installed on the Android device.
I have tested this circuit with multiple Android devices and a simple "home-brewed" SPDIF-receiver. Tests with more complex home entertainment devices (AV receivers, etc.) are still need to be done.
I built this circuit because I wanted to try out such a software SPDIF encoder. In addition, I need an audio output that is better in quality than the headphone jack. I share this circuit here to see if there is some interest in such an audio interface.