c420mat2 2.1.0.0
4-20mA T 2 Click Driver

API for configuring and manipulating 4-20mA T 2 Click driver. More...

Topics

 4-20mA T 2 Registers List
 List of registers of 4-20mA T 2 Click driver.
 
 4-20mA T 2 Registers Settings
 Settings for registers of 4-20mA T 2 Click driver.
 
 4-20mA T 2 MikroBUS Map
 MikroBUS pin mapping of 4-20mA T 2 Click driver.
 

Functions

void c420mat2_cfg_setup (c420mat2_cfg_t *cfg)
 4-20mA T 2 configuration object setup function.
 
err_t c420mat2_init (c420mat2_t *ctx, c420mat2_cfg_t *cfg)
 4-20mA T 2 initialization function.
 
err_t c420mat2_default_cfg (c420mat2_t *ctx)
 4-20mA T 2 default configuration function.
 
err_t c420mat2_write_data (c420mat2_t *ctx, uint8_t reg, uint16_t data_in)
 4-20mA T 2 data writing function.
 
err_t c420mat2_read_data (c420mat2_t *ctx, uint8_t cmd, uint16_t *data_out)
 4-20mA T 2 data reading function.
 
err_t c420mat2_protected_write (c420mat2_t *ctx, uint8_t reg, uint16_t data_in)
 4-20mA T 2 protected data writing function.
 
err_t c420mat2_sw_reset (c420mat2_t *ctx)
 4-20mA T 2 soft reset function.
 
err_t c420mat2_set_dac_data (c420mat2_t *ctx, uint16_t dac_output_code)
 4-20mA T 2 set DAC data function.
 
err_t c420mat2_set_lower_limit (c420mat2_t *ctx, float lower_limit_ma)
 4-20mA T 2 set lower limit function.
 
err_t c420mat2_set_upper_limit (c420mat2_t *ctx, float upper_limit_ma)
 4-20mA T 2 set upper limit function.
 
err_t c420mat2_set_output_current (c420mat2_t *ctx, float current_ma)
 4-20mA T 2 set output current function.
 
err_t c420mat2_get_status (c420mat2_t *ctx, c420mat2_status_t *status)
 4-20mA T 2 set status function.
 
uint8_t c420mat2_get_err_pin (c420mat2_t *ctx)
 4-20mA T 2 get error flag pin state function.
 

Detailed Description

API for configuring and manipulating 4-20mA T 2 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

◆ c420mat2_cfg_setup()

void c420mat2_cfg_setup ( c420mat2_cfg_t * cfg)

4-20mA T 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ c420mat2_default_cfg()

err_t c420mat2_default_cfg ( c420mat2_t * ctx)

4-20mA T 2 default configuration function.

This function executes a default configuration of 4-20mA T 2 click board.

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

◆ c420mat2_get_err_pin()

uint8_t c420mat2_get_err_pin ( c420mat2_t * ctx)

4-20mA T 2 get error flag pin state function.

This function get states of the ERR ( INT pin ) of the DAC161S997 16-Bit SPI-Programmable DAC for 4-20 mA Loops on the 4-20mA T 2 Click board™.

Parameters
[in]ctx: Click context object. See c420mat2_t object definition for detailed explanation.
Returns
  • 0 - Low pin state,
  • 1 - High pin state. See #err_t definition for detailed explanation.
Note
None.

◆ c420mat2_get_status()

err_t c420mat2_get_status ( c420mat2_t * ctx,
c420mat2_status_t * status )

4-20mA T 2 set status function.

This functionset set status data object of the DAC161S997 16-Bit SPI-Programmable DAC for 4-20 mA Loops on the 4-20mA T 2 Click board™.

Parameters
[in]ctx: Click context object. See c420mat2_t object definition for detailed explanation.
[out]status: Status data object. (range from 4mA to 20mA).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ c420mat2_init()

err_t c420mat2_init ( c420mat2_t * ctx,
c420mat2_cfg_t * cfg )

4-20mA T 2 initialization function.

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

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

◆ c420mat2_protected_write()

err_t c420mat2_protected_write ( c420mat2_t * ctx,
uint8_t reg,
uint16_t data_in )

4-20mA T 2 protected data writing function.

This function protected writes a desired byte of data to the selected register by using SPI serial interface.

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

◆ c420mat2_read_data()

err_t c420mat2_read_data ( c420mat2_t * ctx,
uint8_t cmd,
uint16_t * data_out )

4-20mA T 2 data reading function.

This function reads a desired byte of data from the selected register by using SPI serial interface.

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

◆ c420mat2_set_dac_data()

err_t c420mat2_set_dac_data ( c420mat2_t * ctx,
uint16_t dac_output_code )

4-20mA T 2 set DAC data function.

This function writes a DAC data to the C420MAT2_REG_DACCODE register of the DAC161S997 16-Bit SPI-Programmable DAC for 4-20 mA Loops on the 4-20mA T 2 Click board™.

Parameters
[in]ctx: Click context object. See c420mat2_t object definition for detailed explanation.
[in]dac_output_code: DAC data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ c420mat2_set_lower_limit()

err_t c420mat2_set_lower_limit ( c420mat2_t * ctx,
float lower_limit_ma )

4-20mA T 2 set lower limit function.

This functionset lower error conditions the output current of the DAC161S997 16-Bit SPI-Programmable DAC for 4-20 mA Loops on the 4-20mA T 2 Click board™.

Parameters
[in]ctx: Click context object. See c420mat2_t object definition for detailed explanation.
[in]lower_limit_ma: Error conditions the output current (range from 0mA to 12mA).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ c420mat2_set_output_current()

err_t c420mat2_set_output_current ( c420mat2_t * ctx,
float current_ma )

4-20mA T 2 set output current function.

This functionset set analog output current transfer over an industry standard 4-20mA current loop of the DAC161S997 16-Bit SPI-Programmable DAC for 4-20 mA Loops on the 4-20mA T 2 Click board™.

Parameters
[in]ctx: Click context object. See c420mat2_t object definition for detailed explanation.
[in]current_ma: Output loop current value (range from 4mA to 20mA).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ c420mat2_set_upper_limit()

err_t c420mat2_set_upper_limit ( c420mat2_t * ctx,
float upper_limit_ma )

4-20mA T 2 set upper limit function.

This functionset upper error conditions the output current of the DAC161S997 16-Bit SPI-Programmable DAC for 4-20 mA Loops on the 4-20mA T 2 Click board™.

Parameters
[in]ctx: Click context object. See c420mat2_t object definition for detailed explanation.
[in]upper_limit_ma: Error conditions the output current (range from 12mA to 20mA).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ c420mat2_sw_reset()

err_t c420mat2_sw_reset ( c420mat2_t * ctx)

4-20mA T 2 soft reset function.

This function performs software reset of the DAC161S997 16-Bit SPI-Programmable DAC for 4-20 mA Loops on the 4-20mA T 2 Click board™.

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

◆ c420mat2_write_data()

err_t c420mat2_write_data ( c420mat2_t * ctx,
uint8_t reg,
uint16_t data_in )

4-20mA T 2 data writing function.

This function writes a desired byte of data to the selected register by using SPI serial interface.

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