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

Source code for kernel driver handling. More...

#include "dir.bi"
#include "pruio_prussdrv.bi"
#include "pruio_boardpins.bi"
Include dependency graph for pruio_prussdrv.bas:

Go to the source code of this file.

Macros

#define PAGE_SIZE   /* 4096 */
 The page size for memory maps.
 
#define PRU_INTC_GER_REG   /* &h010 */
 Global interrupt enable register.
 
#define PRU_INTC_HIEISR_REG   /* &h034 */
 Host interrupt enable indexed set register.
 
#define PRU_INTC_SRSR0_REG   /* &h200 */
 System event status register 0-31.
 
#define PRU_INTC_SRSR1_REG   /* &h204 */
 System event status register 32-63.
 
#define PRU_INTC_SECR0_REG   /* &h280 */
 System event enable/clear register 0-31.
 
#define PRU_INTC_SECR1_REG   /* &h284 */
 System event enable/clear register 32-63.
 
#define PRU_INTC_ESR0_REG   /* &h300 */
 System event enable set register 0-31.
 
#define PRU_INTC_ESR1_REG   /* &h304 */
 System event enable set register 0-31.
 
#define PRU_INTC_CMR0_REG   /* &h400 */
 The channel map register.
 
#define PRU_INTC_HMR0_REG   /* &h800 */
 Host interrupt map register, channels 0 to 3.
 
#define PRU_INTC_SIPR0_REG   /* &hD00 */
 System event polarity register, events 0 to 31.
 
#define PRU_INTC_SIPR1_REG   /* &hD04 */
 System event polarity register, events 32 to 63.
 
#define PRU_INTC_SITR0_REG   /* &hD80 */
 System event type register, events 0 to 31.
 
#define PRU_INTC_SITR1_REG   /* &hD84 */
 System event type register, events 31 to 63.
 
#define MAX_HOSTS_SUPPORTED   /* 10 */
 The maximal number of host events.
 
#define PRUSS_UIO_PARAM_VAL_LEN   /* 20 */
 The size of the read buffer.
 
#define KERNEL_PINMUX_PINS   /* "/sys/kernel/debug/pinctrl/44e10800.pinmux/pinmux-pins" */
 The file with pinmux information.
 
#define KERNEL_PINMUX_PINX   /* "/sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pinmux-pins" */
 Alternative file with pinmux information.
 
#define O_ACCMODE   /* &o003 */
 File acess mode.
 
#define O_RDONLY   /* &o0 */
 File read only mode.
 
#define O_WRONLY   /* &o1 */
 File write only mode.
 
#define O_RDWR   /* &o2 */
 File read/write mode.
 
#define O_CREAT   /* &o100 ' Not fcntl. */
 File create mode.
 
#define O_EXCL   /* &o200 ' Not fcntl. */
 Fail if file exists.
 
#define O_NOCTTY   /* &o400 ' Not fcntl. */
 No tty mode.
 
#define O_TRUNC   /* &o1000 ' Not fcntl. */
 File truncate to 0.
 
#define O_APPEND   /* &o2000 */
 File append mode.
 
#define O_NONBLOCK   /* &o4000 */
 File non blocking mode.
 
#define O_NDELAY   /* O_NONBLOCK */
 File no delay mode.
 
#define O_SYNC   /* &o4010000 */
 File write IO mode.
 
#define PROT_READ   /* &h1 ' */
 Page can be read.
 
#define PROT_WRITE   /* &h2 */
 Page can be written.
 
#define PROT_EXEC   /* &h4 */
 Page can be executed.
 
#define PROT_NONE   /* &h0 */
 Page can not be accessed.
 
#define PROT_GROWSDOWN   /* &h01000000 */
 Extend change to start of growsdown vma (mprotect only)
 
#define PROT_GROWSUP   /* &h02000000 */
 Extend change to start of growsup vma (mprotect only)
 
#define MAP_SHARED   /* &h01 */
 Share changes.
 
