force 2.0.0.0
force.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
35#ifndef FORCE_H
36#define FORCE_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_analog_in.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
57
67#define FORCE_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
75#define FORCE_RETVAL uint8_t
76
77#define FORCE_OK 0x00
78#define FORCE_INIT_ERROR 0xFF
85#define FORCE_RLOAD 10.0
86#define FORCE_RZERO 76.63
87#define FORCE_PARA 116.6020682
88#define FORCE_PARB 2.769034857
89#define FORCE_CORA 0.00035
90#define FORCE_CORB 0.02718
91#define FORCE_CORC 1.39538
92#define FORCE_CORD 0.0018
93#define FORCE_ATMOCO2 397.13
96 // End group macro
97// --------------------------------------------------------------- PUBLIC TYPES
106typedef uint16_t force_data_t;
107
111typedef struct
112{
113 // Modules
114
115 analog_in_t adc;
116
117} force_t;
118
122typedef struct
123{
124 // Communication gpio pins
125
126 pin_name_t an_pin;
127
128 // static variable
129
130 analog_in_resolution_t resolution; // Resolution
131 float vref; // VRef
132
134
135 // End types group
136// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
137
143#ifdef __cplusplus
144extern "C"{
145#endif
146
156
166
176
186float force_get_correction_factor ( float temperature, float humidity );
187
195float force_get_resistance ( uint32_t adc_value );
196
206float force_get_corrected_resistance ( float temperature, float humidity, uint32_t adc_value );
207
208#ifdef __cplusplus
209}
210#endif
211#endif // _FORCE_H_
212
213 // End public_function group
215
216// ------------------------------------------------------------------------ END
#define FORCE_RETVAL
Definition force.h:75
float force_get_correction_factor(float temperature, float humidity)
Get correction factor function.
force_data_t force_generic_read(force_t *ctx)
Generic read function.
FORCE_RETVAL force_init(force_t *ctx, force_cfg_t *cfg)
Initialization function.
void force_cfg_setup(force_cfg_t *cfg)
Config Object Initialization function.
float force_get_resistance(uint32_t adc_value)
Get resistance function.
float force_get_corrected_resistance(float temperature, float humidity, uint32_t adc_value)
Get corrected resistance function.
uint16_t force_data_t
Analog data type.
Definition force.h:106
Click configuration structure definition.
Definition force.h:123
analog_in_resolution_t resolution
Definition force.h:130
float vref
Definition force.h:131
pin_name_t an_pin
Definition force.h:126
Click ctx object definition.
Definition force.h:112
analog_in_t adc
Definition force.h:115