libpruio  0.0
AM33xx-PRU driver for digital input / output and analog input
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pruio_c_wrapper.h File Reference

The main header code of the C wrapper for libpruio. More...

#include "prussdrv.h"
#include "pruss_intc_mapping.h"
Include dependency graph for pruio_c_wrapper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  AdcSteps
 user defined type for a step setting More...
 
class  GpioSet
 user defined type for a GPIO setting More...
 
class  PruIo
 user defined type (class) for the driver structure More...
 

Macros

#define PRUIO_BALL_AZ   109
 
#define PRUIO_BALL_OFFS   256
 
#define PRUIO_GPIO_AZ   3
 
#define PRUIO_GPIO_OFFS   64
 
#define PRUIO_GPIO_DATA   24
 
#define PRUIO_GPIO_BLCK   32
 
#define PRUIO_ADC_OFFS   512
 
#define PRUIO_ADC_DATA   228
 
#define PRUIO_ADC_EMPTY   12
 
#define PRUIO_ADC_BUFF   16
 
#define PRUIO_TRG_PARA   4
 
#define PRUIO_IRPT   25
 
#define PRUIO_MSG_INIT_OK   4294967295
 
#define PRUIO_MSG_EXIT_OK   4294967294
 
#define PRUIO_MSG_ADC_ERRR   4294967293
 
#define PRUIO_MSG_IO_OK   4294967292
 
#define PRUIO_MSG_MM_WAIT   4294967291
 
#define PRUIO_MSG_MM_TRG1   4294967290
 
#define PRUIO_MSG_MM_TRG2   4294967289
 
#define PRUIO_MSG_MM_TRG3   4294967288
 
#define PRUIO_MSG_MM_TRG4   4294967287
 
#define AM33XX
 tell pruss_intc_mapping.bi that we use ARM33xx More...
 
#define PRUIO_CHAN   CHANNEL5
 the PRUSS driver library More...
 
#define PRUIO_MASK   PRU_EVTOUT5_HOSTEN_MASK
 the mask to enable PRU interrupts (must match PRUIO_IRPT) More...
 
#define PRUIO_EMAP   PRU_EVTOUT5
 the event for PRU messages (mapping, must match PRUIO_IRPT) More...
 
#define PRUIO_EVNT   PRU_EVTOUT_5
 the event for PRU messages (must match PRUIO_IRPT) More...
 
#define PRUIO_DEF_AVRAGE   4
 the default setting for avaraging More...
 
#define PRUIO_DEF_ODELAY   183
 the default value for open delay in channel settings More...
 
#define PRUIO_DEF_SDELAY   0
 the default value for sample delay in channel settings More...
 
#define PRUIO_DEF_PRUSS   1
 the default PRU subsystem to use More...
 
#define PRUIO_DEF_SAMPLS   0
 the default number of samples to use (configures single mode) More...
 
#define PRUIO_DEF_STPMSK   0x1FE /* &b111111110 */
 the default step mask (steps 1 to 8 for AIN0 to AIN7, no charge step) More...
 
#define PRUIO_DEF_TIMERV   0
 the default timer value (sampling rate) More...
 
#define PRUIO_DEF_LSLMOD   4
 the default bit mode (4 = 16 bit encoding) More...
 
#define PRUIO_DEF_CLKDIV   0
 the default clock divisor (0 = full speed AFE = 2.4 MHz) More...
 
#define PRUIO_IN   0x2F /* &b00101111 */
 convenience macro to configure an input pin without pullup or pulldown More...
 
#define PRUIO_IN_0   0x27 /* &b00100111 */
 convenience macro to configure an low input pin (with pulldown resistor) More...
 
#define PRUIO_IN_1   0x37 /* &b00110111 */
 convenience macro to configure an high input pin (with pullup resistor) More...
 
#define PRUIO_OUT0   0xF /* &b00001111 */
 convenience macro to configure an output pin initial low More...
 