#define MAP_PRIVATE   /* &h02 */
 Changes are private.
 
#define MAP_TYPE   /* &h0f */
 Mask for type of mapping.
 

Typedefs

typedef UInt32 size_t
 The size type.
 
typedef Int32 ssize_t
 The signed size type.
 
typedef Int32 off_t
 The offset type.
 
typedef ANY_PTR addr_t
 The adress type.
 
typedef UInt8_PTR caddr_t
 The character adress type.
 

Functions

FUNCTION_CDECL_ALIAS_AS_caddr_t mmap (BYVAL_AS_addr_t, BYVAL_AS_size_t, BYVAL_AS_Int32, BYVAL_AS_Int32, BYVAL_AS_Int32, BYVAL_AS_off_t)
 Internal: declaration for C runtime function mmap().
 
FUNCTION_CDECL_ALIAS_AS_ANY_PTR memcpy (BYVAL_AS_ANY_PTR, BYVAL_AS_ANY_PTR, BYVAL_AS_size_t)
 Internal: declaration for C runtime function memcpy().
 
FUNCTION_CDECL_ALIAS_AS_Int32 munmap (BYVAL_AS_ANY_PTR, BYVAL_AS_size_t)
 Internal: declaration for C runtime function munmap().
 
FUNCTION_CDECL_ALIAS_AS_Int32 open_ (BYVAL_AS_CONST_ZSTRING_PTR, BYVAL_AS_Int32,...)
 Internal: declaration for C runtime function open().
 
FUNCTION_CDECL_ALIAS_AS_ssize_t read_ (BYVAL_AS_Int32, BYVAL_AS_ANY_PTR, BYVAL_AS_size_t)
 Internal: declaration for C runtime function read().
 
FUNCTION_CDECL_ALIAS_AS_Int32 close_ (BYVAL_AS_Int32)
 Internal: declaration for C runtime function close().
 
SUB_CDECL __prussintc_set_cmr (BYVAL_AS_UInt32_PTR Intc, BYVAL_AS_UInt16 Event, BYVAL_AS_UInt16 Ch)
 Internal: set CMR register. More...
 
SUB_CDECL __prussintc_set_hmr (BYVAL_AS_UInt32_PTR Intc, BYVAL_AS_UInt16 Ch, BYVAL_AS_UInt16 Host)
 Internal: set HMR register. More...
 
FUNCTION_CDECL_AS_Int32 __prussdrv_memmap_init (BYVAL_AS_Int32 IrqFd)
 Internal: initialize memory pointers. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_open (BYVAL_AS_UInt32 Irq)
 Open an kernel driver interrupt file. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_enable (BYVAL_AS_UInt32 PruId, BYVAL_AS_UInt32 PCnt=0)
 Enable one PRU subsystem. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_disable (BYVAL_AS_UInt32 PruId)
 Disable one PRU. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_reset (BYVAL_AS_UInt32 PruId)
 Reset one PRU. More...
 
FUNCTION_CDECL_ALIAS_AS_ZSTRING_PTR prussdrv_pru_resume (BYVAL_AS_UInt32 PruId)
 Resume one PRU. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_write_memory (BYVAL_AS_UInt32 RamId, BYVAL_AS_UInt32 Offs, BYVAL_AS_CONST_UInt32_PTR Dat, BYVAL_AS_UInt32 Size)
 Write data to PRUSS memory. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pruintc_init (BYVAL_AS_CONST_tpruss_intc_initdata_PTR DatIni)
 Initialize the interrupt controller. More...
 
SUB_CDECL_ALIAS prussdrv_pru_send_event (BYVAL_AS_UInt32 Event)
 Send a system event to PRUSS. More...
 
FUNCTION_CDECL_ALIAS_AS_UInt32 prussdrv_pru_wait_event (BYVAL_AS_UInt32 Irq)
 Wait for an event. More...
 
