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 "drv_digital_in.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
50 #define PEDOMETER_MAP_MIKROBUS( cfg, mikrobus ) \
51  cfg.int_pin= MIKROBUS( mikrobus, MIKROBUS_INT );
52 
58 #define PEDOMETER_RETVAL uint8_t
59 
60 #define PEDOMETER_OK 0x00
61 #define PEDOMETER_INIT_ERROR 0xFF
62 
68 #define PEDOMETER_NEW_STEP_DETECTED 0x01
69 #define PEDOMETER_NO_STEP_DETECTED 0x00
70  // End group macro
73 // --------------------------------------------------------------- PUBLIC TYPES
82 typedef struct
83 {
84 
85  // Input pins
86 
87  digital_in_t int_pin;
88  int16_t step_counter;
89 
90 
91 } pedometer_t;
92 
96 typedef struct
97 {
98  // Additional gpio pins
99 
100  pin_name_t int_pin;
102 
104  // End types group
106 
107 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
108 
114 #ifdef __cplusplus
115 extern "C"{
116 #endif
117 
127 
136 
144 void pedometer_default_cfg ( pedometer_t *ctx );
145 
155 void pedometer_reset_step_counter ( pedometer_t *ctx, uint32_t new_cnt );
156 
166 
175 uint32_t pedometer_get_step_counter ( pedometer_t *ctx );
176 
185 uint8_t pedometer_process ( pedometer_t *ctx );
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 #endif // _PEDOMETER_H_
191  // End public_function group
194 
195 // ------------------------------------------------------------------------- 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:101
pedometer_t::int_pin
digital_in_t int_pin
Definition: pedometer.h:87
PEDOMETER_RETVAL
#define PEDOMETER_RETVAL
Definition: pedometer.h:58
pedometer_t::step_counter
int16_t step_counter
Definition: pedometer.h:88
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:96
pedometer_default_cfg
void pedometer_default_cfg(pedometer_t *ctx)
Click Default Configuration function.
pedometer_t
Click ctx object definition.
Definition: pedometer.h:82
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:100
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.