libpruio  0.0.2
AM33xx-PRU driver for digital input / output and analog input
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PruIo Class Reference

user defined type (class) for the driver structure More...

#include "pruio_c_wrapper.h"

Collaboration diagram for PruIo:

Public Member Functions

 PruIo (BYVAL_AS_uint8, BYVAL_AS_uint32, BYVAL_AS_uint8, BYVAL_AS_uint8)
 Constructor, initialize devices, create default configuration. More...
 
 ~PruIo ()
 Destructor to restore configurations and clear memory. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR config (BYVAL_AS_uint32, BYVAL_AS_uint32, BYVAL_AS_uint32, BYVAL_AS_uint16, BYVAL_AS_uint16)
 Load configuration from host (ARM) to driver (PRU). More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR adc_step (BYVAL_AS_uint8, BYVAL_AS_uint8, BYVAL_AS_uint8, BYVAL_AS_uint8, BYVAL_AS_uint32)
 Customize a single configuration step. More...
 
FUNCTION_CDECL_AS_uint32 gpio_get (BYVAL_AS_uint8)
 Get the state of a GPIO. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR gpio_set (BYVAL_AS_uint8, BYVAL_AS_uint8, BYVAL_AS_uint8)
 Set the configuration of a GPIO. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR gpio_out (BYVAL_AS_uint8, BYVAL_AS_uint8)
 Set the state of a GPIO. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR gpio_get_config (BYVAL_AS_uint8)
 Create a text description for a pin configuration. More...
 
FUNCTION_CDECL_AS_uint32 mm_trg_pin (BYVAL_AS_uint8, BYVAL_AS_uint8, BYVAL_AS_uint16)
 Create a trigger configuration for a digital trigger (GPIO). More...
 
FUNCTION_CDECL_AS_uint32 mm_trg_ain (BYVAL_AS_uint8, BYVAL_AS_int32, BYVAL_AS_uint8, BYVAL_AS_uint16)
 Create a trigger configuration for an analog input trigger. More...
 
FUNCTION_CDECL_AS_uint32 mm_trg_pre (BYVAL_AS_uint8, BYVAL_AS_int32, BYVAL_AS_uint16, BYVAL_AS_uint8)
 Create a trigger configuration for an analog input trigger. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR mm_start (BYVAL_AS_uint32, BYVAL_AS_uint32, BYVAL_AS_uint32, BYVAL_AS_uint32)
 Start a measurement in MM. More...
 

Public Attributes

uint32 Samples
 number of samples More...
 
uint32 TimerVal
 timer value in [ns] More...
 
uint32 StepMask
 mask to specify active channels More...
 
uint16 LslMode
 bit shift modus (0 to 4) More...
 
uint16 ClockDiv
 divisor for ADC input clock (register 0x4C) More...
 
uint32 AdcReg24 = 0
 < ADC register IRQ_STATUS_RAW More...
 
uint32 AdcReg28 = 0
 < ADC register IRQ_STATUS More...
 
uint32 AdcReg2C = 0
 < ADC register IRQENABLE_SET More...
 
uint32 AdcReg30 = 0
 < ADC register IRQENABLE_CLR More...
 
uint32 AdcReg34 = 0
 < ADC register IRQWAKEUP More...
 
uint32 AdcReg38 = 0
 < ADC register DMAENABLE_SET More...
 
uint32 AdcReg3C = 0
 < ADC register DMAENABLE_CLR More...
 
uint32 AdcReg40 = 0
 ADC register CRTL (bits 0, 1 and 2 gets set by driver) More...
 
struct AdcSteps St_p [17+1]
 step configuration (charge step + 16 steps + idle step, by default steps 1 to 8 are used for AIN0 to AIN7) More...
 
uint32DRam
 pointer to access PRU DRam More...
 
void * ERam
 pointer to read PRU external ram More...
 
void * BallOrg
 buffer pointer for original Ball configuration More...
 
uint32AdcOrg
 buffer pointer for original ADC configuration (= 0 in case of ADC down at startup) More...
 
uint32GpioOrg
 buffer pointer for original GPIO configuration More...
 
uint16Value
 pointer to read sampled ADC input data More...
 
