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

Header file for kernel drivers. More...

#include "pruio.bi"
Include dependency graph for pruio_prussdrv.bi:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  __prussdrv
 Date structure for uio_pruss userspace part. More...
 

Typedefs

typedef __prussdrv tprussdrv
 Forward declaration for uio_pruss data.
 

Functions

FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_open (BYVAL_AS_UInt32)
 Open an kernel driver interrupt file. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_enable (BYVAL_AS_UInt32, BYVAL_AS_UInt32)
 Enable one PRU subsystem. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_disable (BYVAL_AS_UInt32)
 Disable one PRU. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_reset (BYVAL_AS_UInt32)
 Reset one PRU. More...
 
FUNCTION_CDECL_ALIAS_AS_ZSTRING_PTR prussdrv_pru_resume (BYVAL_AS_UInt32)
 Resume one PRU. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pru_write_memory (BYVAL_AS_UInt32, BYVAL_AS_UInt32, BYVAL_AS_CONST_UInt32_PTR, BYVAL_AS_UInt32)
 Write data to PRUSS memory. More...
 
FUNCTION_CDECL_ALIAS_AS_Int32 prussdrv_pruintc_init (BYVAL_AS_CONST_tpruss_intc_initdata_PTR)
 Initialize the interrupt controller. More...
 
SUB_CDECL_ALIAS prussdrv_pru_send_event (BYVAL_AS_UInt32)
 Send a system event to PRUSS. More...
 
FUNCTION_CDECL_ALIAS_AS_UInt32 prussdrv_pru_wait_event (BYVAL_AS_UInt32)
 Wait for an event. More...
 
SUB_CDECL_ALIAS prussdrv_pru_clear_event (BYVAL_AS_UInt32, BYVAL_AS_UInt32)
 Clear a pending system event. More...
 
SUB_CDECL_ALIAS prussdrv_map_extmem (BYVAL_AS_ANY_PTR_PTR)
 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, BYVAL_AS_ANY_PTR_PTR)
 Adress pointer mapping. More...
 
FUNCTION_CDECL_ALIAS_AS_UInt32 prussdrv_get_phys_addr (BYVAL_AS_CONST_ANY_PTR)
 Compute physical adress. More...
 
SUB_CDECL_ALIAS prussdrv_exIt ()
 End the driver session. More...
 

Detailed Description

Header file for kernel drivers.

The header contains declarations to bind the user space part of the kernel drivers. Two loadable kernel modules are in use, named:

  • uio_pruss
  • libpruio

The first controls memory mapping and interrupt handling, the second supports pinmuxing and PWM features.

Since
0.6

Definition in file pruio_prussdrv.bi.

Function Documentation

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