SUB_CDECL_ALIAS prussdrv_pru_clear_event (BYVAL_AS_UInt32 Irq, BYVAL_AS_UInt32 Event)
 Clear a pending system event. More...
 
SUB_CDECL_ALIAS prussdrv_map_extmem (BYVAL_AS_ANY_PTR_PTR Addr)
 Map external ram (ERam). More...
 
FUNCTION_CDECL_ALIAS_AS_UInt32 prussdrv_extmem_sIze ()
 Get size of external memory. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_map_prumem (BYVAL_AS_UInt32 RamId, BYVAL_AS_ANY_PTR_PTR Addr)
 Adress pointer mapping. More...
 
FUNCTION_CDECL_ALIAS_AS_UInt32 prussdrv_get_phys_addr (BYVAL_AS_CONST_ANY_PTR Addr)
 Compute physical adress. More...
 
SUB_CDECL_ALIAS prussdrv_exIt ()
 End the driver session. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR find_claims (BYVAL_AS_UInt32 Typ)
 Fetch pinmuxing claims from kernel. More...
 
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). More...
 
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). More...
 
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). More...
 
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). More...
 
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). More...
 

Variables

tprussdrv PRUSSDRV
 The data structure, global at module level.
 

Detailed Description

Source code for kernel driver handling.

In previous versions libpruio was dependant on libprussdrv, a driver library for the uio_pruss kernel module. Since this driver isn't available in the upstream Debian repositories, compiling from source was required for users. Once I started to fix some downsides in the original library code, I came up with this code here, reduced to the bare minimum and mostly compatible to the original API. Find further information on the PRUSS, the pasm assembler and the original prussdrv function in the am335x_pru_package at GitHub.

In the second part the utility functions for the new loadable kernel module are included.

Since
0.6

Definition in file pruio_prussdrv.bas.

Function Documentation

◆ __prussdrv_memmap_init()

FUNCTION_CDECL_AS_Int32 __prussdrv_memmap_init ( BYVAL_AS_Int32  IrqFd)

Internal: initialize memory pointers.

Returns
0 (zero) on success, otherwise a negative error number.

This internal function reads the files from uio_pruss kernel driver and computes pointers to the different memory areas. In contrast to the original libprussdrv code, the function here gets called only once.

Since
0.6

Definition at line 189 of file pruio_prussdrv.bas.

Here is the caller graph for this function:

◆ __prussintc_set_cmr()

SUB_CDECL __prussintc_set_cmr ( BYVAL_AS_UInt32_PTR  Intc,
BYVAL_AS_UInt16  Event,
BYVAL_AS_UInt16  Ch 
)

Internal: set CMR register.

Parameters
IntcThe interrupt controller number.
EventThe event number.
ChThe channel to set

This is an internal service function.

Since
0.6

Definition at line 158 of file pruio_prussdrv.bas.

Here is the caller graph for this function:

◆ __prussintc_set_hmr()

SUB_CDECL __prussintc_set_hmr ( BYVAL_AS_UInt32_PTR  Intc,
BYVAL_AS_UInt16  Ch,
BYVAL_AS_UInt16  Host 
)

Internal: set HMR register.

Parameters
IntcThe interrupt controller number.
ChThe channel to set
HostThe host number.

This is an internal service function.

Since
0.6

Definition at line 173 of file pruio_prussdrv.bas.

Here is the caller graph for this function:

◆ find_claims()

FUNCTION_CDECL_AS_ZSTRING_PTR find_claims ( BYVAL_AS_UInt32  Typ)

Fetch pinmuxing claims from kernel.

Returns
A structure containing pin array and names of owners (or zero in case of failure)

The function greps the kernel claim for CPU balls by parsing the output from /sys/kernel/debug/pinctrl/44e10800.pinmux/pinmux-pins. Free and claimed CPU balls (named pins by kernel) get identified, and the owners of claimed balls get collected in a STRING variable in a condensed form. Each owner name is stored only once, no double entries.

Since
0.6.0

Definition at line 599 of file pruio_prussdrv.bas.

