ph2 2.1.0.0
ph2.h File Reference

This file contains API for pH 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_analog_in.h"
#include "drv_i2c_master.h"
#include "drv_one_wire.h"

Go to the source code of this file.

Data Structures

struct  ph2_t
 pH 2 Click context object. More...
 
struct  ph2_cfg_t
 pH 2 Click configuration object. More...
 

Macros

#define PH2_CMD_CONVERT_TEMPERATURE   0x44
 pH 2 DS18B20 commands list.
 
#define PH2_CMD_WRITE_SCRATCHPAD   0x4E
 
#define PH2_CMD_READ_SCRATCHPAD   0xBE
 
#define PH2_CMD_COPY_SCRATCHPAD   0x48
 
#define PH2_CMD_RECALL_SCRATCHPAD   0xB8
 
#define PH2_CMD_READ_POWER_SUPPLY   0xB4
 
#define PH2_PH_CALCULATION_COEF   0.18
 pH 2 description setting.
 
#define PH2_CONFIG_ADDRESS   0x10
 
#define PH2_ADC_RESOLUTION   0x0FFF
 pH 2 ADC setting.
 
#define PH2_VREF_3V3   3.3
 
#define PH2_VREF_5V   5.0
 
#define PH2_SET_DEV_ADDR   0x4D
 pH 2 device address setting.
 
#define PH2_FAMILY_CODE   0x28
 pH 2 DS18B20 family code value.
 
#define PH2_CONFIG_RESOLUTION_9BIT   0x00
 pH 2 config register settings.
 
#define PH2_CONFIG_RESOLUTION_10BIT   0x20
 
#define PH2_CONFIG_RESOLUTION_11BIT   0x40
 
#define PH2_CONFIG_RESOLUTION_12BIT   0x60
 
#define PH2_CONFIG_RESOLUTION_BIT_MASK   0x60
 
#define PH2_CONFIG_RESERVED_BITS   0x10
 
#define PH2_DATA_RESOLUTION   0.0625
 pH 2 temperature calculation values.
 
#define PH2_DEFAULT_ADDRESS   PH2_CONFIG_ADDRESS
 pH 2 default config values.
 
#define PH2_DEFAULT_RESOLUTION   PH2_CONFIG_RESOLUTION_12BIT
 
#define PH2_DEFAULT_TEMP_HIGH_ALARM   0xFF
 
#define PH2_DEFAULT_TEMP_LOW_ALARM   0x00
 
#define PH2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  ph2_drv_t { PH2_DRV_SEL_ADC , PH2_DRV_SEL_I2C }
 pH 2 Click driver selector. More...
 
enum  ph2_return_value_t { PH2_OK = 0 , PH2_ERROR = -1 }
 pH 2 Click return value data. More...
 

Functions

void ph2_cfg_setup (ph2_cfg_t *cfg)
 pH 2 configuration object setup function.
 
void ph2_drv_interface_selection (ph2_cfg_t *cfg, ph2_drv_t drv_sel)
 pH 2 driver interface setup function.
 
err_t ph2_init (ph2_t *ctx, ph2_cfg_t *cfg)
 pH 2 initialization function.
 
err_t ph2_read_raw_adc (ph2_t *ctx, uint16_t *raw_adc)
 pH 2 read raw ADC value function.
 
err_t ph2_read_voltage (ph2_t *ctx, float *voltage)
 pH 2 read voltage level function.
 
err_t ph2_set_vref (ph2_t *ctx, float vref)
 pH 2 set vref function.
 
err_t ph2_calibrate (ph2_t *ctx, float pH_value)
 Ph 2 calibrate function.
 
err_t ph2_calculate_ph (ph2_t *ctx, float *pH_value)
 Ph 2 calculate pH value function.
 
void ph2_calibrate_offset (ph2_t *ctx)
 Ph 2 calibrate offset function.
 
void ph2_enable_st1 (ph2_t *ctx)
 Ph 2 enable LED STAT1 function.
 
void ph2_disable_st1 (ph2_t *ctx)
 Ph 2 disable LED STAT1 function.
 
void ph2_enable_st2 (ph2_t *ctx)
 Ph 2 enable LED STAT2 function.
 
void ph2_disable_st2 (ph2_t *ctx)
 Ph 2 disable LED STAT2 function.
 
err_t ph2_ds18b20_init (ph2_t *ctx, ph2_cfg_t *cfg)
 pH 2 DS18B20 initialization function.
 
err_t ph2_ds18b20_check_communication (ph2_t *ctx)
 pH 2 DS18B20 check communication function.
 
err_t ph2_ds18b20_select_device (ph2_t *ctx)
 pH 2 DS18B20 select device function.
 
err_t ph2_ds18b20_read_scratchpad (ph2_t *ctx, uint8_t *scratchpad)
 pH 2 DS18B20 read scratchpad function.
 
err_t ph2_ds18b20_write_scratchpad (ph2_t *ctx, uint8_t temp_high, uint8_t temp_low, uint8_t config)
 pH 2 DS18B20 write scratchpad function.
 
err_t ph2_ds18b20_default_cfg (ph2_t *ctx)
 pH 2 DS18B20 default configuration function.
 
err_t ph2_ds18b20_start_measurement (ph2_t *ctx)
 pH 2 DS18B20 start measurement function.
 
err_t ph2_ds18b20_read_temperature (ph2_t *ctx, float *temperature)
 pH 2 DS18B20 read temperature function.
 

Detailed Description

This file contains API for pH 2 Click Driver.

Enumeration Type Documentation

◆ ph2_drv_t

enum ph2_drv_t

pH 2 Click driver selector.

Selects target driver interface of pH 2 Click driver.

Enumerator
PH2_DRV_SEL_ADC 

ADC driver descriptor.

PH2_DRV_SEL_I2C 

I2C driver descriptor.

◆ ph2_return_value_t

pH 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
PH2_OK 
PH2_ERROR