uint8BallRef
 pointer to ball reference (GPIO# for CPU pins or lock) More...
 
uint8BallConf
 pointer to ball configuration (CPU pin muxing) More...
 
char * Errr
 pointer for error messages More...
 
uint32 EOffs
 the offset of the external PRUSS-DDR More...
 
uint32 ESize
 the size of the external PRUSS-DDR More...
 
uint32 CSize
 the size of the original configuration block More...
 
uint32 PruNo
 the PRU number to use More...
 
uint32 PruEvtout
 the interrupt channel to send commands to PRU More...
 
uint32 PruIRam
 the PRU instruction ram to load More...
 
uint32 PruDRam
 the PRU data ram More...
 
int16 ArmPruInt
 the interrupt to send More...
 
int16 ChAz
 number of active channels More...
 
struct __pruss_intc_initdata IntcInit
 interrupt settings (we also set default interrupts, so that the other PRUSS can be used in parallel) More...
 
struct GpioSetGpio
 pointer to GPIO structure (current values) More...
 
struct GpioSet GpioInit [PRUIO_GPIO_AZ+1]
 initial GPIO definitions More...
 
uint8 BallGpio [PRUIO_BALL_AZ+1]
 list of GPIO numbers, corresponding to ball index More...
 
AdcSteps St_p [17+1]
 step configuration (charge step + 16 steps + idle step, by default steps 1 to 8 are used for AIN0 to AIN7) More...
 
uint32_PTR DRam
 pointer to access PRU DRam More...
 
ANY_PTR ERam
 pointer to read PRU external ram More...
 
ANY_PTR BallOrg
 buffer pointer for original Ball configuration More...
 
uint32_PTR AdcOrg
 buffer pointer for original ADC configuration (= 0 in case of ADC down at startup) More...
 
uint32_PTR GpioOrg
 buffer pointer for original GPIO configuration More...
 
uint16_PTR Value
 pointer to read sampled ADC input data More...
 
uint8_PTR BallRef
 pointer to ball reference (GPIO# for CPU pins or lock) More...
 
uint8_PTR BallConf
 pointer to ball configuration (CPU pin muxing) More...
 
ZSTRING_PTR Errr = 0
 pointer for error messages More...
 
tpruss_intc_initdata IntcInit
 interrupt settings (we also set default interrupts, so that the other PRUSS can be used in parallel) More...
 
GpioSet_PTR Gpio
 
GpioSet GpioInit [PRUIO_GPIO_AZ+1]
 initial GPIO definitions More...
 

Detailed Description

user defined type (class) for the driver structure

Definition at line 134 of file pruio_c_wrapper.h.

Constructor & Destructor Documentation

PruIo::PruIo ( BYVAL_AS_uint8  Av = PRUIO_DEF_AVRAGE,
BYVAL_AS_uint32  OpD = PRUIO_DEF_ODELAY,
BYVAL_AS_uint8  SaD = PRUIO_DEF_SDELAY,
BYVAL_AS_uint8  Pru = PRUIO_DEF_PRUSS 
)

Constructor, initialize devices, create default configuration.

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)

The constructor tries to open the PRUSS interrupt and reports an error in case of a failure (the structure should be freed in that case and in case of any other error).

Otherwise the constructor generates valid steps configuration data for all channels (AIN0 to AIN 7 in steps 1 to 8). For these steps, the default values can get customized using the (optional) parameter list:

  • avaraging may get done in a certain number of steps, options are 1, 2, 4, 8 or 16. (A non-matching parameter get increased either to the next higher or to the last option.)
  • open delay is the number of clock cycles the ADC waits between setting the step configuration and sending the start of conversion signal.
  • sample delay is the number of clock cycles the ADC waits before starting (the width of the start of conversion signal). It specifies the number of clock cycles between the single conversion processes.

See ARM Reference Guide, chapter 12 for details on step configuration.

Also, and after executing the constructor, the step configuration can get customized by function PruIo::adc_step().

Definition at line 153 of file pruio.bas.

PruIo::~PruIo ( )

Destructor to restore configurations and clear memory.

The destructor copies the original configuration to DRam (if any), loads new instructions to the PRU and start them. This PRU code restores the devices GPIOs, Control Module and ADC to their original configurations. Finaly the PRU gets powered off and the memory of the PruIo instance get freed.

The destructor cannot report error messages in member variable PruIo::Errr. Messages (if any) get sent directly to the ERROUT pipe of the operating system instead.

Definition at line 251 of file pruio.bas.

Member Function Documentation

FUNCTION_CDECL_AS_ZSTRING_PTR PruIo::config ( BYVAL_AS_uint32  Samp = PRUIO_DEF_SAMPLS,
BYVAL_AS_uint32  Mask = PRUIO_DEF_STPMSK,
BYVAL_AS_uint32  Tmr = PRUIO_DEF_TIMERV,
BYVAL_AS_uint16  Mds = PRUIO_DEF_LSLMOD,
BYVAL_AS_uint16  ClDv = PRUIO_DEF_CLKDIV 
)

Load configuration from host (ARM) to driver (PRU).

Parameters
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 is used to download the configuration from the host (ARM) to the driver (PRU). The PRU gets stopped (if running) and the new configurations get loaded. Also the PRU instructions get re-initialized.

In case of an error the PRU will be disabled after this call. Otherwise it's running and

The Samp parameter specifies the number of samples to convert for each channel. In single mode (Samp <= 1 = default) sampling starts immediately and the index in the array PruIo::Value[] is equal to the step number. Inactive steps return 0 (zero) in this case.

field result of defaults to
Value[0] charge step allways zero
Value[1] step 1 AIN0
Value[2] step 2 AIN1
... ... ...

In MM (Samp > 1) the array PruIo::Value[] contains no zero values. Instead only values from active steps get collected. The charge step (step 0) returns no value. So when 3 steps are active in the Mask and Samp is set to 5, a total of 3 times 5 = 15 values get available in the array PruIo::Value[] (after the call of the function PruIo::mm_start() ). The array contains the active steps, so when ie. steps 3, 6 and 7 are active in the Mask, the array contains:

field Mask = &b110010000
Value[0] 1. sample AIN3
Value[1] 1. sample AIN6
Value[2] 1. sample AIN7
Value[3] 2. sample AIN3
Value[4] 2. sample AIN6
Value[5] 2. sample AIN7
Value[6] 3. sample AIN3
Value[7] 3. sample AIN6
Value[8] ...

Currently the number of samples is limited by the external memory allocated by the kernel PRUSS driver. This 256 kByte by default, see Memory Organisation for further informations.

active Steps max. Samples
1 131072
2 65536
3 43690
4 32768
5 26214
6 21845
7 18724
8 16384
... ...

The Mask parameter specifies the active steps. Setting a bit in the Mask activates a step defined by the step configuration (by default bits 1 = AIN0, 2 = AIN1, ... up to 8 = AIN7 are set, use function PruIo::adc_step() to customize steps).

Note
Bit 0 controls the charge step (see ARM Reference Guide, chapter 12, ADC STEPENABLE register).

The highest bit 31 has a special meaning for customizing the idle step. By default the idle configuration is set like the configuration of the first active step, so that (in MM) the open delay can get reduced to a minimum for that step (if there's enough time left before restart the ADC). By setting bit 31 the configuration from PruIo::St_p is used instead.

The Tmr parameter specifies the sampling rate. It's the number of nano seconds between the starts of the ADC sampling process. The IEP timer gets used. It is configured to increase by steps of 5 (it counts in GHz, but runs at 200 MHz), so values like 22676 or 22679 results to the same frequency. Some examples

Tmr [ns] Sampling rate [Hz]
1e9 1
1e6 1000
22675 ~44100
Note
This value has no effect in single mode (when Samp is less than 2).

The Mds parameter specifies the range of the samples. By default (Mds = 4) the 12 bit samples from the ADC get left shifted by 4, so that they actually are 16 bit values and can get compared with samples from other ADC devices (like 16 bit audio data). Examples

Mds samples
0 12 bit
1 13 bit
2 14 bit
3 15 bit
4 16 bit
>4 16 bit

The ClDv parameter gets transfered to the ADC clock divider register ADC_CLKDIV (&h4C). The default value (0 = zero) lets the analog front end (AFE) running at full speed (2.4 MHz). Otherwise the clock frequency gets divided by this value + 1. Some examples

ClDv AFE [MHz]
0 2.4
1 1.2
5 0.4

Furthermore the registers PruIo::AdcReg24 to PruIo::AdcReg40 (ie. IRQ and DMA settings) get transfered to the ADC device, but bits 0 to 2 from PruIo::AdcReg40 are controled by the driver software. See ARM Reference Guide, chapter 12 for details on ADC configurations.

Definition at line 407 of file pruio.bas.

FUNCTION_CDECL_AS_ZSTRING_PTR PruIo::adc_step ( BYVAL_AS_uint8  Stp,
BYVAL_AS_uint8  ChN,
BYVAL_AS_uint8  Av = PRUIO_DEF_AVRAGE,
BYVAL_AS_uint8  SaD = PRUIO_DEF_SDELAY,
BYVAL_AS_uint32  OpD = PRUIO_DEF_ODELAY 
)

Customize a single configuration step.

Parameters
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 is used to adapt a step configuration. In the constructor, steps 1 to 8 get configured for AIN0 to AIN7 (other steps stay un-configured). By this function you can customize the default settings and / or configure further steps (input channel number, avaraging and delay values).

Stp Description
0 charge step
1 step 1
2 step 2
... ...
17 idle step
Note
This sets the local data on the host system (ARM). The setup gets uploaded to the PRU and activated when calling function PruIo::config().

It's also possible to directly write to the step configuration in member variables PruIo::St_p (i).Confg and PruIo::St_p (i).Delay. See ARM Reference Guide, chapter 12 for details on ADC configurations.

Definition at line 506 of file pruio.bas.

FUNCTION_CDECL_AS_uint32 PruIo::gpio_get ( BYVAL_AS_uint8  Ball)

Get the state of a GPIO.

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

This function is used to get the state of a digital pin (GPIO). Use the macros defined in pruio.bi to specify the pin number for a pin on the Beaglebone headers (ie P8_03 selects pin 3 on header P8).

It's also possible to get the state of a CPU ball (not connected to a header). In this case you need to find the matching CPU ball number and pass it in as the parameter Ball.

The function returns the state of input and output pins (locked or unlocked). Return values are

Value Description
1 GPIO is in high state
0 GPIO is in low state
-1 error (undefined ball number)

An alternative (and faster) way to get a pin (or ball) state is reading the corresponding bit in member variable PruIo::Gpio[i].Stat.

Definition at line 771 of file pruio.bas.

FUNCTION_CDECL_AS_ZSTRING_PTR PruIo::gpio_set ( BYVAL_AS_uint8  Ball,
BYVAL_AS_uint8  Modus = PRUIO_IN_0,
BYVAL_AS_uint8  Lokk = PRUIO_LOCK_CHECK 
)

Set the configuration of a GPIO.

Parameters
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 is used to configure a digital pin. Use the macros defined in pruio.bi to specify the pin number for a pin on the Beaglebone headers (ie P8_03 selects pin 3 on header P8).

Its also possible to get the state of a CPU ball (not connected to a header). In this case you need to find the matching CPU ball number and pass it in as the parameter Ball.

Parameter Modus specifies the pinmux mode for the ARM control module (see ARM Reference Guide, chapter 9). By default the pin gets configured as input pin with pullup resistor, so you can connect a button between the pin and ground to use it as a on/off switch. Other configurations are prepared as macros:

macro name Description
PRUIO_IN open input pin (no resistor)
PRUIO_IN_0 low input pin (with pulldown resistor)
PRUIO_IN_1 high input pin (with pullup resistor)
PRUIO_OUT0 output pin set to low (no resistor)
PRUIO_OUT1 output pin set to high (no resistor)
PRUIO_PIN_RESET reset pin configuration to initial state

By default only unlocked pins can get changed. These are header pins on P8 or P9 headers that were in mode 7 (GPIO) at start-up. All other pins are locked. That are internal pins not connected to a header and pins in a different mode (ie HDMI or EMMC2 pins).

Parameter Lokk can be specified to change the locking mode of a pin. Use the enumerator from PRUIO_PIN_LOCKING to specify the new mode (the latest is the default value):

enumerator name Description
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
Note
Pin locking only works for function family PruIo::gpio_xxx(). It doesn't work in case of direct access to internal PruIo::Gpio member variables.

Definition at line 694 of file pruio.bas.

FUNCTION_CDECL_AS_ZSTRING_PTR PruIo::gpio_out ( BYVAL_AS_uint8  Ball,
BYVAL_AS_uint8  Modus = 0 
)

Set the state of a GPIO.

Parameters
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 is used to set the state of an output GPIO. Use the macros defined in pruio.bi to specify the pin number for a pin on the Beaglebone headers (ie P8_03 selects pin 3 on header P8).

Its also possible to set the state of a CPU ball (not connected to a header). In this case you need to find the matching CPU ball number and pass it in as the parameter Ball.

This function only works on unlocked output pins. Selecting an input pin or a locked pin generates an error message.

An alternative (and faster) way to set a pin (or ball) state is writing to the corresponding bit in member variables PruIo::Gpio[i].SetM or PruIo::Gpio[i].ClrM. (No locking in this case, mind what you're doing.)

Definition at line 800 of file pruio.bas.

Here is the caller graph for this function:

FUNCTION_CDECL_AS_ZSTRING_PTR PruIo::gpio_get_config ( BYVAL_AS_uint8  Ball)

Create a text description for a pin configuration.

Parameters
Ballthe CPU ball number to describe
Returns
a human-readable text string (internal string, never free it)

This function is used to create a text description for the current state of a CPU ball, that is called a pin when it's connected to one of the Beaglebone headers P8 or P9.

The description contains the pin name and its mode. Header pin names start with a capital 'P', CPU ball names start with a lower case 'b'. The detailed pinmux setting is only described for pins in mode 7 (GPIO mode). Otherwise only the mode number gets shown. Finally locked pins get marked by the text '(locked)'.

The returned string pointer points to an internal string. Never free it. The string gets overwritten on further calls to this function, so make local copies if you need several descriptions at a time. The string may contain an error message if the ball number is too big.

Definition at line 547 of file pruio.bas.

FUNCTION_CDECL_AS_uint32 PruIo::mm_trg_pin ( BYVAL_AS_uint8  Ball,
BYVAL_AS_uint8  GpioV = 0,
BYVAL_AS_uint16  Skip = 0 
)

Create a trigger configuration for a digital trigger (GPIO).

Parameters
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 is used to create a configuration for a digital (= GPIO) trigger. Pass the returned value as parameter to function PruIo::mm_start(). The measurement (or the next trigger) will start when the specified GPIO gets in to the declared state.

The parameter Skip can be used to hold up the start for a certain time (previously defined by the Tmr parameter in the last call to function PruIo::config).

This trigger is a fast trigger. The ADC device is waiting in idle mode while the GPIO gets checked.

Definition at line 835 of file pruio.bas.

FUNCTION_CDECL_AS_uint32 PruIo::mm_trg_ain ( BYVAL_AS_uint8  Stp,
BYVAL_AS_int32  AdcV,
BYVAL_AS_uint8  Rela = 0,
BYVAL_AS_uint16  Skip = 0 
)

Create a trigger configuration for an analog input trigger.

Parameters
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 is used to create a configuration for an analog (= AIN) trigger. Pass the returned value as parameter to function PruIo::mm_start(). The measurement (or the next trigger) will start when the specified analog input (AIN) gets in to the declared state.

The parameter AdcV specifies the value to compare with. A positive value starts when the input is greater than AdcV. A negative value starts when the input is less than AdcV.

AdcV is scalled like the samples, so when the previuos call to function PruIo::config() requires 16 bit samples (Mds = 4), AdcV has to be specified as 16 bit value as well.

AdcV can either be an absolute value or a relative value. For the later case set parameter Rela to any value <> zero. The driver will fetch the current analog input value when the trigger gets active and adds AdcV to calculate the absolute trigger value.

This trigger value gets auto-limited to a certain range (ie &hF0 to &hFF00, in case of default 16 bit setting), to avoid trigger values that never can be reached.

The parameter Skip can be used to hold up the start for a certain time (previously defined by the Tmr parameter in the last call to function PruIo::config). Example:

Tmr = 1e8 ' 10 Hz
Skip = 500 ' skip 500 samples
time = Skip / Tmr * 1e9 ' delay time = 5 seconds (1e9 = Hz / GHz)

This trigger is a fast trigger. Only the specified step is active while waiting for the event. The trigger step can be inactive in the Mask of the previous call to function PruIo::config() and only be used for trigger purposes. (Ie. a short open delay can get specified for the trigger step since there is no channel muxing.)

Note
All error checks in this function are related to the parameters of the previuos call to function PruIo::config(). The created specification may get invalid by changing the ADC settings by a further call to function PruIo::config() with different parameters (ie. when the trigger step gets cleared). To be on the save side, re-create your trigger specifications after each call to function PruIo::config().

Definition at line 909 of file pruio.bas.

FUNCTION_CDECL_AS_uint32 PruIo::mm_trg_pre ( BYVAL_AS_uint8  Stp,
BYVAL_AS_int32  AdcV,
BYVAL_AS_uint16  Samp = 0,
BYVAL_AS_uint8  Rela = 0 
)

Create a trigger configuration for an analog input trigger.

Parameters
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 is used to create a configuration for an analog (= AIN) pre-trigger. Pass the returned value as parameter to function PruIo::mm_start(). The measurement on all active steps will start immediately and collect the input values in a ring buffer. Normal measurement starts when the specified analog input (AIN) gets in to the declared state.

Either a certain step (that must be activated in the previous call to function PruIo::config() ) can be checked. Or all active inputs get checked against the specified AdcV. In the later case AdcV is allways an absolute value (parameter Rela gets ignored).

The parameter AdcV specifies the value to compare with. A positive value starts when the input is greater than AdcV. A negative value starts when the input is less than AdcV.

AdcV is scalled like the samples, so when the previuos call to function PruIo::config() requires 16 bit samples (Mds = 4), AdcV has to be specified as 16 bit value as well.

AdcV can either be an absolute value or a relative value. For the later case set parameter Rela to any value <> zero. The driver will fetch the current analog input value when the trigger gets active and add AdcV to calculate the absolute trigger value.

The trigger value gets auto-limited to a certain range (ie &hF0 to &hFF00, in case of default 16 bit setting), to avoid trigger values that never can be reached.

Parameter Samp is used to specify the number of samples to fetch before the trigger event occurs. It specifies the number of sampling sets for all active channels. Its maximum value is limited to 1023 and also by the amount of memory available (approx. 7000 samples in DRam0 and DRam1) to sort the ring buffer.

The pre-trigger is a slow trigger. The ADC device goes through all activated steps while waiting for the trigger event.

Note
All error checks in this function are related to the parameters of the previuos call to function PruIo::config(). The created specification may get invalid by changing the ADC settings by a further call to function PruIo::config() with different parameters (ie. when the trigger step gets cleared). To be on the save side, re-create your trigger specifications after each call to function PruIo::config().
A pre-trigger is always the last trigger specification in the call to function PruIo::mm_start() (all further specifications get ignored).

Definition at line 992 of file pruio.bas.

FUNCTION_CDECL_AS_ZSTRING_PTR PruIo::mm_start ( BYVAL_AS_uint32  Trg1 = 0,
BYVAL_AS_uint32  Trg2 = 0,
BYVAL_AS_uint32  Trg3 = 0,
BYVAL_AS_uint32  Trg4 = 0 
)

Start a measurement in MM.

Parameters
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 starts a measurement in MM mode. The ADC configuration from the previous call to function PruIo::config() are used. The measurement either starts immediately or the start gets controlled by one (or up to four) trigger event(s).

Function are available to create trigger specifications:

Note
The created analog trigger specifications may get invalid by changing the ADC settings in a further call to function PruIo::config() with different parameters (ie. when the trigger step gets cleared). To be on the save side, re-create your trigger specifications after each call to function PruIo::config().

Definition at line 1047 of file pruio.bas.

Member Data Documentation

uint32 PruIo::Samples

number of samples

Definition at line 137 of file pruio_c_wrapper.h.

uint32 PruIo::TimerVal

timer value in [ns]

Definition at line 137 of file pruio_c_wrapper.h.

uint32 PruIo::StepMask

mask to specify active channels

Definition at line 137 of file pruio_c_wrapper.h.

uint16 PruIo::LslMode

bit shift modus (0 to 4)

Definition at line 141 of file pruio_c_wrapper.h.

uint16 PruIo::ClockDiv

divisor for ADC input clock (register 0x4C)

Definition at line 141 of file pruio_c_wrapper.h.

uint32 PruIo::AdcReg24 = 0

< ADC register IRQ_STATUS_RAW

ADC register IRQ_STATUS_RAW.

Definition at line 146 of file pruio_c_wrapper.h.

uint32 PruIo::AdcReg28 = 0

< ADC register IRQ_STATUS

ADC register IRQ_STATUS.

Definition at line 146 of file pruio_c_wrapper.h.

uint32 PruIo::AdcReg2C = 0

< ADC register IRQENABLE_SET

ADC register IRQENABLE_SET.

Definition at line 146 of file pruio_c_wrapper.h.

uint32 PruIo::AdcReg30 = 0

< ADC register IRQENABLE_CLR

ADC register IRQENABLE_CLR.

Definition at line 146 of file pruio_c_wrapper.h.

uint32 PruIo::AdcReg34 = 0

< ADC register IRQWAKEUP

ADC register IRQWAKEUP.

Definition at line 146 of file pruio_c_wrapper.h.

uint32 PruIo::AdcReg38 = 0

< ADC register DMAENABLE_SET

ADC register DMAENABLE_SET.

Definition at line 146 of file pruio_c_wrapper.h.

uint32 PruIo::AdcReg3C = 0

< ADC register DMAENABLE_CLR

ADC register DMAENABLE_CLR.

Definition at line 146 of file pruio_c_wrapper.h.

uint32 PruIo::AdcReg40 = 0

ADC register CRTL (bits 0, 1 and 2 gets set by driver)

Definition at line 146 of file pruio_c_wrapper.h.

struct AdcSteps PruIo::St_p[17+1]

step configuration (charge step + 16 steps + idle step, by default steps 1 to 8 are used for AIN0 to AIN7)

Definition at line 155 of file pruio_c_wrapper.h.

uint32* PruIo::DRam

pointer to access PRU DRam

Definition at line 157 of file pruio_c_wrapper.h.

void* PruIo::ERam

pointer to read PRU external ram

Definition at line 158 of file pruio_c_wrapper.h.

void * PruIo::BallOrg

buffer pointer for original Ball configuration

Definition at line 158 of file pruio_c_wrapper.h.

uint32* PruIo::AdcOrg

buffer pointer for original ADC configuration (= 0 in case of ADC down at startup)

Definition at line 160 of file pruio_c_wrapper.h.

uint32 * PruIo::GpioOrg

buffer pointer for original GPIO configuration

Definition at line 160 of file pruio_c_wrapper.h.

uint16* PruIo::Value

pointer to read sampled ADC input data

Definition at line 162 of file pruio_c_wrapper.h.

uint8* PruIo::BallRef

pointer to ball reference (GPIO# for CPU pins or lock)

Definition at line 163 of file pruio_c_wrapper.h.

uint8 * PruIo::BallConf

pointer to ball configuration (CPU pin muxing)

Definition at line 163 of file pruio_c_wrapper.h.

char* PruIo::Errr

pointer for error messages

Definition at line 165 of file pruio_c_wrapper.h.

uint32 PruIo::EOffs

the offset of the external PRUSS-DDR

the offset of the external memory (PRUSS-DDR)

Definition at line 167 of file pruio_c_wrapper.h.

uint32 PruIo::ESize

the size of the external PRUSS-DDR

the size of the external memory (PRUSS-DDR)

Definition at line 167 of file pruio_c_wrapper.h.

uint32 PruIo::CSize

the size of the original configuration block

Definition at line 167 of file pruio_c_wrapper.h.

uint32 PruIo::PruNo

the PRU number to use

the PRU number to use (defaults to 1)

Definition at line 167 of file pruio_c_wrapper.h.

uint32 PruIo::PruEvtout

the interrupt channel to send commands to PRU

Definition at line 167 of file pruio_c_wrapper.h.

uint32 PruIo::PruIRam

the PRU instruction ram to load

Definition at line 167 of file pruio_c_wrapper.h.

uint32 PruIo::PruDRam

the PRU data ram

Definition at line 167 of file pruio_c_wrapper.h.

int16 PruIo::ArmPruInt

the interrupt to send

Definition at line 175 of file pruio_c_wrapper.h.

int16 PruIo::ChAz

number of active channels

Definition at line 175 of file pruio_c_wrapper.h.

struct __pruss_intc_initdata PruIo::IntcInit

interrupt settings (we also set default interrupts, so that the other PRUSS can be used in parallel)

Definition at line 179 of file pruio_c_wrapper.h.

struct GpioSet* PruIo::Gpio

pointer to GPIO structure (current values)

Definition at line 180 of file pruio_c_wrapper.h.

struct GpioSet PruIo::GpioInit[PRUIO_GPIO_AZ+1]

initial GPIO definitions

Definition at line 181 of file pruio_c_wrapper.h.

uint8 PruIo::BallGpio
Initial value:
= {
32, 33, 34, 35, 36, 37, 38, 39, 22, 23
, 26, 27, 44, 45, 46, 47, 48, 49, 50, 51
, 52, 53, 54, 55, 56, 57, 58, 59, 30, 31
, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79
, 80, 81, 8, 9, 10, 11, 86, 87, 88, 89
, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
, 100, 16, 17, 21, 28, 105, 106, 82, 83, 84
, 85, 29, 0, 1, 2, 3, 4, 5, 6, 7
, 40, 41, 42, 43, 12, 13, 14, 15, 101, 102
, 110, 111, 112, 113, 114, 115, 116, 117, 19, 20}

list of GPIO numbers, corresponding to ball index

Definition at line 182 of file pruio_c_wrapper.h.

AdcSteps PruIo::St_p[17+1]

step configuration (charge step + 16 steps + idle step, by default steps 1 to 8 are used for AIN0 to AIN7)

Definition at line 123 of file pruio.bi.

uint32_PTR PruIo::DRam

pointer to access PRU DRam

Definition at line 125 of file pruio.bi.

ANY_PTR PruIo::ERam

pointer to read PRU external ram

Definition at line 128 of file pruio.bi.

ANY_PTR PruIo::BallOrg

buffer pointer for original Ball configuration

Definition at line 128 of file pruio.bi.

uint32_PTR PruIo::AdcOrg

buffer pointer for original ADC configuration (= 0 in case of ADC down at startup)

Definition at line 130 of file pruio.bi.

uint32_PTR PruIo::GpioOrg

buffer pointer for original GPIO configuration

Definition at line 130 of file pruio.bi.

uint16_PTR PruIo::Value

pointer to read sampled ADC input data

Definition at line 132 of file pruio.bi.

uint8_PTR PruIo::BallRef

pointer to ball reference (GPIO# for CPU pins or lock)

Definition at line 133 of file pruio.bi.

uint8_PTR PruIo::BallConf

pointer to ball configuration (CPU pin muxing)

Definition at line 133 of file pruio.bi.

ZSTRING_PTR PruIo::Errr = 0

pointer for error messages

Definition at line 135 of file pruio.bi.

tpruss_intc_initdata PruIo::IntcInit
Initial value:
=
TYPE<tpruss_intc_initdata>(
{ PRU0_PRU1_INTERRUPT
, PRU1_PRU0_INTERRUPT
, PRU0_ARM_INTERRUPT
, PRU1_ARM_INTERRUPT
, ARM_PRU0_INTERRUPT
, ARM_PRU1_INTERRUPT
, CAST(BYTE, -1) },
{ TYPE<tsysevt_to_channel_map>(PRU0_PRU1_INTERRUPT, CHANNEL1)
, TYPE<tsysevt_to_channel_map>(PRU1_PRU0_INTERRUPT, CHANNEL0)
, TYPE<tsysevt_to_channel_map>(PRU0_ARM_INTERRUPT, CHANNEL2)
, TYPE<tsysevt_to_channel_map>(PRU1_ARM_INTERRUPT, CHANNEL3)
, TYPE<tsysevt_to_channel_map>(ARM_PRU0_INTERRUPT, CHANNEL0)
, TYPE<tsysevt_to_channel_map>(ARM_PRU1_INTERRUPT, CHANNEL1)
, TYPE<tsysevt_to_channel_map>(PRUIO_IRPT, PRUIO_CHAN)
, TYPE<tsysevt_to_channel_map>(-1, -1)},
{ TYPE<tchannel_to_host_map>(CHANNEL0, PRU0)
, TYPE<tchannel_to_host_map>(CHANNEL1, PRU1)
, TYPE<tchannel_to_host_map>(CHANNEL2, PRU_EVTOUT0)
, TYPE<tchannel_to_host_map>(CHANNEL3, PRU_EVTOUT1)
, TYPE<tchannel_to_host_map>(PRUIO_CHAN, PRUIO_EMAP)
, TYPE<tchannel_to_host_map>(-1, -1) },
(PRU0_HOSTEN_MASK OR PRU1_HOSTEN_MASK OR
PRU_EVTOUT0_HOSTEN_MASK OR PRU_EVTOUT1_HOSTEN_MASK OR PRUIO_MASK)
)

interrupt settings (we also set default interrupts, so that the other PRUSS can be used in parallel)

Definition at line 149 of file pruio.bi.

GpioSet_PTR PruIo::Gpio

pointer to GPIO structure (current values)

Definition at line 177 of file pruio.bi.

GpioSet PruIo::GpioInit[PRUIO_GPIO_AZ+1]
Initial value:
= {
TYPE<GpioSet>(&h44E07100uL, &h44E00408uL, 0, 0, 0, 0, 0, 0)
, TYPE<GpioSet>(&h4804C100uL, &h44E000ACuL, 0, 0, 0, 0, 0, 0)
, TYPE<GpioSet>(&h481AC100uL, &h44E000B0uL, 0, 0, 0, 0, 0, 0)
, TYPE<GpioSet>(&h481AE100uL, &h44E000B4uL, 0, 0, 0, 0, 0, 0)
}

initial GPIO definitions

Definition at line 179 of file pruio.bi.


The documentation for this class was generated from the following files: