pwrmeter3 2.1.0.0
PWR Meter 3 Click Driver

API for configuring and manipulating PWR Meter 3 Click driver. More...

Topics

 PWR Meter 3 Registers List
 List of registers of PWR Meter 3 Click driver.
 
 PWR Meter 3 Registers Settings
 Settings for registers of PWR Meter 3 Click driver.
 
 PWR Meter 3 MikroBUS Map
 MikroBUS pin mapping of PWR Meter 3 Click driver.
 

Functions

void pwrmeter3_cfg_setup (pwrmeter3_cfg_t *cfg)
 PWR Meter 3 configuration object setup function.
 
err_t pwrmeter3_init (pwrmeter3_t *ctx, pwrmeter3_cfg_t *cfg)
 PWR Meter 3 initialization function.
 
err_t pwrmeter3_default_cfg (pwrmeter3_t *ctx)
 PWR Meter 3 default configuration function.
 
err_t pwrmeter3_write_register (pwrmeter3_t *ctx, uint8_t reg, uint32_t data_in)
 PWR Meter 3 write register function.
 
err_t pwrmeter3_read_register (pwrmeter3_t *ctx, uint8_t reg, uint32_t *data_out)
 PWR Meter 3 read register function.
 
uint8_t pwrmeter3_get_dio0_pin (pwrmeter3_t *ctx)
 PWR Meter 3 get dio0 pin function.
 
uint8_t pwrmeter3_get_dio1_pin (pwrmeter3_t *ctx)
 PWR Meter 3 get dio1 pin function.
 
void pwrmeter3_enable_device (pwrmeter3_t *ctx)
 PWR Meter 3 enable device function.
 
void pwrmeter3_disable_device (pwrmeter3_t *ctx)
 PWR Meter 3 disable device function.
 
err_t pwrmeter3_allow_write_access (pwrmeter3_t *ctx)
 PWR Meter 3 allow write access function.
 
err_t pwrmeter3_deny_write_access (pwrmeter3_t *ctx)
 PWR Meter 3 deny write access function.
 
err_t pwrmeter3_set_bypass_n_state (pwrmeter3_t *ctx, uint8_t state)
 PWR Meter 3 set bypass n state function.
 
err_t pwrmeter3_set_num_samples (pwrmeter3_t *ctx, uint16_t num_samples)
 PWR Meter 3 set num samples function.
 
err_t pwrmeter3_set_dio0_sel (pwrmeter3_t *ctx, uint8_t dio_sel)
 PWR Meter 3 set dio0 sel function.
 
err_t pwrmeter3_set_dio1_sel (pwrmeter3_t *ctx, uint8_t dio_sel)
 PWR Meter 3 set dio1 sel function.
 
err_t pwrmeter3_set_ovrms_threshold (pwrmeter3_t *ctx, uint8_t ovrms)
 PWR Meter 3 set ovrms threshold function.
 
err_t pwrmeter3_set_uvrms_threshold (pwrmeter3_t *ctx, uint8_t uvrms)
 PWR Meter 3 set uvrms threshold function.
 
err_t pwrmeter3_read_rms (pwrmeter3_t *ctx, float *v_rms, float *i_rms)
 PWR Meter 3 read rms function.
 
err_t pwrmeter3_read_average_rms (pwrmeter3_t *ctx, float *v_rms, float *i_rms, uint16_t num_avg)
 PWR Meter 3 read average rms function.
 

Detailed Description

API for configuring and manipulating PWR Meter 3 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ pwrmeter3_allow_write_access()

err_t pwrmeter3_allow_write_access ( pwrmeter3_t * ctx)

PWR Meter 3 allow write access function.

This function allows writing to registers by setting the correct write access code.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pwrmeter3_cfg_setup()

void pwrmeter3_cfg_setup ( pwrmeter3_cfg_t * cfg)

PWR Meter 3 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See pwrmeter3_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ pwrmeter3_default_cfg()

err_t pwrmeter3_default_cfg ( pwrmeter3_t * ctx)

PWR Meter 3 default configuration function.

This function executes a default configuration of PWR Meter 3 click board.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ pwrmeter3_deny_write_access()

err_t pwrmeter3_deny_write_access ( pwrmeter3_t * ctx)

PWR Meter 3 deny write access function.

This function denies writing to registers by setting the wrong write access code.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pwrmeter3_disable_device()

void pwrmeter3_disable_device ( pwrmeter3_t * ctx)

PWR Meter 3 disable device function.

This function disables device by setting the EN pin to HIGH logic state.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ pwrmeter3_enable_device()

void pwrmeter3_enable_device ( pwrmeter3_t * ctx)

PWR Meter 3 enable device function.

This function enables device by setting the EN pin to LOW logic state.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ pwrmeter3_get_dio0_pin()

uint8_t pwrmeter3_get_dio0_pin ( pwrmeter3_t * ctx)

PWR Meter 3 get dio0 pin function.

This function returns the DIO0 pin logic state.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ pwrmeter3_get_dio1_pin()

