zerocross  2.1.0.0
zerocross.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 ZEROCROSS_H
29 #define ZEROCROSS_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 
68 #define ZEROCROSS_PIN_STATE_LOW 0x00
69 #define ZEROCROSS_PIN_STATE_HIGH 0x01
70  // zerocross_set
72 
87 #define ZEROCROSS_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.zc = MIKROBUS( mikrobus, MIKROBUS_INT )
89  // zerocross_map // zerocross
92 
97 typedef struct
98 {
99  digital_in_t zc;
101 } zerocross_t;
102 
107 typedef struct
108 {
109  pin_name_t zc;
112 
117 typedef enum
118 {
120  ZEROCROSS_ERROR = -1
121 
123 
140 
155 
167 
179 void zerocross_get_freq ( zerocross_t *ctx, float *freq );
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 #endif // ZEROCROSS_H
185  // zerocross
187 
188 // ------------------------------------------------------------------------ END
zerocross_cfg_setup
void zerocross_cfg_setup(zerocross_cfg_t *cfg)
Zero-Cross configuration object setup function.
zerocross_return_value_t
zerocross_return_value_t
Zero-Cross Click return value data.
Definition: zerocross.h:118
ZEROCROSS_OK
@ ZEROCROSS_OK
Definition: zerocross.h:119
zerocross_cfg_t::zc
pin_name_t zc
Definition: zerocross.h:109
zerocross_pin_read
uint8_t zerocross_pin_read(zerocross_t *ctx)
Zero-Cross pin reading function.
zerocross_get_freq
void zerocross_get_freq(zerocross_t *ctx, float *freq)
Zero-Cross frequency reading function.
zerocross_cfg_t
Zero-Cross Click configuration object.
Definition: zerocross.h:108
zerocross_t
Zero-Cross Click context object.
Definition: zerocross.h:98
ZEROCROSS_ERROR
@ ZEROCROSS_ERROR
Definition: zerocross.h:120
zerocross_init
err_t zerocross_init(zerocross_t *ctx, zerocross_cfg_t *cfg)
Zero-Cross initialization function.
zerocross_t::zc
digital_in_t zc
Definition: zerocross.h:99