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_spi_master.h"
85#define LOADCELL6_REG_STAT 0x00
86#define LOADCELL6_REG_CTRL1 0x01
87#define LOADCELL6_REG_CTRL2 0x02
88#define LOADCELL6_REG_CTRL3 0x03
89#define LOADCELL6_REG_CTRL4 0x04
90#define LOADCELL6_REG_CTRL5 0x05
91#define LOADCELL6_REG_DATA 0x06
92#define LOADCELL6_REG_SOC_SPI 0x07
93#define LOADCELL6_REG_SCG_SPI 0x08
94#define LOADCELL6_REG_SCOC_SPI 0x09
95#define LOADCELL6_REG_SCGC_SPI 0x0A
96#define LOADCELL6_REG_RAM 0x0C
97#define LOADCELL6_REG_SYNC_SPI 0x0D
98#define LOADCELL6_REG_SOC_ADC 0x15
99#define LOADCELL6_REG_SCG_ADC 0x16
100#define LOADCELL6_REG_SCOC_ADC 0x17
101#define LOADCELL6_REG_SCGC_ADC 0x18
124#define LOADCELL6_CMD_RATE0 0x01
125#define LOADCELL6_CMD_RATE1 0x02
126#define LOADCELL6_CMD_RATE2 0x04
127#define LOADCELL6_CMD_RATE3 0x08
128#define LOADCELL6_CMD_IMPD 0x10
129#define LOADCELL6_CMD_CAL 0x20
130#define LOADCELL6_CMD_START 0x80
131#define LOADCELL6_CMD_REG_ACCESS_MODE 0x40
137#define LOADCELL6_STAT_RDY 0x0001
138#define LOADCELL6_STAT_MSTAT 0x0002
139#define LOADCELL6_STAT_DOR 0x0004
140#define LOADCELL6_STAT_SYSGOR 0x0008
141#define LOADCELL6_STAT_RATE0 0x0010
142#define LOADCELL6_STAT_RATE1 0x0020
143#define LOADCELL6_STAT_RATE2 0x0040
144#define LOADCELL6_STAT_RATE3 0x0080
145#define LOADCELL6_STAT_AOR 0x0100
146#define LOADCELL6_STAT_RDERR 0x0200
147#define LOADCELL6_STAT_PDSTAT0 0x0400
148#define LOADCELL6_STAT_PDSTAT1 0x0800
149#define LOADCELL6_STAT_ERROR 0x4000
150#define LOADCELL6_STAT_INRESET 0x8000
156#define LOADCELL6_CTRL1_CONTSC 0x01
157#define LOADCELL6_CTRL1_SCYCLE 0x02
158#define LOADCELL6_CTRL1_FORMAT 0x04
159#define LOADCELL6_CTRL1_U_B 0x08
160#define LOADCELL6_CTRL1_PD0 0x10
161#define LOADCELL6_CTRL1_PD1 0x20
162#define LOADCELL6_CTRL1_SYNC 0x40
163#define LOADCELL6_CTRL1_EXTCK 0x80
169#define LOADCELL6_CTRL2_PGAIN_x1 0x00
170#define LOADCELL6_CTRL2_PGAIN_x2 0x01
171#define LOADCELL6_CTRL2_PGAIN_x4 0x02
172#define LOADCELL6_CTRL2_PGAIN_x8 0x03
173#define LOADCELL6_CTRL2_PGAIN_x16 0x04
174#define LOADCELL6_CTRL2_PGAIN_x32 0x05
175#define LOADCELL6_CTRL2_PGAIN_x64 0x06
176#define LOADCELL6_CTRL2_PGAIN_x128 0x07
177#define LOADCELL6_CTRL2_PGAGEN 0x08
178#define LOADCELL6_CTRL2_LPMODE 0x10
179#define LOADCELL6_CTRL2_BUFEN 0x20
180#define LOADCELL6_CTRL2_DGAIN_x1 0x00
181#define LOADCELL6_CTRL2_DGAIN_x2 0x40
182#define LOADCELL6_CTRL2_DGAIN_x4 0x80
183#define LOADCELL6_CTRL2_DGAIN_x8 0xC0
184#define LOADCELL6_CTRL2_DGAIN0 0x40
185#define LOADCELL6_CTRL2_DGAIN1 0x80
191#define LOADCELL6_CTRL3_DATA32 0x08
192#define LOADCELL6_CTRL3_MODBITS 0x10
193#define LOADCELL6_CTRL3_ENMSYNC 0x20
194#define LOADCELL6_CTRL3_RESERVED 0x41
200#define LOADCELL6_CTRL4_DIO1 0x01
201#define LOADCELL6_CTRL4_DIO2 0x02
202#define LOADCELL6_CTRL4_DIO3 0x04
203#define LOADCELL6_CTRL4_DIO4 0x08
204#define LOADCELL6_CTRL4_DIR1 0x10
205#define LOADCELL6_CTRL4_DIR2 0x20
206#define LOADCELL6_CTRL4_DIR3 0x40
207#define LOADCELL6_CTRL4_DIR4 0x80
213#define LOADCELL6_CTRL5_NOSCO 0x01
214#define LOADCELL6_CTRL5_NOSCG 0x02
215#define LOADCELL6_CTRL5_NOSYSO 0x04
216#define LOADCELL6_CTRL5_NOSYSG 0x08
217#define LOADCELL6_CTRL5_CAL0 0x40
218#define LOADCELL6_CTRL5_CAL1 0x80
225#define LOADCELL6_DATA_NO_DATA 0
226#define LOADCELL6_DATA_OK 1
227#define LOADCELL6_WEIGHT_ZERO 0
228#define LOADCELL6_WEIGHT_100G 100
229#define LOADCELL6_WEIGHT_200G 200
230#define LOADCELL6_WEIGHT_500G 500
231#define LOADCELL6_WEIGHT_1000G 1000
232#define LOADCELL6_WEIGHT_5000G 5000
233#define LOADCELL6_WEIGHT_10000G 10000
243#define LOADCELL6_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
244#define LOADCELL6_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
262#define LOADCELL6_MAP_MIKROBUS( cfg, mikrobus ) \
263 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
264 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
265 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
266 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
267 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
268 cfg.syn = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
269 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t loadcell6_generic_write(loadcell6_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Load Cell 6 data writing function.
err_t loadcell6_init(loadcell6_t *ctx, loadcell6_cfg_t *cfg)
Load Cell 6 initialization function.
err_t loadcell6_write_reg_data(loadcell6_t *ctx, uint8_t reg, uint32_t data_in)
Load Cell 6 read reg data function.
void loadcell6_cfg_setup(loadcell6_cfg_t *cfg)
Load Cell 6 configuration object setup function.
err_t loadcell6_read_adc(loadcell6_t *ctx, uint32_t *data_out)
Load Cell 6 read ADC data function.
err_t loadcell6_hw_reset(loadcell6_t *ctx)
Load Cell 6 hw reset function.
err_t loadcell6_read_reg(loadcell6_t *ctx, uint8_t reg, uint8_t *data_out)
Load Cell 6 read reg function.
uint8_t loadcell6_check_data_ready(loadcell6_t *ctx)
Load Cell 6 check data ready function.
err_t loadcell6_default_cfg(loadcell6_t *ctx)
Load Cell 6 default configuration function.
err_t loadcell6_set_command(loadcell6_t *ctx, uint8_t cmd)
Load Cell 6 set command function.
err_t loadcell6_read_reg_data(loadcell6_t *ctx, uint8_t reg, uint32_t *data_out)
Load Cell 6 read reg data function.
err_t loadcell6_write_reg(loadcell6_t *ctx, uint8_t reg, uint8_t data_in)
Load Cell 6 write reg function.
err_t loadcell6_get_weight(loadcell6_t *ctx, loadcell6_data_t *cell_data, float *weight_g)
Load Cell 6 get weight function.
err_t loadcell6_tare(loadcell6_t *ctx, loadcell6_data_t *cell_data)
Load Cell 6 tare the scales function.
err_t loadcell6_generic_read(loadcell6_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Load Cell 6 data reading function.
uint8_t loadcell6_sync(loadcell6_t *ctx)
Load Cell 6 get sync function.
err_t loadcell6_get_status(loadcell6_t *ctx, uint16_t *status)
Load Cell 6 get status function.
err_t loadcell6_calibration(loadcell6_t *ctx, uint16_t cal_val, loadcell6_data_t *cell_data)
Load Cell 6 calibration function.
loadcell6_return_value_t
Load Cell 6 Click return value data.
Definition loadcell6.h:346
@ LOADCELL6_OK
Definition loadcell6.h:347
@ LOADCELL6_ERROR
Definition loadcell6.h:348
This file contains SPI specific macros, functions, etc.
Load Cell 6 Click configuration object.
Definition loadcell6.h:299
spi_master_chip_select_polarity_t cs_polarity
Definition loadcell6.h:314
pin_name_t sck
Definition loadcell6.h:303
spi_master_mode_t spi_mode
Definition loadcell6.h:313
pin_name_t mosi
Definition loadcell6.h:302
uint32_t spi_speed
Definition loadcell6.h:312
pin_name_t rdy
Definition loadcell6.h:309
pin_name_t miso
Definition loadcell6.h:301
pin_name_t rst
Definition loadcell6.h:307
pin_name_t syn
Definition loadcell6.h:308
pin_name_t cs
Definition loadcell6.h:304
Load Cell 6 Click load cell data object.
Definition loadcell6.h:323
uint8_t weight_data_200g_ok
Definition loadcell6.h:329
float tare
Definition loadcell6.h:324
float weight_coeff_10000g
Definition loadcell6.h:336
uint8_t weight_data_1000g_ok
Definition loadcell6.h:333
uint8_t weight_data_500g_ok
Definition loadcell6.h:331
float weight_coeff_100g
Definition loadcell6.h:326
float weight_coeff_5000g
Definition loadcell6.h:334
uint8_t weight_data_10000g_ok
Definition loadcell6.h:337
float weight_coeff_500g
Definition loadcell6.h:330
uint8_t weight_data_5000g_ok
Definition loadcell6.h:335
uint8_t tare_ok
Definition loadcell6.h:325
float weight_coeff_200g
Definition loadcell6.h:328
uint8_t weight_data_100g_ok
Definition loadcell6.h:327
float weight_coeff_1000g
Definition loadcell6.h:332
Load Cell 6 Click context object.
Definition loadcell6.h:279
spi_master_t spi
Definition loadcell6.h:288
digital_in_t syn
Definition loadcell6.h:284
digital_out_t rst
Definition loadcell6.h:281
pin_name_t chip_select
Definition loadcell6.h:290
digital_in_t rdy
Definition loadcell6.h:285