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
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51
67#define SPEEDSENSE_CNV_MIN_TO_MS 60000.0f
68
73#define SPEEDSENSE_DIR_STATE_FWD 0
74#define SPEEDSENSE_DIR_STATE_RVS 1
75#define SPEEDSENSE_SPEED_STATE_LOW 0
76#define SPEEDSENSE_SPEED_STATE_HIGH 1
77
82#define SPEEDSENSE_STOP_MEASURE 0
83#define SPEEDSENSE_START_NEW_MEASURE 1
84
85 // speedsense_set
86
101#define SPEEDSENSE_MAP_MIKROBUS( cfg, mikrobus ) \
102 cfg.chb = MIKROBUS( mikrobus, MIKROBUS_AN ); \
103 cfg.cha = MIKROBUS( mikrobus, MIKROBUS_INT )
104
105 // speedsense_map
106 // speedsense
107
112typedef struct
113{
114 digital_in_t chb;
115 digital_in_t cha;
118
123typedef struct
124{
125 pin_name_t chb;
126 pin_name_t cha;
129
140
157
172
184
196
197#ifdef __cplusplus
198}
199#endif
200#endif // SPEEDSENSE_H
201
202 // speedsense
203
204// ------------------------------------------------------------------------ END
uint8_t speedsense_get_speed(speedsense_t *ctx)
Speed Sense CHA pin reading function.
err_t speedsense_init(speedsense_t *ctx, speedsense_cfg_t *cfg)
Speed Sense initialization function.
void speedsense_cfg_setup(speedsense_cfg_t *cfg)
Speed Sense configuration object setup function.
uint8_t speedsense_get_direction(speedsense_t *ctx)
Speed Sense CHB pin reading function.
speedsense_return_value_t
Speed Sense Click return value data.
Definition speedsense.h:135
@ SPEEDSENSE_OK
Definition speedsense.h:136
@ SPEEDSENSE_ERROR
Definition speedsense.h:137
Speed Sense Click configuration object.
Definition speedsense.h:124
pin_name_t chb
Definition speedsense.h:125
pin_name_t cha
Definition speedsense.h:126
Speed Sense Click context object.
Definition speedsense.h:113
digital_in_t chb
Definition speedsense.h:114
digital_in_t cha
Definition speedsense.h:115