c420mat2 2.1.0.0
c420mat2.h File Reference

This file contains API for 4-20mA T 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"

Go to the source code of this file.

Data Structures

struct  c420mat2_t
 4-20mA T 2 Click context object. More...
 
struct  c420mat2_cfg_t
 4-20mA T 2 Click configuration object. More...
 
struct  c420mat2_status_t
 4-20mA T 2 Click status object. More...
 

Macros

#define C420MAT2_REG_XFER   0x01
 4-20mA T 2 description register.
 
#define C420MAT2_REG_NOP   0x02
 
#define C420MAT2_REG_WR_MODE   0x03
 
#define C420MAT2_REG_DACCODE   0x04
 
#define C420MAT2_REG_ERR_CONFIG   0x05
 
#define C420MAT2_REG_ERR_LOW   0x06
 
#define C420MAT2_REG_ERR_HIGH   0x07
 
#define C420MAT2_REG_RESET   0x08
 
#define C420MAT2_REG_STATUS   0x09
 
#define C420MAT2_CMD_XFER   0x00FF
 4-20mA T 2 description setting.
 
#define C420MAT2_CMD_NOP   0x0000
 
#define C420MAT2_CMD_WR_MODE_DISABLE   0x0000
 
#define C420MAT2_CMD_WR_MODE_ENABLE   0x0001
 
#define C420MAT2_CMD_RETRY_TIMEL_RETRY_TIME_50ms   0x0000
 
#define C420MAT2_CMD_RETRY_TIMEL_RETRY_TIME_100ms   0x0100
 
#define C420MAT2_CMD_RETRY_TIMEL_RETRY_TIME_150ms   0x0200
 
#define C420MAT2_CMD_RETRY_TIMEL_RETRY_TIME_200ms   0x0300
 
#define C420MAT2_CMD_RETRY_TIMEL_RETRY_TIME_250ms   0x0400
 
#define C420MAT2_CMD_RETRY_TIMEL_RETRY_TIME_300ms   0x0500
 
#define C420MAT2_CMD_RETRY_TIMEL_RETRY_TIME_350ms   0x0600
 
#define C420MAT2_CMD_RETRY_TIMEL_RETRY_TIME_400ms   0x0700
 
#define C420MAT2_CMD_DIS_RETRY_LOOP_DISABLE   0x0000
 
#define C420MAT2_CMD_DIS_RETRY_LOOP_ENABLE   0x0080
 
#define C420MAT2_CMD_MASK_LOOP_ERR_DISABLE   0x0000
 
#define C420MAT2_CMD_MASK_LOOP_ERR_ENABLE   0x0040
 
#define C420MAT2_CMD_DIS_LOOP_ERR_ERRB_DISABLE   0x0000
 
#define C420MAT2_CMD_DIS_LOOP_ERR_ERRB_ENABLE   0x0020
 
#define C420MAT2_CMD_MASK_SPI_ERR_DISABLE   0x0000
 
#define C420MAT2_CMD_MASK_SPI_ERR_ENABLE   0x0010
 
#define C420MAT2_CMD_SPI_TIMEOUT_50ms   0x0000
 
#define C420MAT2_CMD_SPI_TIMEOUT_100ms   0x0002
 
#define C420MAT2_CMD_SPI_TIMEOUT_150ms   0x0004
 
#define C420MAT2_CMD_SPI_TIMEOUT_200ms   0x0006
 
#define C420MAT2_CMD_SPI_TIMEOUT_250ms   0x0008
 
#define C420MAT2_CMD_SPI_TIMEOUT_300ms   0x000A
 
#define C420MAT2_CMD_SPI_TIMEOUT_350ms   0x000C
 
#define C420MAT2_CMD_SPI_TIMEOUT_400ms   0x000E
 
#define C420MAT2_CMD_MASK_SPI_TOUT_DISABLE   0x0000
 
#define C420MAT2_CMD_MASK_SPI_TOUT_ENABLE   0x0001
 
#define C420MAT2_CMD_RESET   0xC33C
 
#define C420MAT2_STATUS_DAC_RES_BIT_MASK   0x00E0
 4-20mA T 2 status bitmask.
 
#define C420MAT2_STATUS_ERRLVL_PIN_BIT_MASK   0x0010
 
#define C420MAT2_STATUS_FERR_STS_BIT_MASK   0x0008
 
#define C420MAT2_STATUSSPI_TIMEOUT_ERR_BIT_MASK   0x0004
 
#define C420MAT2_STATUS_LOOP_STS_BIT_MASK   0x0002
 
#define C420MAT2_STATUS_CURR_LOOP_STS_BIT_MASK   0x0001
 
#define C420MAT2_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define C420MAT2_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define C420MAT2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  c420mat2_return_value_t { C420MAT2_OK = 0 , C420MAT2_ERROR = -1 }
 4-20mA T 2 Click return value data. More...
 
enum  c420mat2_status_value_t { C420MAT2_STATUS_OK = 0 , C420MAT2_STATUS_ERROR = 1 }
 4-20mA T 2 Click error status value data. More...
 

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

This file contains API for 4-20mA T 2 Click Driver.

Enumeration Type Documentation

◆ c420mat2_return_value_t

4-20mA T 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
C420MAT2_OK 
C420MAT2_ERROR 

◆ c420mat2_status_value_t

4-20mA T 2 Click error status value data.

Predefined enum values for error status values.

Enumerator
C420MAT2_STATUS_OK 
C420MAT2_STATUS_ERROR