pac1954  2.0.0.0
Modules | Functions
PAC1954 Click Driver

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

Modules

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

Functions

void pac1954_cfg_setup (pac1954_cfg_t *cfg)
 PAC1954 configuration object setup function. More...
 
err_t pac1954_init (pac1954_t *ctx, pac1954_cfg_t *cfg)
 PAC1954 initialization function. More...
 
err_t pac1954_default_cfg (pac1954_t *ctx)
 PAC1954 default configuration function. More...
 
err_t pac1954_generic_write (pac1954_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 PAC1954 I2C writing function. More...
 
err_t pac1954_generic_read (pac1954_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 PAC1954 I2C reading function. More...
 
err_t pac1954_single_write (pac1954_t *ctx, uint8_t reg, uint8_t data_in)
 PAC1954 Single Byte Write Function. More...
 
err_t pac1954_single_read (pac1954_t *ctx, uint8_t reg, uint8_t *data_out)
 PAC1954 Single Byte Read Function. More...
 
err_t pac1954_set_address_pointer (pac1954_t *ctx, uint8_t reg)
 PAC1954 Set Address Pointer Function. More...
 
err_t pac1954_read_last_accessed_register (pac1954_t *ctx, uint8_t *data_out)
 PAC1954 Last Accessed Register Read Function. More...
 
err_t pac1954_refresh_cmd (pac1954_t *ctx)
 PAC1954 Refresh Command. More...
 
err_t pac1954_volatile_refresh_cmd (pac1954_t *ctx)
 PAC1954 Volatile Refresh Command. More...
 
err_t pac1954_get_measurement (pac1954_t *ctx, uint8_t meas_sel, uint8_t ch_sel, uint8_t avg_sel, uint32_t *data_out)
 PAC1954 Get Measurement Function. More...
 
err_t pac1954_get_accumulator_count (pac1954_t *ctx, uint32_t *data_out)
 PAC1954 Get Accumulator Count Function. More...
 
err_t pac1954_get_accumulator_output (pac1954_t *ctx, uint8_t ch_sel, uint8_t *data_out)
 PAC1954 Get Accumulator Output Function. More...
 
err_t pac1954_get_calc_measurement (pac1954_t *ctx, uint8_t meas_sel, uint8_t ch_sel, uint8_t avg_sel, uint8_t meas_mode, float *data_out)
 PAC1954 Get Calculated Measurement Function. More...
 
void pac1954_set_all_channels_sample_at_8_sps (pac1954_t *ctx, uint8_t state)
 PAC1954 Slow Down Sampling Freq Of All Channels Function. More...
 
void pac1954_enable (pac1954_t *ctx, uint8_t state)
 PAC1954 Power Control Function. More...
 
uint8_t pac1954_get_alert2_status (pac1954_t *ctx)
 PAC1954 Get INT Pin State Function. More...
 

Detailed Description

API for configuring and manipulating PAC1954 Click driver.

Function Documentation

◆ pac1954_cfg_setup()

void pac1954_cfg_setup ( pac1954_cfg_t cfg)

PAC1954 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ pac1954_default_cfg()

err_t pac1954_default_cfg ( pac1954_t ctx)

PAC1954 default configuration function.

This function executes a default configuration of PAC1954 click board.

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

◆ pac1954_enable()

void pac1954_enable ( pac1954_t ctx,
uint8_t  state 
)

PAC1954 Power Control Function.

This function executes a power control of the PAC1954 click using EN pin.

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

◆ pac1954_generic_read()

err_t pac1954_generic_read ( pac1954_t ctx,
uint8_t  reg,
uint8_t *  rx_buf,
uint8_t  rx_len 
)

PAC1954 I2C reading 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 pac1954_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.

◆ pac1954_generic_write()

err_t pac1954_generic_write ( pac1954_t ctx,
uint8_t  reg,
uint8_t *  tx_buf,
uint8_t  tx_len 
)

PAC1954 I2C writing 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 pac1954_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.

◆ pac1954_get_accumulator_count()

err_t pac1954_get_accumulator_count ( pac1954_t ctx,
uint32_t *  data_out 
)

PAC1954 Get Accumulator Count Function.

This function can be used to get the accumulator count value.

Parameters
[in]ctx: Click context object. See pac1954_t object definition for detailed explanation.
[out]data_out: The accumulator count value.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1954_get_accumulator_output()

err_t pac1954_get_accumulator_output ( pac1954_t ctx,
uint8_t  ch_sel,
uint8_t *  data_out 
)

PAC1954 Get Accumulator Output Function.

This function can be used to get the accumulator output value for the selected channel.

Parameters
[in]ctx: Click context object. See pac1954_t object definition for detailed explanation.
[in]ch_sel: Channel selector.
[out]data_out: The accumulator output values [7 bytes].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1954_get_alert2_status()

uint8_t pac1954_get_alert2_status ( pac1954_t ctx)

PAC1954 Get INT Pin State Function.

This function checks the state of the INT pin which has role as Alert2 pin by default.

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

◆ pac1954_get_calc_measurement()

err_t pac1954_get_calc_measurement ( pac1954_t ctx,
uint8_t  meas_sel,
uint8_t  ch_sel,
uint8_t  avg_sel,
uint8_t  meas_mode,
float *  data_out 
)

PAC1954 Get Calculated Measurement Function.

This function calls the function for getting the selected measurement data and performs all the necessary calculations to get the measurement value in standard unit.

Parameters
[in]ctx: Click context object. See pac1954_t object definition for detailed explanation.
[in]meas_sel: Measurement data selector.
[in]ch_sel: Channel selector.
[in]avg_sel: Selector for using averaged or one sample data. This parameter will be ignored for reading Power measurement.
[in]meas_mode: Measurement type of data selector.
[out]data_out: The calculated measurement data.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1954_get_measurement()

err_t pac1954_get_measurement ( pac1954_t ctx,
uint8_t  meas_sel,
uint8_t  ch_sel,
uint8_t  avg_sel,
uint32_t *  data_out 
)

PAC1954 Get Measurement Function.

This function can be used to get the target measurement data for the desired channel.

Parameters
[in]ctx: Click context object. See pac1954_t object definition for detailed explanation.
[in]meas_sel: Measurement data selector.
[in]ch_sel: Channel selector.
[in]avg_sel: Selector for using averaged or one sample data. This parameter will be ignored for reading Power measurement.
[out]data_out: The target measurement data.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1954_init()

err_t pac1954_init ( pac1954_t ctx,
pac1954_cfg_t cfg 
)

PAC1954 initialization function.

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

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

◆ pac1954_read_last_accessed_register()

err_t pac1954_read_last_accessed_register ( pac1954_t ctx,
uint8_t *  data_out 
)

PAC1954 Last Accessed Register Read 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 pac1954_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.

◆ pac1954_refresh_cmd()

err_t pac1954_refresh_cmd ( pac1954_t ctx)

PAC1954 Refresh Command.

This function updates the readable registers for the VBUS, VSENSE, Power, accumulator outputs and accumulator count by issuing the REFRESH command. The values will be static until the next REFRESH command.

Parameters
[in]ctx: Click context object. See pac1954_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
These readable registers will be stable within 1 ms from sending the REFRESH command, and may be read by the master at any time up until the next REFRESH command is sent.

◆ pac1954_set_address_pointer()

err_t pac1954_set_address_pointer ( pac1954_t ctx,
uint8_t  reg 
)

PAC1954 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 pac1954_t object definition for detailed explanation.
[in]reg: Register address.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ pac1954_set_all_channels_sample_at_8_sps()

void pac1954_set_all_channels_sample_at_8_sps ( pac1954_t ctx,
uint8_t  state 
)

PAC1954 Slow Down Sampling Freq Of All Channels Function.

This function sets sampling frequency at 8 SPS for all channels using SLW pin.

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

◆ pac1954_single_read()

err_t pac1954_single_read ( pac1954_t ctx,
uint8_t  reg,
uint8_t *  data_out 
)

PAC1954 Single Byte Read Function.

This function reads single data byte from the selected register.

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

◆ pac1954_single_write()

err_t pac1954_single_write ( pac1954_t ctx,
uint8_t  reg,
uint8_t  data_in 
)

PAC1954 Single Byte Write Function.

This function writes single data byte to the selected register.

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

◆ pac1954_volatile_refresh_cmd()

err_t pac1954_volatile_refresh_cmd ( pac1954_t ctx)

PAC1954 Volatile Refresh Command.

If the user wants to read VSENSE and VBUS results, the most recent Power calculation, and/or the accumulator values and count without resetting the accumulators, this command may be sent.

Parameters
[in]ctx: Click context object. See pac1954_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
Sending this command and waiting 1 ms ensures that the VSENSE, VBUS, Power, accumulator, and accumulator count values will be stable.