Structure for ADC subsystem features, containing all functions and variables to handle the subsystem. More...
Public Member Functions | |
AdcUdt (BYVAL_AS_Pruio__PTR) | |
The constructor for the ADC features. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | initialize (BYVAL_AS_UInt8, BYVAL_AS_UInt32, BYVAL_AS_UInt8) |
Initialize the register context after running the pasm_init.p instructions (private). More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | configure (BYVAL_AS_UInt32, BYVAL_AS_UInt32, BYVAL_AS_UInt32, BYVAL_AS_UInt16) |
Configuration of ADC parameters for PRU (private). More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | setStep (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 | 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... | |
Public Attributes | |
Pruio__PTR | Top |
Pointer to the calling PruIo instance. | |
AdcSet_PTR | Init |
Initial subsystem configuration, used in the destructor PruIo::~PruIo. | |
AdcSet_PTR | Conf |
Current subsystem configuration, used in PruIo::config(). | |
UInt32 | Samples |
Number of samples (specifies run mode: 0 = config, 1 = IO mode, >1 = MM mode). | |
UInt32 | TimerVal |
Timer value in [ns]. | |
UInt32 | InitParA |
Offset to read data block offset. | |
UInt16 | LslMode |
Bit shift modus (0 to 4, for 12 to 16 bits). | |
UInt16 | ChAz |
The number of active steps. | |
UInt16_PTR | Value |
Fetched ADC samples. | |
ZSTRING_PTR | E0 = "step number too big" |
Common error message. | |
ZSTRING_PTR | E1 = "channel number too big" |
Common error message. | |
ZSTRING_PTR | E2 = "too much values to skip" |
Common error message. | |
ZSTRING_PTR | E3 = "trigger step not configured" |
Common error message. | |
ZSTRING_PTR | E4 = "invalid step number" |
Common error message. | |
ZSTRING_PTR | E5 = !"ADC not enabled" |
Common error message. | |
Structure for ADC subsystem features, containing all functions and variables to handle the subsystem.
This UDT contains the member function to control the ADC features and the related variables.
Definition at line 95 of file pruio_adc.bi.
AdcUdt::AdcUdt | ( | BYVAL_AS_Pruio__PTR | T | ) |
The constructor for the ADC features.
T | A pointer of the calling PruIo structure. |
The constructor prepares the DRam parameters to run the pasm_init.p instructions. The adress of the subsystem and the adress of the clock registers get prepared, and the index of the last parameter gets stored to compute the offset in the Init and Conf data blocks.
Definition at line 19 of file pruio_adc.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR AdcUdt::configure | ( | 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 |
||
) |
Configuration of ADC parameters for PRU (private).
Samp | The number of samples to fetch (or 1 for IO mode). |
Mask | The step mask to use. |
Tmr | The timer value in ns (ignored in IO mode). |
Mds | The bit encoding modus (0 = 12 bit, ... 4 = 16 bit). |
This is a private function, designed to be called from PruIo::config(). It checks if the ADC subsystem is enabled and prepares parameters in PruIo::DRam. Don't call it directly.
Definition at line 86 of file pruio_adc.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR AdcUdt::initialize | ( | BYVAL_AS_UInt8 | Av = PRUIO_DEF_AVRAGE , |
BYVAL_AS_UInt32 | OpD = PRUIO_DEF_ODELAY , |
||
BYVAL_AS_UInt8 | SaD = PRUIO_DEF_SDELAY |
||
) |
Initialize the register context after running the pasm_init.p instructions (private).
Av | The avaraging for default step configuration. |
OpD | The open delay for default step configuration. |
SaD | The sample delay for default step configuration. |
This is a private function, designed to be called from the main constructor PruIo::PruIo(). It sets the pointers to the Init and Conf structures in the data blocks. And it initializes some register context, if the subsystem woke up and is enabled.
Definition at line 43 of file pruio_adc.bas.
FUNCTION_CDECL_AS_UInt32 AdcUdt::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.
Stp | The step number to use for trigger input (or 0 for all active steps). |
AdcV | The sample value to match (positive checks greater than, negative checks less than). |
Rela | Not zero means AdcV is relative to the sample at start (ignored when Stp = 0). |
Skip | The number of samples to skip (defaults to 0 = zero, max. 1023). |
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 Stp specifies the step number to use for the trigger. This may be an active step (enabled in the PruIo::config() call). Or it can be a further step with customized settings only for trigger purposes (see trigger.bas for an example).
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:
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.)
Definition at line 314 of file pruio_adc.bas.
FUNCTION_CDECL_AS_UInt32 AdcUdt::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).
Ball | The CPU ball number to test. |
GpioV | The state to check (defaults to high = 1). |
Skip | The number of samples to skip (defaults to 0 = zero, max. 1023). |
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 subsystem is waiting in idle mode while the GPIO gets checked.
Definition at line 229 of file pruio_adc.bas.
FUNCTION_CDECL_AS_UInt32 AdcUdt::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.
Stp | The step number to use for trigger input. |
AdcV | The sample value to match (positive check greater than, negative check less than). |
Samp | The number of samples for the pre-trigger. |
Rela | If AdcV is relative to the current input. |
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 subsystem goes through all activated steps while waiting for the trigger event.
Definition at line 398 of file pruio_adc.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR AdcUdt::setStep | ( | 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.
Stp | Step index (0 = step 0 => charge step, 1 = step 1 (=> AIN-0 by default), ..., 17 = idle step)- |
ChN | Channel number to scan (0 = AIN-0, 1 = AIN-1, ...)- |
Av | New value for avaraging (defaults to 4)- |
SaD | New value for sample delay (defaults to 0)- |
OpD | New value for open delay (defaults to 0x98)- |
This function is used to adapt a step configuration. In the constructor, steps 1 to 8 get configured for AIN-0 to AIN-7 (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 |
... | ... |
16 | step 16 |
It's also possible to directly write to the step configuration in member variables AdcSet::St_p (i).Confg
and AdcSet::St_p (i).Delay
. See ARM Reference Guide, chapter 12 for details on ADC configurations.
Definition at line 183 of file pruio_adc.bas.