#define PRUIO_OUT1   0x8F /* &b10001111 */
 convenience macro to configure an output pin initial high More...
 
#define PRUIO_PIN_RESET   0xFF /* &b11111111 */
 convenience macro to re-configure a pin to its original (initial) state More...
 

Typedefs

typedef unsigned int uint32
 32 bit unsigned integer data type More...
 
typedef unsigned short uint16
 16 bit unsigned integer data type More...
 
typedef unsigned char uint8
 8 bit unsigned integer data type More...
 
typedef int int32
 32 bit signed integer data type More...
 
typedef short int16
 16 bit signed integer data type More...
 
typedef signed char int8
 8 bit signed integer data type More...
 
typedef struct PruIo PruIo
 user defined type (class) for the driver structure More...
 

Enumerations

enum  PRUIO_PIN_LOCKING {
  PRUIO_UNLOCK_CURR, PRUIO_UNLOCK_ORIG, PRUIO_UNLOCK_NEW, PRUIO_LOCK_CURR,
  PRUIO_LOCK_ORIG, PRUIO_LOCK_NEW, PRUIO_LOCK_CHECK, PRUIO_UNLOCK_CURR,
  PRUIO_UNLOCK_ORIG, PRUIO_UNLOCK_NEW, PRUIO_LOCK_CURR, PRUIO_LOCK_ORIG,
  PRUIO_LOCK_NEW, PRUIO_LOCK_CHECK
}
 

Functions

PruIopruio_new (uint8 Av, uint32 OpD, uint8 SaD, uint8 Pru)
 C wrapper to create a PruIo instance. More...
 
void pruio_destroy (PruIo *Io)
 C wrapper to destroy a PruIo instance. More...
 
char * pruio_config (PruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds, uint16 ClDv)
 C wrapper for function PruIo::config(). More...
 
char * pruio_adc_step (PruIo *Io, uint8 Stp, uint8 ChN, uint8 Av, uint8 SaD, uint32 OpD)
 C wrapper for function PruIo::adc_step(). More...
 
char * pruio_gpio_get_config (PruIo *Io, uint8 Ball)
 C wrapper for function PruIo::gpio_get_config(). More...
 
char * pruio_gpio_set (PruIo *Io, uint8 Ball, uint8 Modus, uint8 Lokk)
 C wrapper for function PruIo::gpio_set(). More...
 
uint32 pruio_gpio_get (PruIo *Io, uint8 Ball)
 C wrapper for function PruIo::gpio_get(). More...
 
char * pruio_gpio_out (PruIo *Io, uint8 Ball, uint8 Modus)
 C wrapper for function PruIo::gpio_out(). More...
 
uint32 pruio_mm_trg_pin (PruIo *Io, uint8 Ball, uint8 GpioV, uint16 Skip)
 C wrapper for function PruIo::mm_trg_pin(). More...
 
uint32 pruio_mm_trg_ain (PruIo *Io, uint8 Stp, int32 AdcV, uint8 Rela, uint16 Skip)
 C wrapper for function PruIo::mm_trg_ain(). More...
 
uint32 pruio_mm_trg_pre (PruIo *Io, uint8 Stp, int32 AdcV, uint16 Samp, uint8 Rela)
 C wrapper for function PruIo::mm_trg_pre(). More...
 
char * pruio_mm_start (PruIo *Io, uint32 Trg1, uint32 Trg2, uint32 Trg3, uint32 Trg4)
 C wrapper for function PruIo::mm_start(). More...
 

Detailed Description

The main header code of the C wrapper for libpruio.

This file provides the declarations of the PruIo class member functions in C syntax. It also can be used to create language bindings for non-C languages to use libpruio in polyglot applications.

Note
The includes pruio.h and pruio_pins.h are not shown in this documentation because they confuse Doxygen. It mixes up references with the original headers pruio/pruio.bi and pruio/pruio_pins.bi.

