No, this cannot be done from the Bela API. In fact, the Bela API allows you to access the GPIO registers, but the pullup-pulldown is a property of the pin, as set by the pinmuxer, and NOT of the GPIO itself.
As to how you set the pu/pd: on the current Bela image you DO have to deal with dtb / dtbo files.
The way some of the pins are set currently on Bela, it is a bit of a hacky way (for no particular reason, except that it is the way it was done in the first place).
This file is the source of the
dtb (device tree blob) that is loaded on Bela at startup. Lines 64/65 set "GPIOrt" pins (those GPIOs that are addressed by Bela). For each pair of hex values, e.g.:
0x90 0x27, the first is the pin offset and the second is the pin setting.
Have a look at the pinouts for P8 and P9
- the offset is the value after the
/ in the third column
- the setting value is composed of the
- mode (bits 2-0), which tells you which of the (up to) 8 modes (as detailed in the "Mode x" columns) the pin is set to (e.g.: GPIO/mcasp/i2c/PRUgpio)
- pin settings (bits 6-3), which set slew control, output enabled and your pullup/pulldown. (see table at the bottom right of the documents)
So, for the
0x90 0x27, it is:
0x90 is P8_07
- bits (2-0) are
111 (mode 7, gpio2)
- bits (6-3) are
0100 (cf table at the bottom right):
- slew control fast
- receiver active: enable
- pullup/pulldown: pulldown select
- enable pullup/pulldown: enabled
If you want to change the default values, the proper way is using device tree overlays. The hacky way is editing the
dts file linked to above, then use the
dtc (device tree compiler) which is installed on the board and run:
dtc am335x-boneblack.dts > /boot/uboot/dtbs/am335x-boneblack.dtb
Make sure you keep a copy of the existing
/boot/uboot/dtbs/am335x-boneblack.dtb (it's in the repo, anyhow), because if you screw something up, then the BBB will not boot at all, but still you can place the SD card in your computer and revert back to the original
am335x-boneblack.dtb, as it lives in the FAT32 partition which shows up on your host if you put the SD card into its reader.