pedometer  2.0.0.0
pedometer.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 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef PEDOMETER_H
36 #define PEDOMETER_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_in.h"
49 
50 // -------------------------------------------------------------- PUBLIC MACROS
60 #define PEDOMETER_MAP_MIKROBUS( cfg, mikrobus ) \
61  cfg.int_pin= MIKROBUS( mikrobus, MIKROBUS_INT );
62 
68 #define PEDOMETER_RETVAL uint8_t
69 
70 #define PEDOMETER_OK 0x00
71 #define PEDOMETER_INIT_ERROR 0xFF
72 
78 #define PEDOMETER_NEW_STEP_DETECTED 0x01
79 #define PEDOMETER_NO_STEP_DETECTED 0x00
80  // End group macro
83 // --------------------------------------------------------------- PUBLIC TYPES
92 typedef struct
93 {
94 
95  // Input pins
96 
97  digital_in_t int_pin;
98  int16_t step_counter;
99 
100 
101 } pedometer_t;
102 
106 typedef struct
107 {
108  // Additional gpio pins
109 
110  pin_name_t int_pin;
112 
114  // End types group
116 
117 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
118 
124 #ifdef __cplusplus
125 extern "C"{
126 #endif
127 
137 
146 
155 
165 void pedometer_reset_step_counter ( pedometer_t *ctx, uint32_t new_cnt );
166 
176 
186 
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 #endif // _PEDOMETER_H_
201  // End public_function group
204 
205 // ------------------------------------------------------------------------- END
pedometer_init
PEDOMETER_RETVAL pedometer_init(pedometer_t *ctx, pedometer_cfg_t *cfg)
Initialization function.
pedometer_reset_step_counter
void pedometer_reset_step_counter(pedometer_t *ctx, uint32_t new_cnt)
Functions for reset Step counter.
pedometer_cfg_t::dev_step_counter
int16_t dev_step_counter
Definition: pedometer.h:111
pedometer_t::int_pin
digital_in_t int_pin
Definition: pedometer.h:97
PEDOMETER_RETVAL
#define PEDOMETER_RETVAL
Definition: pedometer.h:68
pedometer_t::step_counter
int16_t step_counter
Definition: pedometer.h:98
pedometer_get_step_counter
uint32_t pedometer_get_step_counter(pedometer_t *ctx)
Functions for get step counter.
pedometer_cfg_t
Click configuration structure definition.
Definition: pedometer.h:107
pedometer_default_cfg
void pedometer_default_cfg(pedometer_t *ctx)
Click Default Configuration function.
pedometer_t
Click ctx object definition.
Definition: pedometer.h:93
pedometer_cfg_setup
void pedometer_cfg_setup(pedometer_cfg_t *cfg)
Config Object Initialization function.
pedometer_cfg_t::int_pin
pin_name_t int_pin
Definition: pedometer.h:110
pedometer_get_interrupt_state
uint8_t pedometer_get_interrupt_state(pedometer_t *ctx)
Functions for get Interrupt state on the INT pin.
pedometer_process
uint8_t pedometer_process(pedometer_t *ctx)
Pedometer process.