Licence: LGPLv2 (http://www.gnu.org/licenses/lgpl-2.0.html)

Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net

Definition in file pruio_c_wrapper.h.


Class Documentation

class AdcSteps

user defined type for a step setting

Definition at line 115 of file pruio_c_wrapper.h.

Collaboration diagram for AdcSteps:
Class Members
uint32 Confg context for configuration register
uint32 Delay context for delay register
class GpioSet

user defined type for a GPIO setting

Definition at line 121 of file pruio_c_wrapper.h.

Collaboration diagram for GpioSet:
Class Members
uint32 Addr base address of GPIO device
uint32 ClrM mask to clear pins to low
uint32 SetM mask to set pins to high
uint32 OutE mask to enable pins for output
uint32 Stat current state of pins (mixed)
uint32 StaO current state of output pins
uint32 fe1 future expansion
uint32 fe2

Macro Definition Documentation

#define PRUIO_BALL_AZ   109

Definition at line 20 of file pruio_c_wrapper.h.

#define PRUIO_BALL_OFFS   256

Definition at line 21 of file pruio_c_wrapper.h.

#define PRUIO_GPIO_AZ   3

Definition at line 23 of file pruio_c_wrapper.h.

#define PRUIO_GPIO_OFFS   64

Definition at line 24 of file pruio_c_wrapper.h.

#define PRUIO_GPIO_DATA   24

Definition at line 25 of file pruio_c_wrapper.h.

#define PRUIO_GPIO_BLCK   32

Definition at line 26 of file pruio_c_wrapper.h.

#define PRUIO_ADC_OFFS   512

Definition at line 28 of file pruio_c_wrapper.h.

#define PRUIO_ADC_DATA   228

Definition at line 29 of file pruio_c_wrapper.h.

#define PRUIO_ADC_EMPTY   12

Definition at line 30 of file pruio_c_wrapper.h.

#define PRUIO_ADC_BUFF   16

Definition at line 31 of file pruio_c_wrapper.h.

#define PRUIO_TRG_PARA   4

Definition at line 32 of file pruio_c_wrapper.h.

#define PRUIO_IRPT   25

Definition at line 34 of file pruio_c_wrapper.h.

#define PRUIO_MSG_INIT_OK   4294967295

Definition at line 36 of file pruio_c_wrapper.h.

#define PRUIO_MSG_EXIT_OK   4294967294

Definition at line 37 of file pruio_c_wrapper.h.

#define PRUIO_MSG_ADC_ERRR   4294967293

Definition at line 38 of file pruio_c_wrapper.h.

#define PRUIO_MSG_IO_OK   4294967292

Definition at line 39 of file pruio_c_wrapper.h.

#define PRUIO_MSG_MM_WAIT   4294967291

Definition at line 40 of file pruio_c_wrapper.h.

#define PRUIO_MSG_MM_TRG1   4294967290

Definition at line 41 of file pruio_c_wrapper.h.

#define PRUIO_MSG_MM_TRG2   4294967289

Definition at line 42 of file pruio_c_wrapper.h.

#define PRUIO_MSG_MM_TRG3   4294967288

Definition at line 43 of file pruio_c_wrapper.h.

#define PRUIO_MSG_MM_TRG4   4294967287

Definition at line 44 of file pruio_c_wrapper.h.

#define AM33XX

tell pruss_intc_mapping.bi that we use ARM33xx

Definition at line 49 of file pruio_c_wrapper.h.

#define PRUIO_CHAN   CHANNEL5

the PRUSS driver library

PRUSS driver interrupt settings the channel for PRU messages (must match PRUIO_IRPT)

Definition at line 57 of file pruio_c_wrapper.h.

#define PRUIO_MASK   PRU_EVTOUT5_HOSTEN_MASK

the mask to enable PRU interrupts (must match PRUIO_IRPT)

Definition at line 59 of file pruio_c_wrapper.h.

#define PRUIO_EMAP   PRU_EVTOUT5

the event for PRU messages (mapping, must match PRUIO_IRPT)

Definition at line 61 of file pruio_c_wrapper.h.

#define PRUIO_EVNT   PRU_EVTOUT_5

the event for PRU messages (must match PRUIO_IRPT)

Definition at line 63 of file pruio_c_wrapper.h.

#define PRUIO_DEF_AVRAGE   4

the default setting for avaraging

Definition at line 66 of file pruio_c_wrapper.h.

#define PRUIO_DEF_ODELAY   183

the default value for open delay in channel settings

Definition at line 68 of file pruio_c_wrapper.h.

#define PRUIO_DEF_SDELAY   0

the default value for sample delay in channel settings

Definition at line 70 of file pruio_c_wrapper.h.

#define PRUIO_DEF_PRUSS   1

the default PRU subsystem to use

Definition at line 72 of file pruio_c_wrapper.h.

#define PRUIO_DEF_SAMPLS   0

the default number of samples to use (configures single mode)

Definition at line 74 of file pruio_c_wrapper.h.

#define PRUIO_DEF_STPMSK   0x1FE /* &b111111110 */

the default step mask (steps 1 to 8 for AIN0 to AIN7, no charge step)

Definition at line 76 of file pruio_c_wrapper.h.

#define PRUIO_DEF_TIMERV   0

the default timer value (sampling rate)

Definition at line 78 of file pruio_c_wrapper.h.

#define PRUIO_DEF_LSLMOD   4

the default bit mode (4 = 16 bit encoding)

Definition at line 80 of file pruio_c_wrapper.h.

#define PRUIO_DEF_CLKDIV   0

the default clock divisor (0 = full speed AFE = 2.4 MHz)

Definition at line 82 of file pruio_c_wrapper.h.

#define PRUIO_IN   0x2F /* &b00101111 */

convenience macro to configure an input pin without pullup or pulldown

Definition at line 85 of file pruio_c_wrapper.h.

#define PRUIO_IN_0   0x27 /* &b00100111 */

convenience macro to configure an low input pin (with pulldown resistor)

Definition at line 87 of file pruio_c_wrapper.h.

#define PRUIO_IN_1   0x37 /* &b00110111 */

convenience macro to configure an high input pin (with pullup resistor)

Definition at line 89 of file pruio_c_wrapper.h.

#define PRUIO_OUT0   0xF /* &b00001111 */

convenience macro to configure an output pin initial low

Definition at line 91 of file pruio_c_wrapper.h.

#define PRUIO_OUT1   0x8F /* &b10001111 */

convenience macro to configure an output pin initial high

Definition at line 93 of file pruio_c_wrapper.h.

#define PRUIO_PIN_RESET   0xFF /* &b11111111 */

convenience macro to re-configure a pin to its original (initial) state

Definition at line 95 of file pruio_c_wrapper.h.

Typedef Documentation

typedef unsigned int uint32

32 bit unsigned integer data type

Definition at line 107 of file pruio_c_wrapper.h.

typedef unsigned short uint16

16 bit unsigned integer data type

Definition at line 108 of file pruio_c_wrapper.h.

typedef unsigned char uint8

8 bit unsigned integer data type

Definition at line 109 of file pruio_c_wrapper.h.

typedef int int32

32 bit signed integer data type

Definition at line 110 of file pruio_c_wrapper.h.

typedef short int16

16 bit signed integer data type

Definition at line 111 of file pruio_c_wrapper.h.

typedef signed char int8

8 bit signed integer data type

Definition at line 112 of file pruio_c_wrapper.h.

typedef struct PruIo PruIo

user defined type (class) for the driver structure

Enumeration Type Documentation

Enumerator
PRUIO_UNLOCK_CURR 

unlock a pin, don't change the configuration

PRUIO_UNLOCK_ORIG 

unlock a pin, change to original (initial) configuration

PRUIO_UNLOCK_NEW 

unlock a pin, change to parameter configuration

PRUIO_LOCK_CURR 

lock a pin, don't change the configuration

PRUIO_LOCK_ORIG 

lock a pin, change to original (initial) configuration

PRUIO_LOCK_NEW 

lock a pin, change to parameter configuration

PRUIO_LOCK_CHECK 

don't change pin locking, skip operation if pin is locked

PRUIO_UNLOCK_CURR 

unlock a pin, don't change the configuration

PRUIO_UNLOCK_ORIG 

unlock a pin, change to original (initial) configuration

PRUIO_UNLOCK_NEW 

unlock a pin, change to parameter configuration

PRUIO_LOCK_CURR 

lock a pin, don't change the configuration

PRUIO_LOCK_ORIG 

lock a pin, change to original (initial) configuration

PRUIO_LOCK_NEW 

lock a pin, change to parameter configuration

PRUIO_LOCK_CHECK 

don't change pin locking, skip operation if pin is locked

Definition at line 97 of file pruio_c_wrapper.h.

Function Documentation

PruIo* pruio_new ( uint8  Av,
uint32  OpD,
uint8  SaD,
uint8  Pru 
)

C wrapper to create a PruIo instance.

Parameters
Avavaraging for default steps (0 to 16, defaults to 0)
OpDopen delay for default steps (0 to 0x3FFFF, defaults to 0x98)
SaDsample delay for default steps (0 to 255, defaults to 0)
Prunumber of PRU subsystem to use (0 or 1, defaults to 1)
Returns
A pointer for the new instance.

This function wraps the constructor, check PruIo::PruIo() for details.

Since the constructor reads the original devices configurations and the destructor restores them, it's recommended to create and use just one PruIo instance at the same time.

Here is the caller graph for this function:

void pruio_destroy ( PruIo Io)

C wrapper to destroy a PruIo instance.

Parameters
IoThe pointer of the instance.

This function wraps the destructor, check PruIo::~PruIo() for details. (Doxygen should create a link here?!)

Here is the caller graph for this function:

char* pruio_config ( PruIo Io,
uint32  Samp,
uint32  Mask,
uint32  Tmr,
uint16  Mds,
uint16  ClDv 
)

C wrapper for function PruIo::config().

Parameters
IoThe pointer of the PruIo instance
Sampnumber of samples to fetch (defaults to zero)
Maskmask for active steps (defaults to all 8 channels active in steps 1 to 8)
Tmrtimer value in [ns] to specify the sampling rate (defaults to zero, MM only)
Mdsmodus for output (defaults to 4 = 16 bit)
ClDvdivisor for ADC input clock (defaults to 0 = full speed = 2.4 MHz)
Returns
zero on success (otherwise a string with an error message)

This function wraps the member function config, check PruIo::config() for details.

Here is the caller graph for this function:

char* pruio_adc_step ( PruIo Io,
uint8  Stp,
uint8  ChN,
uint8  Av,
uint8  SaD,
uint32  OpD 
)

C wrapper for function PruIo::adc_step().

Parameters
IoThe pointer of the PruIo instance
Stpstep index (0 = step 0 => charge step, 1 = step 1 (=> AIN0 by default), ..., 17 = idle step)
ChNchannel number to scan (0 = AIN0, 1 = AIN1, ...)
Avnew value for avaraging (defaults to 4)
SaDnew value for sample delay (defaults to 0)
OpDnew value for open delay (defaults to 0x98)
Returns
zero on success (otherwise a string with an error message)

This function wraps the member function adc_step, check PruIo::adc_step() for details.

char* pruio_gpio_get_config ( PruIo Io,
uint8  Ball 
)

C wrapper for function PruIo::gpio_get_config().

Parameters
IoThe pointer of the PruIo instance
Ballthe CPU ball number to describe
Returns
a human-readable text string (internal string, never free it)

This function wraps the member function gpio_get_config, check PruIo::gpio_get_config() for details.

Here is the caller graph for this function:

char* pruio_gpio_set ( PruIo Io,
uint8  Ball,
uint8  Modus,
uint8  Lokk 
)

C wrapper for function PruIo::gpio_set().

Parameters
IoThe pointer of the PruIo instance
Ballthe CPU ball number to set
Modusthe mode for the GPIO
Lokkthe locking specification
Returns
zero on success (otherwise a pionter to an error message)

This function wraps the member function gpio_set, check PruIo::gpio_set() for details.

Here is the caller graph for this function:

uint32 pruio_gpio_get ( PruIo Io,
uint8  Ball 
)

C wrapper for function PruIo::gpio_get().

Parameters
IoThe pointer of the PruIo instance
Ballthe CPU ball number to test
Returns
GPIO state (otherwise -1, check PruIo::Errr for an error message)

This function wraps the member function gpio_get, check PruIo::gpio_get() for details.

char* pruio_gpio_out ( PruIo Io,
uint8  Ball,
uint8  Modus 
)

C wrapper for function PruIo::gpio_out().

Parameters
IoThe pointer of the PruIo instance
Ballthe CPU ball number to test
Modusthe state to set (0 = low, high otherwise)
Returns
zero on success (otherwise a pointer to an error message)

This function wraps the member function gpio_out, check PruIo::gpio_out() for details.

Here is the caller graph for this function:

uint32 pruio_mm_trg_pin ( PruIo Io,
uint8  Ball,
uint8  GpioV,
uint16  Skip 
)

C wrapper for function PruIo::mm_trg_pin().

Parameters
IoThe pointer of the PruIo instance
Ballthe CPU ball number to test
GpioVthe state to check (defaults to high = 1)
Skipthe number of samples to skip (defaults to 0 = zero, max. 1023)
Returns
the trigger configuration (or zero in case of an error, check PruIo::Errr)

This function wraps the member function mm_trg_pin, check PruIo::mm_trg_pin() for details.

uint32 pruio_mm_trg_ain ( PruIo Io,
uint8  Stp,
int32  AdcV,
uint8  Rela,
uint16  Skip 
)

C wrapper for function PruIo::mm_trg_ain().

Parameters
IoThe pointer of the PruIo instance
Stpthe step number to use for trigger input
AdcVthe sample value to match (positive check greater than, negative check less than)
Relaif AdcV is relative to the current input
Skipthe number of samples to skip (defaults to 0 = zero, max. 1023)
Returns
the trigger configuration (or zero in case of an error, check PruIo::Errr)

This function wraps the member function mm_trg_ain, check PruIo::mm_trg_ain() for details.

uint32 pruio_mm_trg_pre ( PruIo Io,
uint8  Stp,
int32  AdcV,
uint16  Samp,
uint8  Rela 
)

C wrapper for function PruIo::mm_trg_pre().

Parameters
IoThe pointer of the PruIo instance
Stpthe step number to use for trigger input
AdcVthe sample value to match (positive check greater than, negative check less than)
Sampthe number of samples for the pre-trigger
Relaif AdcV is relative to the current input
Returns
the trigger configuration (or zero in case of an error, check PruIo::Errr)

This function wraps the member function mm_trg_pre, check PruIo::mm_trg_pre() for details.

char* pruio_mm_start ( PruIo Io,
uint32  Trg1,
uint32  Trg2,
uint32  Trg3,
uint32  Trg4 
)

C wrapper for function PruIo::mm_start().

Parameters
IoThe pointer of the PruIo instance
Trg1settings for first trigger (default = no trigger)
Trg2settings for second trigger (default = no trigger)
Trg3settings for third trigger (default = no trigger)
Trg4settings for fourth trigger (default = no trigger)
Returns
zero on success (otherwise a string with an error message)

This function wraps the member function mm_start, check PruIo::mm_start() for details.