pac1944 2.0.0.0
PAC1944 Click Driver

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

Topics

 PAC1944 Registers List
 List of registers of PAC1944 Click driver.
 
 PAC1944 Registers Settings
 Settings for registers of PAC1944 Click driver.
 
 PAC1944 MikroBUS Map
 MikroBUS pin mapping of PAC1944 Click driver.
 
 Meas_sel
 
 Ch_sel
 
 Avg_sel
 
 Meas_mode
 
 State
 

Functions

void pac1944_cfg_setup (pac1944_cfg_t *cfg)
 PAC1944 configuration object setup function.
 
err_t pac1944_init (pac1944_t *ctx, pac1944_cfg_t *cfg)
 PAC1944 initialization function.
 
void pac1944_default_cfg (pac1944_t *ctx)
 PAC1944 default configuration function.
 
void pac1944_set_slow_state (pac1944_t *ctx, uint8_t state)
 PAC1944 set slow state function.
 
void pac1944_device_state (pac1944_t *ctx, uint8_t state)
 PAC1944 set device state function.
 
uint8_t pac1944_get_alert_state (pac1944_t *ctx)
 PAC1944 get alert state function.
 
err_t pac1944_generic_write (pac1944_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 PAC1944 I2C writing function.
 
err_t pac1944_generic_read (pac1944_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 PAC1944 I2C reading function.
 
void pac1944_setup_config (pac1944_t *ctx, pac1944_setup_t cfg_data)
 PAC1944 setup config function.
 
void pac1944_set_address_pointer (pac1944_t *ctx, uint8_t reg_addr)
 PAC1944 set address pointer function.
 
uint8_t pac1944_read_last_accessed_register (pac1944_t *ctx)
 PAC1944 last accessed register read function.
 
void pac1944_general_refresh_cmd (pac1944_t *ctx)
 PAC1944 general refresh command.
 
void pac1944_refresh_cmd (pac1944_t *ctx)
 PAC1944 refresh command.
 
void pac1944_volatile_refresh_cmd (pac1944_t *ctx)
 PAC1944 volatile refresh command.
 
uint32_t pac1944_get_accumulator_count (pac1944_t *ctx)
 PAC1944 accumulator count function.
 
void pac1944_get_accumulator_output (pac1944_t *ctx, uint8_t ch_sel, uint8_t *acc_out)
 PAC1944 get accumulator output function.
 
uint32_t pac1944_get_measurement (pac1944_t *ctx, uint8_t meas_sel, uint8_t ch_sel, uint8_t avg_sel)
 PAC1944 get measurement function.
 
float pac1944_get_calc_measurement (pac1944_t *ctx, uint8_t meas_sel, uint8_t ch_sel, uint8_t avg_sel, uint8_t meas_mode)
 PAC1944 get calculated measurement function.
 

Detailed Description

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

◆ pac1944_cfg_setup()

void pac1944_cfg_setup ( pac1944_cfg_t * cfg)

PAC1944 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ pac1944_default_cfg()

void pac1944_default_cfg ( pac1944_t * ctx)

PAC1944 default configuration function.

This function executes a default configuration of PAC1944 click board.

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
Note
Default config enables all channels. Channel 1 is set to work in bipolar full scale range mode. Channel 2 is set to bipolar half scale range mode. Channels 3 and 4 are configured to unipolar full scale range mode. Sampling frequency is set to 1024 SPS and pin configuration for PAC1944 are default.

◆ pac1944_device_state()

void pac1944_device_state ( pac1944_t * ctx,
uint8_t state )

PAC1944 set device state function.

This function sets the state of en pin.

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
[in]state: Pin state.
  • 0 ( PAC1944_DEV_PWR_DWN ) - Sets the PAC1944 in power down mode,
  • 1 ( PAC1944_DEV_ENABLE ) - Sets the PAC1944 in normal operating mode.
Note
None.

◆ pac1944_general_refresh_cmd()

void pac1944_general_refresh_cmd ( pac1944_t * ctx)

PAC1944 general refresh command.

This function result is identical to the REFRESH command, but it is used with the I2C General Call address (0000 000).

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
Note
This allows the user to issue a REFRESH command to all of the PAC19xx devices in the system with a single command.

◆ pac1944_generic_read()

err_t pac1944_generic_read ( pac1944_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

PAC1944 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 pac1944_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.

◆ pac1944_generic_write()

err_t pac1944_generic_write ( pac1944_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

PAC1944 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 pac1944_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.

◆ pac1944_get_accumulator_count()

uint32_t pac1944_get_accumulator_count ( pac1944_t * ctx)

PAC1944 accumulator count function.

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

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
Returns
The accumulator count value.
Note
None.

◆ pac1944_get_accumulator_output()

void pac1944_get_accumulator_output ( pac1944_t * ctx,
uint8_t ch_sel,
uint8_t * acc_out )

PAC1944 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 pac1944_t object definition for detailed explanation.
[in]ch_sel: Channel selection.
  • 1 ( PAC1944_CH_SEL_CH_1 ) - Sets the channel 1 of the PAC1944,
  • 2 ( PAC1944_CH_SEL_CH_2 ) - Sets the channel 2 of the PAC1944,
  • 3 ( PAC1944_CH_SEL_CH_3 ) - Sets the channel 3 of the PAC1944,
  • 4 ( PAC1944_CH_SEL_CH_4 ) - Sets the channel 4 of the PAC1944.
[out]acc_out: Pointer to accumulator output data store.
Note
None.

◆ pac1944_get_alert_state()

uint8_t pac1944_get_alert_state ( pac1944_t * ctx)

PAC1944 get alert state function.

This function checks the state of int pin.

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
Returns
  • 0 ( PAC1944_ALERT_ACTIVE ) - Alert triggered,
  • 1 ( PAC1944_ALERT_INACTIVE ) - Alert on standby.
Note
None.

◆ pac1944_get_calc_measurement()

float pac1944_get_calc_measurement ( pac1944_t * ctx,
uint8_t meas_sel,
uint8_t ch_sel,
uint8_t avg_sel,
uint8_t meas_mode )

PAC1944 get calculated measurement function.

This function returns calculated measurement depending on the settings.

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
[in]meas_sel: Measurement selection.
  • 0 ( PAC1944_MEAS_SEL_V_SOURCE ) - Sets the voltage measurement,
  • 1 ( PAC1944_MEAS_SEL_I_SENSE ) - Sets the current measurement,
  • 2 ( PAC1944_MEAS_SEL_P_SENSE ) - Sets the power measurement.
[in]ch_sel: Channel selection.
  • 1 ( PAC1944_CH_SEL_CH_1 ) - Sets the channel 1 of the PAC1944,
  • 2 ( PAC1944_CH_SEL_CH_2 ) - Sets the channel 2 of the PAC1944,
  • 3 ( PAC1944_CH_SEL_CH_3 ) - Sets the channel 3 of the PAC1944,
  • 4 ( PAC1944_CH_SEL_CH_4 ) - Sets the channel 4 of the PAC1944.
[in]avg_sel: Sets the averaging mode of measurements.
  • 0 ( PAC1944_AVG_SEL_DISABLE ) - Results are measured only once,
  • 1 ( PAC1944_AVG_SEL_ENABLE ) - Result is averaged from 8 most recent measurements.
[in]meas_mode: Measure mode selection.
  • 0 ( PAC1944_MEAS_MODE_UNIPOLAR_FSR ) - Unipolar measurement mode,
  • 1 ( PAC1944_MEAS_MODE_BIPOLAR_FSR ) - Bipolar measurement mode,
  • 2 ( PAC1944_MEAS_MODE_BIPOLAR_HALF_FSR ) - Bipolar measurement mode reduced by half.
Returns
Calculated measurement data.
Note
Measure mode has to match the configuration of the selected channel in order to return the correct calculated measurement data.

◆ pac1944_get_measurement()

uint32_t pac1944_get_measurement ( pac1944_t * ctx,
uint8_t meas_sel,
uint8_t ch_sel,
uint8_t avg_sel )

PAC1944 get measurement function.

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

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
[in]meas_sel: Measurement selection.
  • 0 ( PAC1944_MEAS_SEL_V_SOURCE ) - Sets the voltage measurement,
  • 1 ( PAC1944_MEAS_SEL_I_SENSE ) - Sets the current measurement,
  • 2 ( PAC1944_MEAS_SEL_P_SENSE ) - Sets the power measurement.
[in]ch_sel: Channel selection.
  • 1 ( PAC1944_CH_SEL_CH_1 ) - Sets the channel 1 of the PAC1944,
  • 2 ( PAC1944_CH_SEL_CH_2 ) - Sets the channel 2 of the PAC1944,
  • 3 ( PAC1944_CH_SEL_CH_3 ) - Sets the channel 3 of the PAC1944,
  • 4 ( PAC1944_CH_SEL_CH_4 ) - Sets the channel 4 of the PAC1944.
[in]avg_sel: Sets the averaging mode of measurements.
  • 0 ( PAC1944_AVG_SEL_DISABLE ) - Results are measured only once,
  • 1 ( PAC1944_AVG_SEL_ENABLE ) - Result is acquired from 8 most recent measurements.
Returns
Raw measurement data.
Note
None.

◆ pac1944_init()

err_t pac1944_init ( pac1944_t * ctx,
pac1944_cfg_t * cfg )

PAC1944 initialization function.

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

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

◆ pac1944_read_last_accessed_register()

uint8_t pac1944_read_last_accessed_register ( pac1944_t * ctx)

PAC1944 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 pac1944_t object definition for detailed explanation.
Returns
The data from the last accessed register.
Note
None.

◆ pac1944_refresh_cmd()

void pac1944_refresh_cmd ( pac1944_t * ctx)

PAC1944 refresh command.

The readable registers for the VBUS, VSENSE, Power, accumulator outputs and accumulator count are updated by the REFRESH command and the values will be static until the next REFRESH command.

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
Note
The result registers may be read by the master at any time and will retain the same values until the next REFRESH command is sent. This function has 1 ms delay included within.

◆ pac1944_set_address_pointer()

void pac1944_set_address_pointer ( pac1944_t * ctx,
uint8_t reg_addr )

PAC1944 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 pac1944_t object definition for detailed explanation.
[in]reg_addr: Targeted register address.
Note
None.

◆ pac1944_set_slow_state()

void pac1944_set_slow_state ( pac1944_t * ctx,
uint8_t state )

PAC1944 set slow state function.

This function sets the state of slw pin.

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
[in]state: Pin state.
  • 0 ( PAC1944_SLOW_STATE_OFF ) - Disables the 8 sps sampling on all channels,
  • 1 ( PAC1944_SLOW_STATE_ON ) - Enables the 8 sps sampling on all channels.
Note
None.

◆ pac1944_setup_config()

void pac1944_setup_config ( pac1944_t * ctx,
pac1944_setup_t cfg_data )

PAC1944 setup config function.

This function checks the state of int pin.

Parameters
[in]ctx: Click context object. See pac1944_t object definition for detailed explanation.
[in]cfg_data: Configuration for setup of the device.
Note
None.

◆ pac1944_volatile_refresh_cmd()

void pac1944_volatile_refresh_cmd ( pac1944_t * ctx)

PAC1944 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 pac1944_t object definition for detailed explanation.
Note
This function has 1 ms delay included within.