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"
73#define LOADCELL4_GET_RESULT_ERROR 0
74#define LOADCELL4_GET_RESULT_OK 1
75#define LOADCELL4_DATA_NO_DATA 0
76#define LOADCELL4_DATA_OK 1
77#define LOADCELL4_WEIGHT_100G 100
78#define LOADCELL4_WEIGHT_500G 500
79#define LOADCELL4_WEIGHT_1000G 1000
80#define LOADCELL4_WEIGHT_5000G 5000
81#define LOADCELL4_WEIGHT_10000G 10000
82#define LOADCELL4_DEFAULT_WEIGHT_SCALE_COEFFICIENT 0.088495575221
88#define LOADCELL4_EEPROM_ID_0 0x00
89#define LOADCELL4_EEPROM_CONFIG_1 0x01
90#define LOADCELL4_EEPROM_CONFIG_2 0x02
91#define LOADCELL4_EEPROM_OFFSET_BRIDGE 0x03
92#define LOADCELL4_EEPROM_GAIN_BRIDGE 0x04
93#define LOADCELL4_EEPROM_TEMP_COF_GAIN 0x05
94#define LOADCELL4_EEPROM_TEMP_COF_OFFSET 0x06
95#define LOADCELL4_EEPROM_2ND_ORDER_TEMP_COF_OFFSET 0x07
96#define LOADCELL4_EEPROM_2ND_ORDER_TEMP_COF_GAIN 0x08
97#define LOADCELL4_EEPROM_2ND_ORDER_BRIDGE 0x09
98#define LOADCELL4_EEPROM_OFFSET_TEMP 0x0A
99#define LOADCELL4_EEPROM_GAINT_TEMP 0x0B
100#define LOADCELL4_EEPROM_2ND_ORDER_TEMP 0x0C
101#define LOADCELL4_EEPROM_TEMP_SETL 0x0D
102#define LOADCELL4_EEPROM_ID_1 0x0E
103#define LOADCELL4_EEPROM_BRIDGE_CONFIG 0x0F
104#define LOADCELL4_EEPROM_TEMP_CONFIG 0x10
105#define LOADCELL4_EEPROM_OSC_TRIM 0x11
106#define LOADCELL4_EEPROM_SIGNATURE 0x12
107#define LOADCELL4_EEPROM_ID_2 0x13
108#define LOADCELL4_EEPROM_WRITE_CMD 0x40
109#define LOADCELL4_EEPROM_STATUS_READ_READY 0x5A
115#define LOADCELL4_STATUS_NORMAL 0x00
116#define LOADCELL4_STATUS_CMD_MODE 0x01
117#define LOADCELL4_STATUS_STALE_DATA 0x02
118#define LOADCELL4_STATUS_ERROR 0x03
119#define LOADCELL4_STATUS_BIT_MASK 0x03
120#define LOADCELL4_BRIDGE_RES 0x3FFF
126#define LOADCELL4_DUMMY 0x0000
132#define LOADCELL4_PWR_OFF 0x00
133#define LOADCELL4_PWR_ON 0x01
139#define LOADCELL4_WEIGHT_ZERO 0.000
146#define LOADCELL4_NUMB_OF_SUM_AVG_20 20.00
147#define LOADCELL4_NUMB_OF_SUM_AVG_100 100.0
153#define LOADCELL4_CMD_MODE_START 0xA0
154#define LOADCELL4_CMD_MODE_STOP 0x80
161#define LOADCELL4_SET_DEV_ADDR 0x28
179#define LOADCELL4_MAP_MIKROBUS( cfg, mikrobus ) \
180 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
181 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
182 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
183 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t loadcell4_default_cfg(loadcell4_t *ctx)
Load Cell 4 default configuration function.
void loadcell4_read_raw(loadcell4_t *ctx, uint32_t *rx_data)
Read raw data function.
void loadcell4_end_cmd_mode(loadcell4_t *ctx)
Start command mode function.
void loadcell4_start_cmd_mode(loadcell4_t *ctx)
Start command mode function.
err_t loadcell4_generic_write(loadcell4_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Load Cell 4 I2C writing function.
uint16_t loadcell4_read_bridge_data(loadcell4_t *ctx)
Read bridge data function.
uint8_t loadcell4_get_int(loadcell4_t *ctx)
Get state of the INT pin function.
void loadcell4_write_eeprom(loadcell4_t *ctx, uint8_t cmd_byte, uint16_t data_word)
Write eeprom function.
err_t loadcell4_calibration(loadcell4_t *ctx, uint16_t cal_val, loadcell4_data_t *cell_data)
Calibration function.
err_t loadcell4_generic_read(loadcell4_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Load Cell 4 I2C reading function.
void loadcell4_power_dev(loadcell4_t *ctx, uint8_t power_state)
Enable power function.
uint16_t loadcell4_read_eeprom(loadcell4_t *ctx, uint8_t cmd_byte)
Write eeprom function.
void loadcell4_cfg_setup(loadcell4_cfg_t *cfg)
Load Cell 4 configuration object setup function.
float loadcell4_get_weight(loadcell4_t *ctx, loadcell4_data_t *cell_data)
Get weight function.
void loadcell4_tare(loadcell4_t *ctx, loadcell4_data_t *cell_data)
Tare the scales function.
uint8_t loadcell4_read_data(loadcell4_t *ctx, uint16_t *bridge_data, int16_t *temperature_data)
Read data function.
err_t loadcell4_init(loadcell4_t *ctx, loadcell4_cfg_t *cfg)
Load Cell 4 initialization function.
loadcell4_return_value_t
Load Cell 4 Click return value data.
Definition loadcell4.h:251
@ LOADCELL4_OK
Definition loadcell4.h:252
@ LOADCELL4_ERROR
Definition loadcell4.h:253
Load Cell 4 Click configuration object.
Definition loadcell4.h:213
uint32_t i2c_speed
Definition loadcell4.h:220
pin_name_t scl
Definition loadcell4.h:214
pin_name_t en
Definition loadcell4.h:217
pin_name_t int_pin
Definition loadcell4.h:218
pin_name_t sda
Definition loadcell4.h:215
uint8_t i2c_address
Definition loadcell4.h:221
Load Cell 4 Click data object.
Definition loadcell4.h:230
float tare
Definition loadcell4.h:231
float weight_coeff_10000g
Definition loadcell4.h:241
uint8_t weight_data_1000g_ok
Definition loadcell4.h:238
uint8_t weight_data_500g_ok
Definition loadcell4.h:236
float weight_coeff_100g
Definition loadcell4.h:233
float weight_coeff_5000g
Definition loadcell4.h:239
uint8_t weight_data_10000g_ok
Definition loadcell4.h:242
float weight_coeff_500g
Definition loadcell4.h:235
uint8_t weight_data_5000g_ok
Definition loadcell4.h:240
uint8_t tare_ok
Definition loadcell4.h:232
uint8_t weight_data_100g_ok
Definition loadcell4.h:234
float weight_coeff_1000g
Definition loadcell4.h:237
Load Cell 4 Click context object.
Definition loadcell4.h:193
digital_in_t int_pin
Definition loadcell4.h:198
i2c_master_t i2c
Definition loadcell4.h:201
digital_out_t en
Definition loadcell4.h:195
uint8_t slave_address
Definition loadcell4.h:204