uint8_t pwrmeter3_get_dio1_pin ( pwrmeter3_t * ctx)

PWR Meter 3 get dio1 pin function.

This function returns the DIO1 pin logic state.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ pwrmeter3_init()

err_t pwrmeter3_init ( pwrmeter3_t * ctx,
pwrmeter3_cfg_t * cfg )

PWR Meter 3 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See pwrmeter3_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pwrmeter3_read_average_rms()

err_t pwrmeter3_read_average_rms ( pwrmeter3_t * ctx,
float * v_rms,
float * i_rms,
uint16_t num_avg )

PWR Meter 3 read average rms function.

This function reads the voltage and current RMS measurements averaged from a specified number of samples.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[out]v_rms: Averaged voltage RMS measurement in Volts.
[out]i_rms: Averaged current RMS measurement in Ampers.
[in]num_avg: Number of samples for averaging RMS measurements.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pwrmeter3_read_register()

err_t pwrmeter3_read_register ( pwrmeter3_t * ctx,
uint8_t reg,
uint32_t * data_out )

PWR Meter 3 read register function.

This function reads a 32-bit data from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Output read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pwrmeter3_read_rms()

err_t pwrmeter3_read_rms ( pwrmeter3_t * ctx,
float * v_rms,
float * i_rms )

PWR Meter 3 read rms function.

This function reads the voltage and current RMS measurements.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[out]v_rms: Voltage RMS measurement in Volts.
[out]i_rms: Current RMS measurement in Ampers.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pwrmeter3_set_bypass_n_state()

err_t pwrmeter3_set_bypass_n_state ( pwrmeter3_t * ctx,
uint8_t state )

PWR Meter 3 set bypass n state function.

This function sets whether RMS is calculated based on voltage zero crossing (AC measurement) or predefined num samples (DC measurement).

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]state:
  • 0 - Disable N - RMS is calculated based on voltage zero crossing (AC measurement),
  • 1 - Enable N - RMS is calculated based on predefined num samples (DC measurement),
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Writing to registers must be allowed using pwrmeter3_allow_write_access function.

◆ pwrmeter3_set_dio0_sel()

err_t pwrmeter3_set_dio0_sel ( pwrmeter3_t * ctx,
uint8_t dio_sel )

PWR Meter 3 set dio0 sel function.

This function sets the DIO0 selection. Determines which flags are output on the DIO0 pin.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]dio_sel:
  • 0 - ZC: zero crossing,
  • 1 - ovrms: the VRMS overvoltage flag (Default).
  • 2 - uvrms: the VRMS undervoltage flag.
  • 3 - The OR of ovrms and uvrms (if either flag is triggered, the DIO_0 pin will be asserted).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Writing to registers must be allowed using pwrmeter3_allow_write_access function.

◆ pwrmeter3_set_dio1_sel()

err_t pwrmeter3_set_dio1_sel ( pwrmeter3_t * ctx,
uint8_t dio_sel )

PWR Meter 3 set dio1 sel function.

This function sets the DIO1 selection. Determines which flags are output on the DIO1 pin.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]dio_sel:
  • 0 - OCF: Overcurrent fault,
  • 1 - uvrms: the VRMS undervoltage flag (Default),
  • 2 - ovrms: the VRMS overvoltage flag,
  • 3 - The OR of ovrms and uvrms, and OCF_LAT [Latched Overcurrent Fault].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Writing to registers must be allowed using pwrmeter3_allow_write_access function.

◆ pwrmeter3_set_num_samples()

err_t pwrmeter3_set_num_samples ( pwrmeter3_t * ctx,
uint16_t num_samples )

PWR Meter 3 set num samples function.

This function sets the number of samples for RMS calculations. Bypass N state must be set/true for this to have effect.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]num_samples: 0-1023 samples,
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Writing to registers must be allowed using pwrmeter3_allow_write_access function.

◆ pwrmeter3_set_ovrms_threshold()

err_t pwrmeter3_set_ovrms_threshold ( pwrmeter3_t * ctx,
uint8_t ovrms )

PWR Meter 3 set ovrms threshold function.

This function sets the overvoltage RMS threshold.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]ovrms: 0-63 steps, a single step represents about 9.3V,
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Writing to registers must be allowed using pwrmeter3_allow_write_access function.

◆ pwrmeter3_set_uvrms_threshold()

err_t pwrmeter3_set_uvrms_threshold ( pwrmeter3_t * ctx,
uint8_t uvrms )

PWR Meter 3 set uvrms threshold function.

This function sets the undervoltage RMS threshold.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]uvrms: 0-63 steps, a single step represents about 9.3V,
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Writing to registers must be allowed using pwrmeter3_allow_write_access function.

◆ pwrmeter3_write_register()

err_t pwrmeter3_write_register ( pwrmeter3_t * ctx,
uint8_t reg,
uint32_t data_in )

PWR Meter 3 write register function.

This function writes a desired 32-bit data to the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See pwrmeter3_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: 32-bit data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.