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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_analog_in.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
43 
53 #define FORCE_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
55 
61 #define FORCE_RETVAL uint8_t
62 
63 #define FORCE_OK 0x00
64 #define FORCE_INIT_ERROR 0xFF
65 
71 #define FORCE_RLOAD 10.0
72 #define FORCE_RZERO 76.63
73 #define FORCE_PARA 116.6020682
74 #define FORCE_PARB 2.769034857
75 #define FORCE_CORA 0.00035
76 #define FORCE_CORB 0.02718
77 #define FORCE_CORC 1.39538
78 #define FORCE_CORD 0.0018
79 #define FORCE_ATMOCO2 397.13
80  // End group macro
83 // --------------------------------------------------------------- PUBLIC TYPES
92 typedef uint16_t force_data_t;
93 
97 typedef struct
98 {
99  // Modules
100 
101  analog_in_t adc;
102 
103 } force_t;
104 
108 typedef struct
109 {
110  // Communication gpio pins
111 
112  pin_name_t an_pin;
113 
114  // static variable
115 
116  analog_in_resolution_t resolution; // Resolution
117  float vref; // VRef
118 
119 } force_cfg_t;
120  // End types group
122 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
123 
129 #ifdef __cplusplus
130 extern "C"{
131 #endif
132 
142 
152 
162 
172 float force_get_correction_factor ( float temperature, float humidity );
173 
181 float force_get_resistance ( uint32_t adc_value );
182 
192 float force_get_corrected_resistance ( float temperature, float humidity, uint32_t adc_value );
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 #endif // _FORCE_H_
198  // End public_function group
201 
202 // ------------------------------------------------------------------------ END
force_cfg_t::resolution
analog_in_resolution_t resolution
Definition: force.h:116
force_get_correction_factor
float force_get_correction_factor(float temperature, float humidity)
Get correction factor function.
force_data_t
uint16_t force_data_t
Analog data type.
Definition: force.h:92
force_init
FORCE_RETVAL force_init(force_t *ctx, force_cfg_t *cfg)
Initialization function.
force_t
Click ctx object definition.
Definition: force.h:98
force_get_corrected_resistance
float force_get_corrected_resistance(float temperature, float humidity, uint32_t adc_value)
Get corrected resistance function.
force_cfg_t::an_pin
pin_name_t an_pin
Definition: force.h:112
force_cfg_t
Click configuration structure definition.
Definition: force.h:109
force_cfg_t::vref
float vref
Definition: force.h:117
force_get_resistance
float force_get_resistance(uint32_t adc_value)
Get resistance function.
force_t::adc
analog_in_t adc
Definition: force.h:101
FORCE_RETVAL
#define FORCE_RETVAL
Definition: force.h:61
force_cfg_setup
void force_cfg_setup(force_cfg_t *cfg)
Config Object Initialization function.
force_generic_read
force_data_t force_generic_read(force_t *ctx)
Generic read function.