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 "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_analog_in.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
53 
63 #define FORCE_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
65 
71 #define FORCE_RETVAL uint8_t
72 
73 #define FORCE_OK 0x00
74 #define FORCE_INIT_ERROR 0xFF
75 
81 #define FORCE_RLOAD 10.0
82 #define FORCE_RZERO 76.63
83 #define FORCE_PARA 116.6020682
84 #define FORCE_PARB 2.769034857
85 #define FORCE_CORA 0.00035
86 #define FORCE_CORB 0.02718
87 #define FORCE_CORC 1.39538
88 #define FORCE_CORD 0.0018
89 #define FORCE_ATMOCO2 397.13
90  // End group macro
93 // --------------------------------------------------------------- PUBLIC TYPES
102 typedef uint16_t force_data_t;
103 
107 typedef struct
108 {
109  // Modules
110 
111  analog_in_t adc;
112 
113 } force_t;
114 
118 typedef struct
119 {
120  // Communication gpio pins
121 
122  pin_name_t an_pin;
123 
124  // static variable
125 
126  analog_in_resolution_t resolution; // Resolution
127  float vref; // VRef
128 
129 } force_cfg_t;
130  // End types group
132 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
133 
139 #ifdef __cplusplus
140 extern "C"{
141 #endif
142 
152 
162 
172 
182 float force_get_correction_factor ( float temperature, float humidity );
183 
191 float force_get_resistance ( uint32_t adc_value );
192 
202 float force_get_corrected_resistance ( float temperature, float humidity, uint32_t adc_value );
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 #endif // _FORCE_H_
208  // End public_function group
211 
212 // ------------------------------------------------------------------------ END
force_cfg_t::resolution
analog_in_resolution_t resolution
Definition: force.h:126
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:102
force_init
FORCE_RETVAL force_init(force_t *ctx, force_cfg_t *cfg)
Initialization function.
force_t
Click ctx object definition.
Definition: force.h:108
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:122
force_cfg_t
Click configuration structure definition.
Definition: force.h:119
force_cfg_t::vref
float vref
Definition: force.h:127
force_get_resistance
float force_get_resistance(uint32_t adc_value)
Get resistance function.
force_t::adc
analog_in_t adc
Definition: force.h:111
FORCE_RETVAL
#define FORCE_RETVAL
Definition: force.h:71
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.