PaulELong My current setup is that SuperCollider is listening on a digital port.
You mean it's using a Bela Digital pin?
PaulELong 2. The documentation mentions I can disable the digital ports. I think it means you can turn of digital in settings, but I don't believe that means you can do it per GPIO, it's seems like all or nothing?
At the moment, you can only enable/disable all Bela digitals at once.
PaulELong . I believe that is because the C++ app is using the some of the digital IO ports that the browser interface requires
The "browser interface" you are referring to, is it supercollider, as started through the browser?
PaulELong 1. Based on the post, it seems config-pin is based on a virtual cape, which seems to mean it might not be telling me the truth?
The two thing are not correlated. I think
config-pin will always tell you the truth, except if there is a Bela program running, in which case whether the Bela Digital pins are set as inputs or outputs depends from what you write in Sc's
DigitalIO (or more generically, in Bela's audio code), and not what the kernel driver thinks.
There is also someone else that may be confusing. On many SBCs (including BeagleBone and PocketBeagle), a single pin can be assigned to one of many functions, and this is done via the pinmuxer (pin-multiplexer). This is what
config-pin does: it decides whether a given pin should be used for I2C, UART, ... or GPIO! So GPIO, is simply a "mode" of this pin. When you set a pin to GPIO with
config-pin, this will internally connect the pin to the GPIO line.
The pinmuxer also has a setting that is called "Receiver active", that tells whether the pin will be allowed to work as an input.
config-pin also loads the corresponding kernel driver. I am not sure what the default setting is, or if you can specify that manually.
Once the pin is enabled as a GPIO, in order to use it you have to use the
sysfs interface, either directly (e.g.: from the command line, at
/sys/class/gpio), or in C/C++ you can use
GPIOcontrol.cpp, or - as mentioned elsewhere,
the real-time safe
Gpio.h class that builds on top of it. Note: both of these come with the Bela code, but can actually be used stand-alone, e.g.: in your application).
Remember: in order for the pin to be used as an input, the "Receiver active" flag must be enabled in the pinmuxer by
PaulELong Is it possible to publish a list of available ports for the Bela mini?
Third link at this page. Pins with a light blue overlay and a
Dxx mark are Bela's digital pins. Other pins used by Bela are those with a green border and transparent-red filling. What that is missing is that P2.09 and P2.11 are actually assigned to I2C1, on BelaMini and are not under the control of
config-pin. This explains how to give them back to
PaulELong 3. As for setting the in/out via config-pin, on Arduino, you config the direction in your code.
In a Bela program, too (because the pinmux for those pins is already set)! But as you see above, there are two things that needs to happen:
- pinmuxer setting (done by
- GPIO setting (input/output), done via
So, you need to set the pinmuxer settings before you can use the GPIO pin. If you don't like scripting, you have two options:
- reverse engineer what
config-pin does (it probably just reads and writes some files in
/sys/class) and emulate that in C++
system("config-pin ...") (see man page here) from within your C++ program and let it do the job for you!
Further to this:
giuliomoro if you want to apply the solution after reboot, then you normally have to run a script that runs at startup and sets the pins with config-pin for you. Then you can run the script automatically at startup with systemd.
Alternatively, you can create a device-tree overlay that would set the pins you specify. config-pin + systemd is probably the easiest way of doing it.
check out the link at the bottom of this page about how to set up pins at startup https://github.com/BelaPlatform/Bela/wiki/Load-a-device-tree-overlay#config-pin