no-OS
|
#include "ade9430.h"
#include "adi_pqlib.h"
#include "adi_pqlib_memory.h"
#include "adi_pqlib_profile.h"
#include "pqlib_convert.h"
#include "status.h"
#include <stddef.h>
#include "no_os_circular_buffer.h"
Go to the source code of this file.
Classes | |
struct | EXAMPLE_CONFIG |
struct | PQLIB_EXAMPLE |
Macros | |
#define | PQLIB_MAX_CHANNELS 7 |
#define | ADI_PQLIB_NUM_WAVEFORM_BLOCKS 4 |
#define | PQLIB_MAX_HARMONICS 50 |
#define | PQLIB_MAX_INTER_HARMONICS 50 |
#define | SIZE_OF_INPUT_RTC 19 |
Enumerations | |
enum | PQLIB_STATE { PQLIB_STATE_WAITING_FOR_START_CMD, PQLIB_STATE_WAITING_FOR_TRIGGER, PQLIB_STATE_RUNNING } |
PQLIB Example states. More... | |
enum | VCONSEL_CONFIG { VCONSEL_4W_WYE, VCONSEL_3W_DELTA_VB_VA_NEGVC, VCONSEL_4W_WYE_VB_NEGVA_NEGVC, VCONSEL_4W_DELTA_VB_NEGVA, VCONSEL_4W_DELTA_VA_VB_VC } |
VCONSEL H/W config selection. More... | |
Functions | |
int | pqm_one_cycle (void) |
One complete cycle for IIO callback function. More... | |
int | process_pqlib_error (PQLIB_EXAMPLE *pExample, ADI_PQLIB_RESULT pqlibStatus) |
Prints error message for errors from the library. Serves as an examples on how to handle the errors from the library. More... | |
int | open_pqlib (PQLIB_EXAMPLE *pExample) |
Call adi_pqlib_Open with required buffers. Serves as an example how to call adi_pqlib_Open API. More... | |
int | SyncLibTime (PQLIB_EXAMPLE *pExample, bool checkRtcTime) |
Sets library internal time using RTC time. Serves as an example how to call the APIs. This also syncs the library time to the user provided time. More... | |
int | config_measurement (PQLIB_EXAMPLE *pExample) |
Configures AFE and the library . This serves as an example on how to call APIs adi_pqlib_SetConfig and adi_pqlib_SetCorrectionCoefficients. More... | |
void | set_default_config (EXAMPLE_CONFIG *pConfig) |
Sets default configuration of the example as floating points Note that this function doesn't configure the library or AFE. More... | |
void | populate_event_config (EXAMPLE_CONFIG *pExampleConfig) |
Populates event configuration using user configuration Serves as an example on how to convert thresholds and hysteresis to the form required by the API. More... | |
int | cpy_correction_coeffs (ADI_PQLIB_NOMINAL_FREQUENCY nominalFrequency, ADI_PQLIB_CORR_COEF *pCorrCoef) |
Copies the user provided correction factors to the interface structure. This shows how floating point correction factors can be converted to the format required by adi_pqlib_SetCorrectionCoefficients Requires both current and voltage pointers should be populated. The code assumes numCorrCoef is same for both and if it is less than 40 these are last 'N' coefficients. More... | |
int | wait_for_zero_crossing (PQLIB_EXAMPLE *pExample, ADI_PQLIB_RESULT pqlibStatus) |
Looks at the return code from library and checks whether there is a zero crossing timeout. This is only needed for testing. We wanted to know when actual signal comes and start monitoring test output only after a predefined settling time. More... | |
void | SyncToDip (PQLIB_EXAMPLE *pExample, ADI_PQLIB_RESULT pqlibStatus) |
Sync the time to a dip or interruption event. Serves as an example how to sync to an external time event. More... | |
int | pqm_measurement_init (void) |
Initializes Power Quality Measurement. More... | |
int | pqm_start_measurement (bool waitingForSync) |
Starts Power Quality measurement as per configured cycles. More... | |
int | process_and_prepare_output () |
The function gets AFE input and calls main processing APIs of the library. This also gets the measurement parameter output from the library and displays it on the console. More... | |
Variables | |
PQLIB_EXAMPLE | pqlibExample |
#define ADI_PQLIB_NUM_WAVEFORM_BLOCKS 4 |
#define PQLIB_MAX_CHANNELS 7 |
#define PQLIB_MAX_HARMONICS 50 |
#define PQLIB_MAX_INTER_HARMONICS 50 |
#define SIZE_OF_INPUT_RTC 19 |
enum PQLIB_STATE |
enum VCONSEL_CONFIG |
int config_measurement | ( | PQLIB_EXAMPLE * | pExample | ) |
Configures AFE and the library . This serves as an example on how to call APIs adi_pqlib_SetConfig and adi_pqlib_SetCorrectionCoefficients.
[in] | pExample | - Pointer to structure for example configurations. |
int cpy_correction_coeffs | ( | ADI_PQLIB_NOMINAL_FREQUENCY | nominalFrequency, |
ADI_PQLIB_CORR_COEF * | pCorrCoef | ||
) |
Copies the user provided correction factors to the interface structure. This shows how floating point correction factors can be converted to the format required by adi_pqlib_SetCorrectionCoefficients Requires both current and voltage pointers should be populated. The code assumes numCorrCoef is same for both and if it is less than 40 these are last 'N' coefficients.
[in] | nominalFrequency | - structure for nominal frequency |
[in] | pCorrCoef | - pointer to structure for correctionCoefficients |
int open_pqlib | ( | PQLIB_EXAMPLE * | pExample | ) |
Call adi_pqlib_Open with required buffers. Serves as an example how to call adi_pqlib_Open API.
[in] | pExample | - Pointer to main example structure. |
void populate_event_config | ( | EXAMPLE_CONFIG * | pExampleConfig | ) |
Populates event configuration using user configuration Serves as an example on how to convert thresholds and hysteresis to the form required by the API.
[in] | pExampleConfig | - pointer to structure for example configurations. |
int pqm_measurement_init | ( | void | ) |
Initializes Power Quality Measurement.
int pqm_one_cycle | ( | void | ) |
One complete cycle for IIO callback function.
int pqm_start_measurement | ( | bool | waitingForSync | ) |
Starts Power Quality measurement as per configured cycles.
[in] | waitingForSync | - Flag to indicate whether the code should look for a sync event to synchronize the RTC time. |
int process_and_prepare_output | ( | ) |
The function gets AFE input and calls main processing APIs of the library. This also gets the measurement parameter output from the library and displays it on the console.
This serves as an example for the APIs adi_pqlib_ProcessOneCycle adi_pqlib_ProcessWaveform adi_pqlib_Process1012Cycles adi_pqlib_GetOutputStatus
int process_pqlib_error | ( | PQLIB_EXAMPLE * | pExample, |
ADI_PQLIB_RESULT | pqlibStatus | ||
) |
Prints error message for errors from the library. Serves as an examples on how to handle the errors from the library.
[in] | pExample | - Pointer to PQLIB_EXAMPLE structure. |
[in] | pqlibStatus | - return code for the library. |
void set_default_config | ( | EXAMPLE_CONFIG * | pConfig | ) |
Sets default configuration of the example as floating points Note that this function doesn't configure the library or AFE.
[in] | pConfig | - Pointer to example configuration structure. |
int SyncLibTime | ( | PQLIB_EXAMPLE * | pExample, |
bool | checkRtcTime | ||
) |
Sets library internal time using RTC time. Serves as an example how to call the APIs. This also syncs the library time to the user provided time.
[in] | pExample | - Pointer to example structure. |
[in] | checkRtcTime | - Checks RTC time. |
void SyncToDip | ( | PQLIB_EXAMPLE * | pExample, |
ADI_PQLIB_RESULT | pqlibStatus | ||
) |
Sync the time to a dip or interruption event. Serves as an example how to sync to an external time event.
[in] | pExample | - Pointer to example structure. |
[in] | pqlibStatus | - Status from adi_pqlib_ProcessOneCycle. |
int wait_for_zero_crossing | ( | PQLIB_EXAMPLE * | pExample, |
ADI_PQLIB_RESULT | pqlibStatus | ||
) |
Looks at the return code from library and checks whether there is a zero crossing timeout. This is only needed for testing. We wanted to know when actual signal comes and start monitoring test output only after a predefined settling time.
[in] | pExample | - Pointer to PQLIB_EXAMPLE structure |
[in] | pqlibStatus | - return code for the library |
PQLIB_EXAMPLE pqlibExample |