analogkey 2.0.0.0
analogkey.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
35#ifndef ANALOGKEY_H
36#define ANALOGKEY_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_analog_in.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
57
67#define ANALOGKEY_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
71 // End group macro
72// --------------------------------------------------------------- PUBLIC TYPES
92
96typedef struct
97{
98 analog_in_t adc;
99 float vref;
100 float vdiv;
103
107typedef struct
108{
109 // Communication gpio pins
110
111 pin_name_t an_pin;
113 // Static variable
114
115 analog_in_resolution_t resolution;
116 float vref;
117 float vsel;
120
121 // End types group
122// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
128#ifdef __cplusplus
129extern "C"{
130#endif
131
141
151
161
171
182
183#ifdef __cplusplus
184}
185#endif
186#endif // ANALOGKEY_H
187
188 // End public_function group
190
191// ------------------------------------------------------------------------ END
uint16_t analogkey_generic_read(analogkey_t *ctx)
Generic read function.
void analogkey_cfg_setup(analogkey_cfg_t *cfg)
Config Object Initialization function.
float analogkey_read_voltage(analogkey_t *ctx)
Generic read function.
analogkey_key_id_t analogkey_get_key(analogkey_t *ctx, float an_value)
Detects which button is pressed.
err_t analogkey_init(analogkey_t *ctx, analogkey_cfg_t *cfg)
Initialization function.
analogkey_key_id_t
Click touch key definition.
Definition analogkey.h:82
@ ANALOGKEY_TOUCH_KEY_2
Definition analogkey.h:85
@ ANALOGKEY_TOUCH_KEY_4
Definition analogkey.h:87
@ ANALOGKEY_TOUCH_KEY_NONE
Definition analogkey.h:83
@ ANALOGKEY_TOUCH_KEY_5
Definition analogkey.h:88
@ ANALOGKEY_TOUCH_KEY_3
Definition analogkey.h:86
@ ANALOGKEY_TOUCH_KEY_1
Definition analogkey.h:84
@ ANALOGKEY_TOUCH_KEY_6
Definition analogkey.h:89
Click configuration structure definition.
Definition analogkey.h:108
analog_in_resolution_t resolution
Definition analogkey.h:115
float vref
Definition analogkey.h:116
pin_name_t an_pin
Definition analogkey.h:111
float vsel
Definition analogkey.h:117
Click ctx object definition.
Definition analogkey.h:97
float vdiv
Definition analogkey.h:100
float vref
Definition analogkey.h:99
analog_in_t adc
Definition analogkey.h:98