I’m developing a hardware project using a Raspberry Pi 4 Compute Module as the platform, and I just ordered a Pisound for testing with a DAC/ADC so that I don’t have to think about the analog circuitry yet. I was wondering, has anyone done any bare metal programming with the Pisound, i.e. without using ALSA or drivers in between? I didn’t see any official documentation related to doing this, apart from the mention of how the DAC/ADC are configured for I2S. What are the steps to take to make this work?
You’d have to somehow gain access to the audio related CPU registers to control the I²S peripheral. See Peripheral specification from BCM2835 - Raspberry Pi Documentation
The main reason I want to do bare metal is that I’m only using Pisound for prototyping, the end product will not ship with Pisound. So instead of depending on drivers being available / writing them for the DAC and ADC chips I end up using, it feels like it would make sense to just skip the middleman and talk directly to them over I2S. If there’s an error in my thinking, corrections are more than welcome, as I’m new to this embedded Linux thing
You’d just use ALSA drivers for ADC / DAC of your choice or if there’s none available, you’ll have to write that part yourself. That would be one off code that you get right one time. Most of your energy will likely go on your actual PCM processing & generation routines which are sufficiently independent from underlying hardware.
Yep that makes sense, thanks for the perspective. Will try using ALSA then.
I have been writing the algorithm prototype on PC with JUCE so I already have the algorithm be completely independent from hardware, so that part’s already covered
@Giedrius Is there any documentation available on Pisound’s usage of the Pi’s GPIO pins? The “Detailed Specs” document doesn’t seem to go into that much detail … Also, is there any functionality of Pisound that’s “expendable”, i.e. will gracefully fail if its pins aren’t available (e.g. audio in, MIDI out, button … as they wouldn’t be needed for use with MiniDexed). The latter would probably be needed, as the number of available GPIO left by Pisound seems lower than what is needed by MiniDexed when using it with the display and rotary encoder.
Unfortunately, I’m not at all experienced when it comes to programming in C, so my main goal here would be to gather information for someone else to actually code Pisound support into MiniDexed
They key GPIOs for audio are the OSR pins which select the sampling rate. See here for what OSR values to use for which rate (Pisound supports only 48kHz, 96kHz and 192kHz). Also the first Reset pin resets the ADC and DAC.
This should be enough for audio functionality, MIDI requires communication via SPI.