Here is the caller graph for this function:

◆ prussdrv_exIt()

SUB_CDECL_ALIAS prussdrv_exIt ( )

End the driver session.

The procedure unmaps all memory and closes all interrupt files.

Note
It doesn't disable the PRUSS.
Since
0.6

Definition at line 576 of file pruio_prussdrv.bas.

◆ prussdrv_extmem_sIze()

FUNCTION_CDECL_ALIAS_AS_UInt32 prussdrv_extmem_sIze ( )

Get size of external memory.

Returns
The memory size.

The procedure returns the size of the external memory. The kernel driver uio_pruss allocates a block of coherent memory. This function returns the size if this block. See section ERam for details.

Since
0.6

Definition at line 517 of file pruio_prussdrv.bas.

Here is the caller graph for this function:

◆ prussdrv_get_phys_addr()

FUNCTION_CDECL_ALIAS_AS_UInt32 prussdrv_get_phys_addr ( BYVAL_AS_CONST_ANY_PTR  Addr)

Compute physical adress.

Parameters
AddrMemory pointer or mmap value
Returns
The physical Addr associated with the mmap value input if successful, otherwise 0 (zero).

The function computes the physical adress from a prussdrv memory pointer or from an value returned form a mmap() call.

Since
0.6

Definition at line 556 of file pruio_prussdrv.bas.

◆ prussdrv_map_extmem()

SUB_CDECL_ALIAS prussdrv_map_extmem ( BYVAL_AS_ANY_PTR_PTR  Addr)

Map external ram (ERam).

Parameters
AddrThe pointer to set.

The procedure maps the external memory allocated by the uio_pruss kernel driver to pointer parameter. Memory is then accessed by an array.

Since
0.6

Definition at line 503 of file pruio_prussdrv.bas.

◆ prussdrv_map_prumem()

FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_map_prumem ( BYVAL_AS_UInt32  RamId,
BYVAL_AS_ANY_PTR_PTR  Addr 
)

Adress pointer mapping.

Parameters
RamIdThe memory ID.
AddrThe pointer to set.
Returns
0 (zero) on success, otherwise -1.

The procedure maps PRU memory (DRAM, IRAM, SHARED) to the pointer parameter. Memory is then accessed by an array.

Note
Call this function after the prussdrv_open() function. Minimum one event needs to be opened to access memory map.
Since
0.6

Definition at line 535 of file pruio_prussdrv.bas.

◆ prussdrv_open()

FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_open ( BYVAL_AS_UInt32  Irq)

Open an kernel driver interrupt file.

Parameters
IrqThe interrupt number.
Returns
0 (zero) on success, otherwise a negative error number

The function tries to open an interrupt file dev/uio[0-7], corresponding to Host[2-9] of the PRU INTC. In case of a problem a negative error number gets returned.

At least one call to that function is mandatory, since it initializes the memory. Call it again for each interrupt you need. A single call to prussdrv_exIt() closes all open files.

Since
0.6

Definition at line 250 of file pruio_prussdrv.bas.

Here is the call graph for this function:

◆ prussdrv_pru_clear_event()

SUB_CDECL_ALIAS prussdrv_pru_clear_event ( BYVAL_AS_UInt32  Irq,
BYVAL_AS_UInt32  Event 
)

Clear a pending system event.

Parameters
IrqThe host interrupt.
EventThe system event.

The procedure clears an event, previously sent from PRU to ARM. Once a system event occurs, the registers have to get released, in order to get ready for the next event.

Since
0.6

Definition at line 487 of file pruio_prussdrv.bas.

◆ prussdrv_pru_disable()

FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_disable ( BYVAL_AS_UInt32  PruId)

Disable one PRU.

Parameters
PruIdThe PRUSS number.
Returns
0 (zero) in case of success, otherwise -1

The function disables a PRU subsystem by stopping its clock.

Since
0.6

Definition at line 292 of file pruio_prussdrv.bas.

