libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
pruio.bas File Reference

The main source code of the library. More...

#include "pruio_prussdrv.bi"
#include "pruio.bi"
#include "pruio_pins.bi"
#include "pruio_pins_pocket.bi"
#include "pruio_pins_blue.bi"
#include "pruio_pins_sd.bi"
#include "pasm_init.bi"
#include "pasm_run.bi"
#include "dir.bi"
Include dependency graph for pruio.bas:

Go to the source code of this file.

Macros

#define __PRUIO_COMPILING__
 Tell the header pruio.bi that we won't include libpruio.so.
 
#define PMUX_NAME   /* "pruio-" */
 The start of the pinmux-helper folder names in /sys/devices/ocp.*‍/.
 
#define PMUX_ERRR   /* 258 */
 The constant number for no pinmux capability.
 
#define ArrayBytes(_A_)   /* (UBOUND(_A_) + 1) * SIZEOF(_A_(0)) */
 Macro to calculate the total size of an array in bytes.
 
#define BB_NAMES()
 Beaglebone pin name for CPU ball number. More...
 
#define BLUE_NAMES()
 Beaglebone Blue connector pin name for CPU ball number. More...
 
#define POCKET_NAMES()
 Pocketbeagle header pin name for CPU ball number. More...
 

Functions

FUNCTION_CDECL_ALIAS_AS_ANY_PTR memcpy (BYVAL_AS_ANY_PTR, BYVAL_AS_ANY_PTR, BYVAL_AS_ULONG)
 Declaration for C runtime function memcpy().
 
FUNCTION_CDECL_AS_ZSTRING_PTR setPin_save (BYVAL_AS_Pruio__PTR, BYVAL_AS_UInt8, BYVAL_AS_UInt8)
 Set a new pin configuration (internal). More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR setPin_lkm_bb (BYVAL_AS_Pruio__PTR, BYVAL_AS_UInt8, BYVAL_AS_UInt8)
 Set a new pin configuration for BeagleBone boards(internal). More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR setPin_lkm (BYVAL_AS_Pruio__PTR, BYVAL_AS_UInt8, BYVAL_AS_UInt8)
 Set a new pin configuration for Pocket BeagleBone(internal). More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR setPin_dtbo (BYVAL_AS_Pruio__PTR, BYVAL_AS_UInt8, BYVAL_AS_UInt8)
 Pinmuxing for old style device tree multipins (internal). More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR setPin_nogo (BYVAL_AS_Pruio__PTR, BYVAL_AS_UInt8, BYVAL_AS_UInt8)
 Pinmuxing callback for setPin interface (internal). More...
 

Detailed Description

The main source code of the library.

This is the main source code of the library. You may compile it by fbc -dylib pruio.bas to get a small library file (small, because the C wrapper functions are not included as in the original version).

Since
0.0

Definition in file pruio.bas.

Macro Definition Documentation

◆ BB_NAMES

#define BB_NAMES ( )

Beaglebone pin name for CPU ball number.

This macro returns the human readable [2x46 header|connector] pin name wired to a CPU ball number on the Beaglebone (Black, Green, White), if any.

Since
0.6.8

Definition at line 554 of file pruio.bas.

◆ BLUE_NAMES

#define BLUE_NAMES ( )

Beaglebone Blue connector pin name for CPU ball number.

This macro returns the human readable connector pin name wired to a CPU ball number on the Beaglebone Blue, if any.

Since
0.6.8

Definition at line 564 of file pruio.bas.

◆ POCKET_NAMES

#define POCKET_NAMES ( )

Pocketbeagle header pin name for CPU ball number.

This macro returns the human readable 2x36 header pin name wired to a CPU ball number on the PocketBeagle, if any.

Since
0.6.8

Definition at line 574 of file pruio.bas.

Function Documentation

◆ setPin_dtbo()

FUNCTION_CDECL_AS_ZSTRING_PTR setPin_dtbo ( BYVAL_AS_Pruio__PTR  Top,
BYVAL_AS_UInt8  Ball,
BYVAL_AS_UInt8  Mo 
)

Pinmuxing for old style device tree multipins (internal).

Parameters
TopThe PruIo instance.
BallThe CPU ball number (use macros from pruio_pins.bi).
MoThe new modus to set, or PRUIO_PIN_RESET to reset
Returns
Zero on success (otherwise a string with an error message).

Like function setPin_lkm(), this function sets a new pin mode for a CPU ball. Therefor the SysFs files from the OCP pinmux helper are used. That means the pinmux capabilities are handled by the kernel. You have to load an overlay blob and export the pins, before you can set one of the prepared configurations.

