39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
74#define LOADCELL3_REG_TEST_MICRO_INTERFACE_CONTROL 0x0C
75#define LOADCELL3_REG_TEST_PADC_DATA_1 0x10
76#define LOADCELL3_REG_TEST_PADC_DATA_2 0x11
77#define LOADCELL3_REG_TEST_TADC_DATA_1 0x14
78#define LOADCELL3_REG_TEST_TADC_DATA_2 0x15
80#define LOADCELL3_REG_CTRL_STATUS_PSMON_1 0x58
81#define LOADCELL3_REG_CTRL_STATUS_AFEDIAG 0x5A
82#define LOADCELL3_REG_CTRL_STATUS_P_GAIN_SELECT 0x47
83#define LOADCELL3_REG_CTRL_STATUS_T_GAIN_SELECT 0x48
84#define LOADCELL3_REG_CTRL_STATUS_TEMP_CTRL 0x4C
85#define LOADCELL3_REG_CTRL_STATUS_OFFSET_CANCEL 0x4E
86#define LOADCELL3_REG_CTRL_STATUS_DAC_REG0_1 0x30
87#define LOADCELL3_REG_CTRL_STATUS_DAC_REG0_2 0x31
88#define LOADCELL3_REG_CTRL_STATUS_OP_STAGE_CTRL 0x3B
90#define LOADCELL3_REG_EEPROM_ARRAY_START 0x00
91#define LOADCELL3_REG_EEPROM_ARRAY_END 0x7F
92#define LOADCELL3_REG_EEPROM_CACHE_BYTE_0 0x80
93#define LOADCELL3_REG_EEPROM_CACHE_BYTE_1 0x81
94#define LOADCELL3_REG_EEPROM_PAGE_ADDRESS 0x82
95#define LOADCELL3_REG_EEPROM_CTRL 0x83
96#define LOADCELL3_REG_EEPROM_CRC 0x84
97#define LOADCELL3_REG_EEPROM_STATUS 0x85
98#define LOADCELL3_REG_EEPROM_CRC_STATUS 0x86
99#define LOADCELL3_REG_EEPROM_CRC_VALUE 0x87
117#define LOADCELL3_SET_IF_SEL_ACCESSES_CONTROLLER 0x00
118#define LOADCELL3_SET_IF_SEL_ACCESSES_DIGITAL_INTERFACE 0x01
120#define LOADCELL3_SET_TSEM_MODE_SINGLE_ENDED 0x00
121#define LOADCELL3_SET_TSEM_MODE_DIFFERENTIAL 0x01
123#define LOADCELL3_SET_T_MUX_CTRL_EXT_TEMPE 0x00
124#define LOADCELL3_SET_T_MUX_CTRL_TEST 0x01
125#define LOADCELL3_SET_T_MUX_CTRL_INT_TEMPE 0x02
126#define LOADCELL3_SET_T_MUX_CTRL_BRIDGE_CURRENT 0x03
127#define LOADCELL3_SET_T_MUX_CTRL_ITEMP 0x04
129#define LOADCELL3_SET_GAIN_1_33 0x00
130#define LOADCELL3_SET_GAIN_2 0x01
131#define LOADCELL3_SET_GAIN_4 0x02
132#define LOADCELL3_SET_GAIN_10 0x03
133#define LOADCELL3_SET_GAIN_20 0x04
134#define LOADCELL3_SET_GAIN_40 0x05
135#define LOADCELL3_SET_GAIN_100 0x06
136#define LOADCELL3_SET_GAIN_200 0x07
138#define LOADCELL3_SET_ITEMP_CTRL_50_mA 0x00
139#define LOADCELL3_SET_ITEMP_CTRL_100_mA 0x01
140#define LOADCELL3_SET_ITEMP_CTRL_200_mA 0x02
141#define LOADCELL3_SET_ITEMP_CTRL_1000_mA 0x03
142#define LOADCELL3_SET_ITEMP_CTRL_OFF 0x04
144#define LOADCELL3_SET_OFFSET_CANCEL_0_mV 0x00
145#define LOADCELL3_SET_OFFSET_CANCEL_3_65_mV 0x01
146#define LOADCELL3_SET_OFFSET_CANCEL_7_3_mV 0x02
147#define LOADCELL3_SET_OFFSET_CANCEL_10_95_mV 0x03
148#define LOADCELL3_SET_OFFSET_CANCEL_14_6_mV 0x04
149#define LOADCELL3_SET_OFFSET_CANCEL_18_28_mV 0x05
150#define LOADCELL3_SET_OFFSET_CANCEL_21_9_mV 0x06
151#define LOADCELL3_SET_OFFSET_CANCEL_25_55_mV 0x07
152#define LOADCELL3_SET_OFFSET_CANCEL_29_2_mV 0x08
153#define LOADCELL3_SET_OFFSET_CANCEL_32_85_mV 0x09
154#define LOADCELL3_SET_OFFSET_CANCEL_36_5_mV 0x0A
155#define LOADCELL3_SET_OFFSET_CANCEL_40_15_mV 0x0B
156#define LOADCELL3_SET_OFFSET_CANCEL_43_8_mV 0x0C
157#define LOADCELL3_SET_OFFSET_CANCEL_47_45_mV 0x0D
158#define LOADCELL3_SET_OFFSET_CANCEL_51_1_mV 0x0E
159#define LOADCELL3_SET_OFFSET_CANCEL_54_75_mV 0x0F
161#define LOADCELL3_SET_OFFSET_CURRENT_VINPN 0x00
162#define LOADCELL3_SET_OFFSET_CURRENT_VINPP 0x01
169#define LOADCELL3_SET_DEV_ADDR 0x42
170#define LOADCELL3_SET_MEMORY_PAGE_TEST_REG 0x40
171#define LOADCELL3_SET_MEMORY_PAGE_CONTROL_AND_STATUS_REG 0x42
172#define LOADCELL3_SET_MEMORY_PAGE_EEPROM_CACHE_CELLS 0x45
173#define LOADCELL3_SET_MEMORY_PAGE_CTRL_AND_STATUS_REG 0x47
186#define LOADCELL3_WEIGHT_ZERO 0
187#define LOADCELL3_WEIGHT_100G 100
188#define LOADCELL3_WEIGHT_500G 500
189#define LOADCELL3_WEIGHT_1000G 1000
190#define LOADCELL3_WEIGHT_5000G 5000
191#define LOADCELL3_WEIGHT_10000G 10000
204#define LOADCELL3_DATA_NO_DATA 0
205#define LOADCELL3_DATA_OK 1
223#define LOADCELL3_MAP_MIKROBUS( cfg, mikrobus ) \
224 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
225 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
226 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
err_t loadcell3_generic_write(loadcell3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Load Cell 3 I2C writing function.
err_t loadcell3_accesses_controller(loadcell3_t *ctx)
Load Cell 3 accesses controller function.
err_t loadcell3_set_t_gain(loadcell3_t *ctx, uint8_t t_gain)
Load Cell 3 set temperature gain function.
err_t loadcell3_generic_test_page_write(loadcell3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Load Cell 3 test I2C writing function.
err_t loadcell3_init(loadcell3_t *ctx, loadcell3_cfg_t *cfg)
Load Cell 3 initialization function.
err_t loadcell3_generic_eeprom_read(loadcell3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Load Cell 3 I2C EEPROM reading function.
err_t loadcell3_calibration(loadcell3_t *ctx, uint16_t cal_val, loadcell3_data_t *cell_data)
Load Cell 3 calibration function.
err_t loadcell3_generic_eeprom_write(loadcell3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Load Cell 3 EEPROM I2C writing function.
void loadcell3_tare(loadcell3_t *ctx, loadcell3_data_t *cell_data)
Load Cell 3 tare the scales function.
err_t loadcell3_itemp_ctrl(loadcell3_t *ctx, uint8_t itemp_ctrl)
Load Cell 3 set ITEMP control function.
err_t loadcell3_set_memory_page_slave_addr(loadcell3_t *ctx, uint8_t memory_page)
Load Cell 3 set memory page function.
err_t loadcell3_generic_test_page_read(loadcell3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Load Cell 3 Control and Status I2C EEPROM reading function.
int16_t loadcell3_get_p_adc_data(loadcell3_t *ctx)
Load Cell 3 get pressure ADC data function.
err_t loadcell3_accesses_digital_interface_control(loadcell3_t *ctx)
Load Cell 3 accesses digital interface control function.
err_t loadcell3_soft_reset(loadcell3_t *ctx)
Load Cell 3 soft reset function.
err_t loadcell3_set_t_mux_ctrl(loadcell3_t *ctx, uint8_t t_mux_ctrl)
Load Cell 3 set mux control function.
void loadcell3_cfg_setup(loadcell3_cfg_t *cfg)
Load Cell 3 configuration object setup function.
err_t loadcell3_set_offset(loadcell3_t *ctx, uint8_t offset_cancel_val, uint8_t offset_cancel_sel)
Load Cell 3 set offset function.
err_t loadcell3_set_p_gain(loadcell3_t *ctx, uint8_t p_gain)
Load Cell 3 set pressure gain function.
err_t loadcell3_default_cfg(loadcell3_t *ctx)
Load Cell 3 default configuration function.
err_t loadcell3_set_temp_mode(loadcell3_t *ctx, uint8_t t_mode)
Load Cell 3 set temperature mode function.
int16_t loadcell3_get_t_adc_data(loadcell3_t *ctx)
Load Cell 3 get temperature ADC data function.
err_t loadcell3_generic_read(loadcell3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Load Cell 3 I2C reading function.
float loadcell3_get_weight(loadcell3_t *ctx, loadcell3_data_t *cell_data)
Load Cell 3 get weight function.
loadcell3_return_value_t
Load Cell 3 Click return value data.
Definition loadcell3.h:271
@ LOADCELL3_OK
Definition loadcell3.h:272
@ LOADCELL3_ERROR
Definition loadcell3.h:273
Load Cell 3 Click configuration object.
Definition loadcell3.h:256
uint32_t i2c_speed
Definition loadcell3.h:261
pin_name_t scl
Definition loadcell3.h:257
pin_name_t sda
Definition loadcell3.h:258
pin_name_t an
Definition loadcell3.h:259
uint8_t i2c_address
Definition loadcell3.h:262
Load Cell 3 Click data structure definition.
Definition loadcell3.h:282
float tare
Definition loadcell3.h:283
float weight_coeff_10000g
Definition loadcell3.h:293
uint8_t weight_data_1000g_ok
Definition loadcell3.h:290
uint8_t weight_data_500g_ok
Definition loadcell3.h:288
float weight_coeff_100g
Definition loadcell3.h:285
float weight_coeff_5000g
Definition loadcell3.h:291
uint8_t weight_data_10000g_ok
Definition loadcell3.h:294
float weight_coeff_500g
Definition loadcell3.h:287
uint8_t weight_data_5000g_ok
Definition loadcell3.h:292
uint8_t tare_ok
Definition loadcell3.h:284
uint8_t weight_data_100g_ok
Definition loadcell3.h:286
float weight_coeff_1000g
Definition loadcell3.h:289
Load Cell 3 Click context object.
Definition loadcell3.h:236
i2c_master_t i2c
Definition loadcell3.h:243
digital_in_t an
Definition loadcell3.h:239
uint8_t slave_address
Definition loadcell3.h:247