◆ prussdrv_pru_enable()

FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_enable ( BYVAL_AS_UInt32  PruId,
BYVAL_AS_UInt32  PCnt = 0 
)

Enable one PRU subsystem.

Parameters
PruIdThe PRU number.
PCntThe byte adress where to start (defaults to 0 = zero).
Returns
0 (zero) in case of success, otherwise -1

The function enables a PRU subsystem by starting its clock. Parameter PCnt specifies a byte address where to start, as used in function prussdrv_pru_write_memory().

Note
When the PASM code contains .origin 7 the matching PCnt value is 28 = 7 * 4.
Since
0.6

Definition at line 274 of file pruio_prussdrv.bas.

◆ prussdrv_pru_reset()

FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_reset ( BYVAL_AS_UInt32  PruId)

Reset one PRU.

Parameters
PruIdThe PRUSS number.
Returns
0 (zero) in case of success, otherwise -1

The function forces a reset at a PRU subsystem by writing 0 (zero) to the control register.

Since
0.6

Definition at line 309 of file pruio_prussdrv.bas.

◆ prussdrv_pru_resume()

FUNCTION_CDECL_ALIAS_AS_ZSTRING_PTR prussdrv_pru_resume ( BYVAL_AS_UInt32  PruId)

Resume one PRU.

Parameters
PruIdThe PRUSS number.
Returns
0 (zero) in case of success, otherwise -1

The function restarts a PRUSS after SLP 1 or HALT command. The PRU re-starts executing the next instruction.

Since
0.6.6

Definition at line 326 of file pruio_prussdrv.bas.

◆ prussdrv_pru_send_event()

SUB_CDECL_ALIAS prussdrv_pru_send_event ( BYVAL_AS_UInt32  Event)

Send a system event to PRUSS.

Parameters
EventThe interrupt number to send.

The procedure sets the interrupt registers to send an event to the PRUSS.

Since
0.6

Definition at line 454 of file pruio_prussdrv.bas.

◆ prussdrv_pru_wait_event()

FUNCTION_CDECL_ALIAS_AS_UInt32 prussdrv_pru_wait_event ( BYVAL_AS_UInt32  Irq)

Wait for an event.

Parameters
IrqThe event number to wait for.
Returns
The kernel counter for the event number.

The function blocks the calling thread until the corresponding event input occurs.

Since
0.6

Definition at line 470 of file pruio_prussdrv.bas.

◆ prussdrv_pru_write_memory()

FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_write_memory ( BYVAL_AS_UInt32  RamId,
BYVAL_AS_UInt32  Offs,
BYVAL_AS_CONST_UInt32_PTR  Dat,
BYVAL_AS_UInt32  Size 
)

Write data to PRUSS memory.

Parameters
RamIdThe ID of the memory.
OffsThe offset to start at.
DatA pointer to the data.
SizeThe size of data in bytes.
Returns
The number of bytes written, or -1 in case of failure

The function writes a chunk of data to PRUSS memory (DRam, IRam or SRam), depending on parameter RamId. The start writing position gets specified by parameter Offs.

Since
0.6

Definition at line 350 of file pruio_prussdrv.bas.

◆ prussdrv_pruintc_init()

FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pruintc_init ( BYVAL_AS_CONST_tpruss_intc_initdata_PTR  DatIni)

Initialize the interrupt controller.

Parameters
DatIniData structure to initialize
Returns
0 (zero) on success, otherwise -1

The function initializes and enables the PRU interrupt controller. The input is a structure of arrays that determine which system events are enabled and how each is mapped to a host event. This structure is pre-defined as a member variable PTR PruIo::IntcInit in header file src/pruio/pruio.bi. Experts can adapted the default arrays to meet custom needs before the CTOR PruIo::PruIo() call, but note that wrong settings can cause serious malfunctions.

Since
0.6

Definition at line 385 of file pruio_prussdrv.bas.

Here is the call graph for this function:

◆ 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: