loadcell7 2.1.0.0
loadcell7.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef LOADCELL7_H
29#define LOADCELL7_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
52#include "spi_specifics.h"
53
74#define LOADCELL7_NUM_CONVERSIONS 80
75
84#define LOADCELL7_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
85#define LOADCELL7_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
86
87 // loadcell7_set
88
103#define LOADCELL7_MAP_MIKROBUS( cfg, mikrobus ) \
104 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
105 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
106 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
107 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
108
109 // loadcell7_map
110 // loadcell7
111
116typedef struct
117{
118 digital_in_t miso;
119 digital_out_t cs;
121 // Modules
122 spi_master_t spi;
124 int32_t tare_scale;
128
133typedef struct
134{
135 // Communication gpio pins
136 pin_name_t miso;
137 pin_name_t mosi;
138 pin_name_t sck;
139 pin_name_t cs;
141 // static variable
142 uint32_t spi_speed;
143 spi_master_mode_t spi_mode;
146
157
174
189
199
209
221err_t loadcell7_read_raw_adc ( loadcell7_t *ctx, int32_t *data_out );
222
235
248err_t loadcell7_calibrate_weight ( loadcell7_t *ctx, float cal_weight );
249
262err_t loadcell7_get_weight ( loadcell7_t *ctx, float *weight );
263
264#ifdef __cplusplus
265}
266#endif
267#endif // LOADCELL7_H
268
269 // loadcell7
270
271// ------------------------------------------------------------------------ END
void loadcell7_disable_device(loadcell7_t *ctx)
Load Cell 7 disable device function.
err_t loadcell7_tare_scale(loadcell7_t *ctx)
Load Cell 7 tare scale function.
err_t loadcell7_calibrate_weight(loadcell7_t *ctx, float cal_weight)
Load Cell 7 calibrate weight function.
err_t loadcell7_init(loadcell7_t *ctx, loadcell7_cfg_t *cfg)
Load Cell 7 initialization function.
void loadcell7_cfg_setup(loadcell7_cfg_t *cfg)
Load Cell 7 configuration object setup function.
err_t loadcell7_read_raw_adc(loadcell7_t *ctx, int32_t *data_out)
Load Cell 7 read raw adc function.
err_t loadcell7_get_weight(loadcell7_t *ctx, float *weight)
Load Cell 7 get weight function.
void loadcell7_enable_device(loadcell7_t *ctx)
Load Cell 7 enable device function.
loadcell7_return_value_t
Load Cell 7 Click return value data.
Definition loadcell7.h:152
@ LOADCELL7_OK
Definition loadcell7.h:153
@ LOADCELL7_ERROR
Definition loadcell7.h:154
This file contains SPI specific macros, functions, etc.
Load Cell 7 Click configuration object.
Definition loadcell7.h:134
pin_name_t sck
Definition loadcell7.h:138
spi_master_mode_t spi_mode
Definition loadcell7.h:143
pin_name_t mosi
Definition loadcell7.h:137
uint32_t spi_speed
Definition loadcell7.h:142
pin_name_t miso
Definition loadcell7.h:136
pin_name_t cs
Definition loadcell7.h:139
Load Cell 7 Click context object.
Definition loadcell7.h:117
digital_out_t cs
Definition loadcell7.h:119
spi_master_t spi
Definition loadcell7.h:122
digital_in_t miso
Definition loadcell7.h:118
float weight_scale
Definition loadcell7.h:125
int32_t tare_scale
Definition loadcell7.h:124