The tcDspPulseIntegrator class is used to interface to the MityDSP pulse integrator core. More...
#include <core/DspPulseIntegrator.h>
Public Types | |
typedef void(* | tfIsrCallback )(int, float) |
Prototype for the ISR callbacks. | |
typedef void(* | tfIsrCallbackWithArg )(int, float, void *) |
Public Member Functions | |
tcDspPulseIntegrator (void *apBaseAddr, int anLevel=gnAutoLevel) | |
This constructor is used to create an interface to the MityDSP Pulse Integrator core located at the specified base address. | |
~tcDspPulseIntegrator () | |
This destructor is used to close up and free tcDspPulseIntegrator resources. | |
void | enableIntegrator (int anIntegrator, bool abState, bool fromISR=false) |
Enables or disables the specified integrator. | |
unsigned int | getNumCycles (int anIntegrator) |
Gets the number of cycles over which the specified integrator will make measurements. | |
unsigned int | setNumCycles (int anIntegrator, unsigned int anNewCycles) |
Sets the number of cycles over which the specified integrator will make measurements. | |
bool | getInterruptEnable (int anIntegrator) |
Gets the state of the interrupt on measurement complete for the specified integrator. | |
void | setInterruptEnable (int anIntegrator, bool abEnable) |
Sets the state of the measurement complete interrupt for the specified integrator. | |
bool | getExtMeasEnable (int anIntegrator) |
Gets the state of the external Measurement Enable signal usage for the specified integrator. | |
void | setExtMeasEnable (int anIntegrator, bool abState) |
Sets the state of the external Measurement Enable signal usage for the specified integrator. | |
void | getOutputPulse (float &afTmeasUsec, float &afTpulseUsec) |
Gets the parameters of the output pulse generator. | |
void | setOutputPulse (float afTmeasUsec, float afTpulseUsec) |
Sets the parameters of the output pulse generator. | |
bool | getMeasurement (int anIntegrator, float &afMeasurementUsec) |
Attempts to get a measurement from the specified integrator. | |
void | registerIsrHandler (int anIntegrator, tfIsrCallback afCallback) |
Registers the user-supplied callback to be run whenever the specified integrator's measurement complete interrupt occurs. | |
void | registerIsrHandler (int anIntegrator, tfIsrCallbackWithArg afCallback, void *apUserArg=NULL) |
Registers the user-supplied callback to be run whenever the specified integrator's measurement complete interrupt occurs. | |
Static Public Member Functions | |
static int | interrupt_dispatch (Arg arMyObject) |
Static interrupt dispatch routine. | |
Public Attributes | |
unsigned int | mnInterruptCount |
ISR counter (debug). | |
Static Public Attributes | |
static const int | gnNumIntegrators = 4 |
Four integrators per core. | |
static const unsigned int | gnMaxCycles = 256 |
Max integration cycles. |
The tcDspPulseIntegrator class is used to interface to the MityDSP pulse integrator core.
Up to 4 integrators may be used, which count the number of EMIF clocks that an external signal is asserted during a measurement period. This measurement period is determined by either an internally generated ouput pulse, or an externally provided measurement enable pulse. To average out jitter errors, the integration may occur over 1-256 measurement periods.
Interrupts may be enabled to signal when a measurement has been completed by any of the integrators.
typedef void(* MityDSP::tcDspPulseIntegrator::tfIsrCallback)(int, float) |
Prototype for the ISR callbacks.
The callback is provided with the integrator number, and the measurement value (in usec, already divided by
typedef void(* MityDSP::tcDspPulseIntegrator::tfIsrCallbackWithArg)(int, float, void *) |
tcDspPulseIntegrator::tcDspPulseIntegrator | ( | void * | apAddress, | |
int | anLevel = gnAutoLevel | |||
) |
This constructor is used to create an interface to the MityDSP Pulse Integrator core located at the specified base address.
An interrupt level may be specified to install a chained ISR at the proper level, otherwise automatic interrupt vectoring is employed.
[in] | apAddress | Base Address of Pulse Integrator core |
[in] | anLevel | Optional interrupt level parameter |
tcDspPulseIntegrator::~tcDspPulseIntegrator | ( | ) |
This destructor is used to close up and free tcDspPulseIntegrator resources.
int tcDspPulseIntegrator::interrupt_dispatch | ( | Arg | ahMyObject | ) | [static] |
Static interrupt dispatch routine.
Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the interrupt dispatcher.
[in] | ahMyObject | The "this->" pointer for the instance of tcDspPulseIntegrator associated with this ISR. |
void tcDspPulseIntegrator::enableIntegrator | ( | int | anIntegrator, | |
bool | abState, | |||
bool | fromISR = false | |||
) |
Enables or disables the specified integrator.
[in] | anIntegrator | The integrator to enable/disable (0 - 3). |
[in] | abState | True to enable integrator. |
[in] | fromISR | True if called from ISR space (default: false). |
unsigned int tcDspPulseIntegrator::getNumCycles | ( | int | anIntegrator | ) |
Gets the number of cycles over which the specified integrator will make measurements.
Values may be 1-256.
[in] | anIntegrator | The integrator whose cycle count is requested. |
unsigned int tcDspPulseIntegrator::setNumCycles | ( | int | anIntegrator, | |
unsigned int | anNewCycles | |||
) |
Sets the number of cycles over which the specified integrator will make measurements.
Values may be 1-256 (values greater than 256 are truncated to 256).
[in] | anIntegrator | The integrator to update (0 - 3). |
[in] | anNewCycles | The new cycle value (1 - 256). |
bool tcDspPulseIntegrator::getInterruptEnable | ( | int | anIntegrator | ) |
Gets the state of the interrupt on measurement complete for the specified integrator.
[in] | anIntegrator | The integrator whose interrupt state is being read (0 - 3). |
void tcDspPulseIntegrator::setInterruptEnable | ( | int | anIntegrator, | |
bool | abEnable | |||
) |
Sets the state of the measurement complete interrupt for the specified integrator.
[in] | anIntegrator | The integrator whose interrupt state is being set (0 - 3). |
[in] | abEnable | True to enable measurement interrupts. |
bool tcDspPulseIntegrator::getExtMeasEnable | ( | int | anIntegrator | ) |
Gets the state of the external Measurement Enable signal usage for the specified integrator.
[in] | anIntegrator | The integrator whose external measurement enable state is being read (0 - 3). |
void tcDspPulseIntegrator::setExtMeasEnable | ( | int | anIntegrator, | |
bool | abState | |||
) |
Sets the state of the external Measurement Enable signal usage for the specified integrator.
Setting the state to True indicates that the integrator should use the external measurement enable pulse to control measurement periods. Setting the state to False indicates that the internal output pulse generator should be used.
[in] | anIntegrator | The integrator whose external measurement enable state is being set (0 - 3). |
[in] | abState | True to use the external Measurement Enable pulse, False to use the internal output pulse generator. |
void tcDspPulseIntegrator::getOutputPulse | ( | float & | afTmeasUsec, | |
float & | afTpulseUsec | |||
) |
Gets the parameters of the output pulse generator.
The pulse is specified by a floating-point measurement time (in usec), as well as the total pulse period (also in usec).
[out] | afTmeasUsec | The output pulse measurement time (in usec) |
[out] | afTpulseUsec | The output pulse total time (in usec) |
void tcDspPulseIntegrator::setOutputPulse | ( | float | afTmeasUsec, | |
float | afTpulseUsec | |||
) |
Sets the parameters of the output pulse generator.
The pulse is specified by providing a floating-point measurement time (in usec), as well as the total pulse period (also in usec).
[in] | afTmeasUsec | The output pulse measurement time (in usec) |
[in] | afTpulseUsec | The output pulse total time (in usec) |
bool tcDspPulseIntegrator::getMeasurement | ( | int | anIntegrator, | |
float & | afMeasurementUsec | |||
) |
Attempts to get a measurement from the specified integrator.
If no measurement is available, false is returned. If a measurement is ready, the return value is set to true, the result is converted from EMIF clocks to usec, and divided by the number of cycles integrated.
[in] | anIntegrator | The integrator to retrieve the measurement from. |
[out] | afMeasurementUsec | The measurement (in usec), already divided by the number of cycles integrated. |
void tcDspPulseIntegrator::registerIsrHandler | ( | int | anIntegrator, | |
tfIsrCallback | afCallback | |||
) |
Registers the user-supplied callback to be run whenever the specified integrator's measurement complete interrupt occurs.
Caution should be used as this callback will execute in ISR context (no DSP/BIOS calls that can potentially block are allowed)
[in] | anIntegrator | The integrator to install the callback for. |
[in] | afCallback | Pointer to the callback routine (or NULL to disable callbacks. |
void tcDspPulseIntegrator::registerIsrHandler | ( | int | anIntegrator, | |
tfIsrCallbackWithArg | afCallback, | |||
void * | apUserArg = NULL | |||
) |
Registers the user-supplied callback to be run whenever the specified integrator's measurement complete interrupt occurs.
Caution should be used as this callback will execute in ISR context (no DSP/BIOS calls that can potentially block are allowed)
[in] | anIntegrator | The integrator to install the callback for. |
[in] | afCallback | Pointer to the callback routine (or NULL to disable callbacks. |
[in] | apUserArg | An argument to be supplied with the callback. |
const int MityDSP::tcDspPulseIntegrator::gnNumIntegrators = 4 [static] |
Four integrators per core.
const unsigned int MityDSP::tcDspPulseIntegrator::gnMaxCycles = 256 [static] |
Max integration cycles.
unsigned int MityDSP::tcDspPulseIntegrator::mnInterruptCount |
ISR counter (debug).