pac1720 2.0.0.0
PAC1720 Click Driver

API for configuring and manipulating PAC1720 Click driver. More...

Topics

 PAC1720 Registers List
 List of registers of PAC1720 Click driver.
 
 PAC1720 Registers Settings
 Settings for registers of PAC1720 Click driver.
 
 PAC1720 MikroBUS Map
 MikroBUS pin mapping of PAC1720 Click driver.
 

Functions

void pac1720_cfg_setup (pac1720_cfg_t *cfg)
 PAC1720 configuration object setup function.
 
err_t pac1720_init (pac1720_t *ctx, pac1720_cfg_t *cfg)
 PAC1720 initialization function.
 
err_t pac1720_default_cfg (pac1720_t *ctx)
 PAC1720 default configuration function.
 
err_t pac1720_write_block (pac1720_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 PAC1720 write block function.
 
err_t pac1720_read_block (pac1720_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 PAC1720 read block function.
 
err_t pac1720_write_byte (pac1720_t *ctx, uint8_t reg, uint8_t data_in)
 PAC1720 write byte function.
 
err_t pac1720_read_byte (pac1720_t *ctx, uint8_t reg, uint8_t *data_out)
 PAC1720 read byte function.
 
err_t pac1720_set_address_pointer (pac1720_t *ctx, uint8_t reg)
 PAC1720 set address pointer function.
 
err_t pac1720_read_last_accessed_register (pac1720_t *ctx, uint8_t *data_out)
 PAC1720 read last accessed register function.
 
err_t pac1720_set_slave_address (pac1720_t *ctx, uint8_t slave_address)
 PAC1720 set slave address function.
 
uint8_t pac1720_get_int_pin (pac1720_t *ctx)
 PAC1720 get int pin function.
 
err_t pac1720_check_communication (pac1720_t *ctx)
 PAC1720 check communication function.
 
err_t pac1720_set_vsource_config (pac1720_t *ctx, pac1720_ch_sel_t ch, pac1720_sample_time_t stime, pac1720_avg_t avg)
 PAC1720 set vsource config function.
 
err_t pac1720_set_vsense_config (pac1720_t *ctx, pac1720_ch_sel_t ch, pac1720_sample_time_t stime, pac1720_avg_t avg, pac1720_cs_rng_t cs_rng)
 PAC1720 set vsense config function.
 
err_t pac1720_get_measurements (pac1720_t *ctx, pac1720_ch_sel_t ch, float *voltage, float *current, float *power)
 PAC1720 get measurements function.
 

Detailed Description

API for configuring and manipulating PAC1720 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

◆ pac1720_cfg_setup()

void pac1720_cfg_setup ( pac1720_cfg_t * cfg)

PAC1720 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ pac1720_check_communication()

err_t pac1720_check_communication ( pac1720_t * ctx)

PAC1720 check communication function.

This function checks the communication by reading and verifying the product ID.

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

◆ pac1720_default_cfg()

err_t pac1720_default_cfg ( pac1720_t * ctx)

PAC1720 default configuration function.

This function executes a default configuration of PAC1720 click board.

Parameters
[in]ctx: Click context object. See pac1720_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.

◆ pac1720_get_int_pin()

uint8_t pac1720_get_int_pin ( pac1720_t * ctx)

PAC1720 get int pin function.

This function returns the INT pin logic state.

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

◆ pac1720_get_measurements()

err_t pac1720_get_measurements ( pac1720_t * ctx,
pac1720_ch_sel_t ch,
float * voltage,
float * current,
float * power )

PAC1720 get measurements function.

This function reads voltage, current, and power from the selected channel.

Parameters
[in]ctx: Click context object. See pac1720_t object definition for detailed explanation.
[in]ch: Channel selection. See pac1720_ch_sel_t enum definition for detailed explanation.
[out]voltage: Voltage [V].
[out]current: Current [A].
[out]power: Power [W].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
Vsource and Vsense must be configured with pac1720_set_vsource_config and pac1720_set_vsense_config functions before calling this function.

◆ pac1720_init()

err_t pac1720_init ( pac1720_t * ctx,
pac1720_cfg_t * cfg )

PAC1720 initialization function.

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

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

◆ pac1720_read_block()

err_t pac1720_read_block ( pac1720_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

PAC1720 read block function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See pac1720_t object definition for detailed explanation.
[in]reg: Start register address.
[out]rx_buf: Output read data.
[in]rx_len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1720_read_byte()

err_t pac1720_read_byte ( pac1720_t * ctx,
uint8_t reg,
uint8_t * data_out )

PAC1720 read byte function.

This function reads single data byte from the selected register.

Parameters
[in]ctx: Click context object. See pac1720_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.

◆ pac1720_read_last_accessed_register()

err_t pac1720_read_last_accessed_register ( pac1720_t * ctx,
uint8_t * data_out )

PAC1720 read last accessed register function.

This function allows user to read the last accessed register address, on which the internal address pointer is currently set.

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

◆ pac1720_set_address_pointer()

err_t pac1720_set_address_pointer ( pac1720_t * ctx,
uint8_t reg )

PAC1720 set address pointer function.

This function allows user to set the internal address pointer on the desired register.

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

◆ pac1720_set_slave_address()

err_t pac1720_set_slave_address ( pac1720_t * ctx,
uint8_t slave_address )

PAC1720 set slave address function.

This function sets the slave address for I2C communication.

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

◆ pac1720_set_vsense_config()

err_t pac1720_set_vsense_config ( pac1720_t * ctx,
pac1720_ch_sel_t ch,
pac1720_sample_time_t stime,
pac1720_avg_t avg,
pac1720_cs_rng_t cs_rng )

PAC1720 set vsense config function.

This function sets the Voltage Sense configuration (sample time, average samples, and sampling range) for the selected channel.

Parameters
[in]ctx: Click context object. See pac1720_t object definition for detailed explanation.
[in]ch: Channel selection. See pac1720_ch_sel_t enum definition for detailed explanation.
[in]stime: Sample time selection. See pac1720_sample_time_t enum definition for detailed explanation.
[in]avg: Average samples selection. See pac1720_avg_t enum definition for detailed explanation.
[in]cs_rng: Current sampling range selection. See pac1720_cs_rng_t enum definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1720_set_vsource_config()

err_t pac1720_set_vsource_config ( pac1720_t * ctx,
pac1720_ch_sel_t ch,
pac1720_sample_time_t stime,
pac1720_avg_t avg )

PAC1720 set vsource config function.

This function sets the Voltage Source configuration (sample time and average samples) for the selected channel.

Parameters
[in]ctx: Click context object. See pac1720_t object definition for detailed explanation.
[in]ch: Channel selection. See pac1720_ch_sel_t enum definition for detailed explanation.
[in]stime: Sample time selection. See pac1720_sample_time_t enum definition for detailed explanation.
[in]avg: Average samples selection. See pac1720_avg_t enum definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1720_write_block()

err_t pac1720_write_block ( pac1720_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

PAC1720 write block function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See pac1720_t object definition for detailed explanation.
[in]reg: Start register address.
[in]tx_buf: Data to be written.
[in]tx_len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1720_write_byte()

err_t pac1720_write_byte ( pac1720_t * ctx,
uint8_t reg,
uint8_t data_in )

PAC1720 write byte function.

This function writes single data byte to the selected register.

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