The SysFs folder tree changed between kernel versions 3.8 and 4.x. This function handles either of the folder structures. When the desired pin (ball) isn't available in the overlay blob, an error message gets returned, containing the pin number (or CPU ball#) and the missing state.

Since
0.6.0

Definition at line 818 of file pruio_prussdrv.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPin_lkm()

FUNCTION_CDECL_AS_ZSTRING_PTR setPin_lkm ( BYVAL_AS_Pruio__PTR  Top,
BYVAL_AS_UInt8  Ball,
BYVAL_AS_UInt8  Mo 
)

Set a new pin configuration for Pocket BeagleBone(internal).

Parameters
TopThe toplevel PruIo instance.
BallThe CPU ball number (use macros from pruio_pins.bi).
MoThe new modus to set.
Returns
Zero on success (otherwise a string with an error message).

Callback function for PruIo::setPin() interface to set a new pin (or CPU ball) configuration on PocketBeagleBone hardware, using the new style LKM (loadable kernel module) method.

Since the double pins at this hardware are connections between digital and analog pins, no special action is required regarding pinmuxing (as in for BeagleBone hardware).

It's used when the constructor PruIo::PruIo() finds the SysFs entry from the LKM, and has write access (needs administrator privileges = sudo ...). Since

There're no restriction for pinmuxing. Each CPU ball in the range zero to PRUIO_AZ_BALL can get set to any mode. Even claimed pins or CPU balls can get set to defined or undefined modes. The function executes faster than device tree pinmuxing (no OPEN ... CLOSE), boot-time is shorter (no overlay loading) and less memory is used.

Since
0.6.0

Definition at line 665 of file pruio_prussdrv.bas.

Here is the caller graph for this function:

◆ setPin_lkm_bb()

FUNCTION_CDECL_AS_ZSTRING_PTR setPin_lkm_bb ( BYVAL_AS_Pruio__PTR  Top,
BYVAL_AS_UInt8  Ball,
BYVAL_AS_UInt8  Mo 
)

Set a new pin configuration for BeagleBone boards(internal).

Parameters
TopThe toplevel PruIo instance.
BallThe CPU ball number (use macros from pruio_pins.bi).
MoThe new modus to set.
Returns
Zero on success (otherwise a string with an error message).

Callback function for PruIo::setPin() interface to set a new pin (or CPU ball) configuration on BeagleBone hardware (Black, BlackWireless, Green, White), using the new style LKM (loadable kernel module) method.

Since this hardware has some digital header pins with double CPU ball connections, both CPU balls have to be set. First, the unused CPU ball gets configured to gpio input mode without pull-up/pull-down resistor, before the other pin gets set to the desired mode.

Since
0.6.4

Definition at line 700 of file pruio_prussdrv.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPin_nogo()

FUNCTION_CDECL_AS_ZSTRING_PTR setPin_nogo ( BYVAL_AS_Pruio__PTR  Top,
BYVAL_AS_UInt8  Ball,
BYVAL_AS_UInt8  Mo 
)

Pinmuxing callback for setPin interface (internal).

Parameters
TopThe PruIo instance.
BallThe CPU ball number (use macros from pruio_pins.bi).
MoThe new modus to set, or PRUIO_PIN_RESET to reset
Returns
A string with an error message.

This function is a dummy for the setPin interface in PruIo structure. It gets used when no pinmuxing capability was found on the system: neither a universal device tree overlay was loaded, nor the loadable kernel module is available (may be loaded, but no administrator privileges). The function does nothing, but returns an error message.

Since
0.6.0

Definition at line 789 of file pruio_prussdrv.bas.

Here is the caller graph for this function:

◆ setPin_save()

FUNCTION_CDECL_AS_ZSTRING_PTR setPin_save ( BYVAL_AS_Pruio__PTR  Top,
BYVAL_AS_UInt8  Ball,
BYVAL_AS_UInt8  Mo 
)

Set a new pin configuration (internal).

Parameters
TopThe PruIo instance.
BallThe CPU ball number (use macros from pruio_pins.bi).
MoThe new modus to set, or PRUIO_PIN_RESET to reset
Returns
Zero on success (otherwise a string with an error message).

Callback function for the PruIo::setPin() interface. It's a wrapper around setPin_lkm() functions, that checks the pin claiming of the kernel first. Only mode changes for unclaimed pins (or CPU balls) get executed.

Claims from the kernel get fetched once by calling the function with an invalid Ball parameter (> PRUIO_AZ_BALL). This gets executed by the constructor PruIo::PruIo(). The function doesn't notice changes in kernel claiming at runtime. You can re-fetch the claims when needed.

Since
0.6.0

Definition at line 752 of file pruio_prussdrv.bas.

Here is the call graph for this function:
Here is the caller graph for this function: