
Embedded Metering Library API
5.5
Embedded Metering Library API
In this section the API of the embedded metering library will be introduced.
The metrology library communicates to the user application utilizing function calls, callbacks and
application level calibration functions. Functions calls are the actual call to access the functionalities and
readings provided by the embedded metering. Callbacks are predefined functions called from the
embedded metering library to the user application. Application-level calibration functions are the functions
from user application to access calibration parameters and for the definition of default calibration
parameter.
5.5.1 Embedded Metering Library Function calls
Functions calls to interface to metrology library is defined in metrology-readings.h and metrology-
foreground.h, which provides access to:
•
Metrology engine control, which includes:
–
Initialize the metrology library and ADC hardware
–
Initialize the metrology library with default calibration parameter
•
Performing metrology calculations with data collected by background processing
•
Reading result from metrology calculations
5.5.1.1
Functions for Metrology Engine Control
5.5.1.1.1 int metrology_init (void)
Check if PGAIN in the calibration parameter memory is 0xFFFF, if true copy the default calibration
parameter to calibration parameter memory. Skip copying otherwise.
Parameter: none
Return: 0xFFFF if calibration parameter memory is initialized with default calibration parameters, 0x0000 if
not.
5.5.1.1.2 int metrology_init_from_nv_data (void)
Initialize the metrology engine’s dc filter with calibration parameter loaded to proper memory variables,
initialize the scaling factor of wire resistance compensation and scaling factor of inlet capacitor
compensation.
Parameter: none
Return: Always 0x0000
5.5.1.1.3 void align_metrology_with_calibration_data (void)
reinitialize the metrology related ADC channels with proper phase correction.
Parameter: none
Return: none
5.5.1.1.4 void metrology_switch_to_normal_mode (void)
Initialize the metrology related ADC channels with proper phase correction, Set system to run in normal
mode
Parameter: none
Return: none
37
SLAU587 – August 2014
Firmware and Embedded Metering Library API
Copyright © 2014, Texas Instruments Incorporated