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 "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
63 #define SPEEDSENSE_CNV_MIN_TO_MS 60000.0f
64 
69 #define SPEEDSENSE_DIR_STATE_FWD 0
70 #define SPEEDSENSE_DIR_STATE_RVS 1
71 #define SPEEDSENSE_SPEED_STATE_LOW 0
72 #define SPEEDSENSE_SPEED_STATE_HIGH 1
73 
78 #define SPEEDSENSE_STOP_MEASURE 0
79 #define SPEEDSENSE_START_NEW_MEASURE 1
80  // speedsense_set
82 
97 #define SPEEDSENSE_MAP_MIKROBUS( cfg, mikrobus ) \
98  cfg.chb = MIKROBUS( mikrobus, MIKROBUS_AN ); \
99  cfg.cha = MIKROBUS( mikrobus, MIKROBUS_INT )
100  // speedsense_map // speedsense
103 
108 typedef struct
109 {
110  digital_in_t chb;
111  digital_in_t cha;
113 } speedsense_t;
114 
119 typedef struct
120 {
121  pin_name_t chb;
122  pin_name_t cha;
125 
130 typedef enum
131 {
133  SPEEDSENSE_ERROR = -1
134 
136 
153 
168 
180 
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 #endif // SPEEDSENSE_H
197  // speedsense
199 
200 // ------------------------------------------------------------------------ END
speedsense_cfg_t::cha
pin_name_t cha
Definition: speedsense.h:122
speedsense_t
Speed Sense Click context object.
Definition: speedsense.h:109
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:120
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:121
SPEEDSENSE_OK
@ SPEEDSENSE_OK
Definition: speedsense.h:132
speedsense_t::cha
digital_in_t cha
Definition: speedsense.h:111
speedsense_return_value_t
speedsense_return_value_t
Speed Sense Click return value data.
Definition: speedsense.h:131
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:110
SPEEDSENSE_ERROR
@ SPEEDSENSE_ERROR
Definition: speedsense.h:133
speedsense_get_direction
uint8_t speedsense_get_direction(speedsense_t *ctx)
Speed Sense CHB pin reading function.