Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_analog_in.h"
48 #include "drv_i2c_master.h"
49 #include "drv_one_wire.h"
71 #define PH2_CMD_CONVERT_TEMPERATURE 0x44
72 #define PH2_CMD_WRITE_SCRATCHPAD 0x4E
73 #define PH2_CMD_READ_SCRATCHPAD 0xBE
74 #define PH2_CMD_COPY_SCRATCHPAD 0x48
75 #define PH2_CMD_RECALL_SCRATCHPAD 0xB8
76 #define PH2_CMD_READ_POWER_SUPPLY 0xB4
94 #define PH2_PH_CALCULATION_COEF 0.18
96 #define PH2_CONFIG_ADDRESS 0x10
101 #define PH2_ADC_RESOLUTION 0x0FFF
102 #define PH2_VREF_3V3 3.3
103 #define PH2_VREF_5V 5.0
110 #define PH2_SET_DEV_ADDR 0x4D
116 #define PH2_FAMILY_CODE 0x28
123 #define PH2_CONFIG_RESOLUTION_9BIT 0x00
124 #define PH2_CONFIG_RESOLUTION_10BIT 0x20
125 #define PH2_CONFIG_RESOLUTION_11BIT 0x40
126 #define PH2_CONFIG_RESOLUTION_12BIT 0x60
127 #define PH2_CONFIG_RESOLUTION_BIT_MASK 0x60
128 #define PH2_CONFIG_RESERVED_BITS 0x10
134 #define PH2_DATA_RESOLUTION 0.0625
140 #define PH2_DEFAULT_ADDRESS PH2_CONFIG_ADDRESS
141 #define PH2_DEFAULT_RESOLUTION PH2_CONFIG_RESOLUTION_12BIT
142 #define PH2_DEFAULT_TEMP_HIGH_ALARM 0xFF
143 #define PH2_DEFAULT_TEMP_LOW_ALARM 0x00
161 #define PH2_MAP_MIKROBUS( cfg, mikrobus ) \
162 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
163 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
164 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
165 cfg.dq = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
166 cfg.st1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
167 cfg.st2 = MIKROBUS( mikrobus, MIKROBUS_INT )
pH 2 Click context object.
Definition: ph2.h:188
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_ds18b20_check_communication(ph2_t *ctx)
pH 2 DS18B20 check communication function.
digital_out_t st1
Definition: ph2.h:189
err_t ph2_calibrate(ph2_t *ctx, float pH_value)
Ph 2 calibrate function.
void ph2_disable_st2(ph2_t *ctx)
Ph 2 disable LED STAT2 function.
one_wire_t ow
Definition: ph2.h:194
pin_name_t scl
Definition: ph2.h:214
void ph2_enable_st2(ph2_t *ctx)
Ph 2 enable LED STAT2 function.
uint32_t i2c_speed
Definition: ph2.h:223
ph2_return_value_t
pH 2 Click return value data.
Definition: ph2.h:235
@ PH2_ERROR
Definition: ph2.h:237
ph2_drv_t drv_sel
Definition: ph2.h:226
err_t ph2_ds18b20_read_scratchpad(ph2_t *ctx, uint8_t *scratchpad)
pH 2 DS18B20 read scratchpad function.
analog_in_t adc
Definition: ph2.h:192
ph2_drv_t drv_sel
Definition: ph2.h:203
err_t ph2_ds18b20_start_measurement(ph2_t *ctx)
pH 2 DS18B20 start measurement function.
pin_name_t st2
Definition: ph2.h:218
err_t ph2_ds18b20_read_temperature(ph2_t *ctx, float *temperature)
pH 2 DS18B20 read temperature function.
pin_name_t st1
Definition: ph2.h:217
err_t ph2_calculate_ph(ph2_t *ctx, float *pH_value)
Ph 2 calculate pH value function.
float vref
Definition: ph2.h:202
float pH_vol
Definition: ph2.h:197
err_t ph2_read_raw_adc(ph2_t *ctx, uint16_t *raw_adc)
pH 2 read raw ADC value function.
void ph2_enable_st1(ph2_t *ctx)
Ph 2 enable LED STAT1 function.
ph2_drv_t
pH 2 Click driver selector.
Definition: ph2.h:177
pH 2 Click configuration object.
Definition: ph2.h:212
one_wire_rom_address_t rom_addr
Definition: ph2.h:199
err_t ph2_read_voltage(ph2_t *ctx, float *voltage)
pH 2 read voltage level function.
pin_name_t sda
Definition: ph2.h:215
i2c_master_t i2c
Definition: ph2.h:193
err_t ph2_ds18b20_select_device(ph2_t *ctx)
pH 2 DS18B20 select device function.
float pH_val
Definition: ph2.h:196
err_t ph2_set_vref(ph2_t *ctx, float vref)
pH 2 set vref function.
float vref
Definition: ph2.h:221
err_t ph2_init(ph2_t *ctx, ph2_cfg_t *cfg)
pH 2 initialization function.
err_t ph2_ds18b20_init(ph2_t *ctx, ph2_cfg_t *cfg)
pH 2 DS18B20 initialization function.
uint8_t config
Definition: ph2.h:200
void ph2_calibrate_offset(ph2_t *ctx)
Ph 2 calibrate offset function.
pin_name_t an
Definition: ph2.h:213
@ PH2_DRV_SEL_I2C
Definition: ph2.h:179
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.
digital_out_t st2
Definition: ph2.h:190
@ PH2_DRV_SEL_ADC
Definition: ph2.h:178
analog_in_resolution_t resolution
Definition: ph2.h:220
void ph2_disable_st1(ph2_t *ctx)
Ph 2 disable LED STAT1 function.
pin_name_t dq
Definition: ph2.h:216
uint8_t i2c_address
Definition: ph2.h:224
err_t ph2_ds18b20_default_cfg(ph2_t *ctx)
pH 2 DS18B20 default configuration function.
uint8_t slave_address
Definition: ph2.h:201
@ PH2_OK
Definition: ph2.h:236