Close

Source uploaded

A project log for /dev/analog0

Primitive analog output device for a Raspberry Pi.

Steven ClarkSteven Clark 08/30/2017 at 21:120 Comments

I finally got around to uploading the actual source file here.  It's analog2.c because halfway through I decided I wasn't going to be sure I could get myself hooked into the interrupt controller and rewrote it to use the newer high-resolution timer system in the kernel.  The final version also has runs a clock-in pin for an Analog Devices DAC chip instead of a SIP resistor ladder or homebrew R2R network.  Either of those would still work, there'd just be an extra pin getting uselessly twiddled.

Once compiled and inserted a /dev/analog0 device should appear.  Writing a bytes to it will fill a buffer up to 1MB which will then be clocked out to 8 sequential pins of the GPIO at 22,050hz until the final byte is reached and held.  Writing one byte (on a system with no DC offset filter) should therefore just set an analog value on the DAC, while writing multiple bytes should play 8-bit mono audio (a DC offset filter is recommended in this case).

Discussions