speedsense  2.1.0.0
speedsense.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 SPEEDSENSE_H
29 #define SPEEDSENSE_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 
53 #define SPEEDSENSE_CNV_MIN_TO_MS 60000.0f
54 
59 #define SPEEDSENSE_DIR_STATE_FWD 0
60 #define SPEEDSENSE_DIR_STATE_RVS 1
61 #define SPEEDSENSE_SPEED_STATE_LOW 0
62 #define SPEEDSENSE_SPEED_STATE_HIGH 1
63 
68 #define SPEEDSENSE_STOP_MEASURE 0
69 #define SPEEDSENSE_START_NEW_MEASURE 1
70  // speedsense_set
72 
87 #define SPEEDSENSE_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.chb = MIKROBUS( mikrobus, MIKROBUS_AN ); \
89  cfg.cha = MIKROBUS( mikrobus, MIKROBUS_INT )
90  // speedsense_map // speedsense
93 
98 typedef struct
99 {
100  digital_in_t chb;
101  digital_in_t cha;
103 } speedsense_t;
104 
109 typedef struct
110 {
111  pin_name_t chb;
112  pin_name_t cha;
115 
120 typedef enum
121 {
123  SPEEDSENSE_ERROR = -1
124 
126 
143 
158 
170 
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 #endif // SPEEDSENSE_H
187  // speedsense
189 
190 // ------------------------------------------------------------------------ END
speedsense_cfg_t::cha
pin_name_t cha
Definition: speedsense.h:112
speedsense_t
Speed Sense Click context object.
Definition: speedsense.h:99
speedsense_init
err_t speedsense_init(speedsense_t *ctx, speedsense_cfg_t *cfg)
Speed Sense initialization function.
speedsense_cfg_t
Speed Sense Click configuration object.
Definition: speedsense.h:110
speedsense_get_speed
uint8_t speedsense_get_speed(speedsense_t *ctx)
Speed Sense CHA pin reading function.
speedsense_cfg_t::chb
pin_name_t chb
Definition: speedsense.h:111
SPEEDSENSE_OK
@ SPEEDSENSE_OK
Definition: speedsense.h:122
speedsense_t::cha
digital_in_t cha
Definition: speedsense.h:101
speedsense_return_value_t
speedsense_return_value_t
Speed Sense Click return value data.
Definition: speedsense.h:121
speedsense_cfg_setup
void speedsense_cfg_setup(speedsense_cfg_t *cfg)
Speed Sense configuration object setup function.
speedsense_t::chb
digital_in_t chb
Definition: speedsense.h:100
SPEEDSENSE_ERROR
@ SPEEDSENSE_ERROR
Definition: speedsense.h:123
speedsense_get_direction
uint8_t speedsense_get_direction(speedsense_t *ctx)
Speed Sense CHB pin reading function.