analogmux5 2.0.0.0
analogmux5.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 ANALOGMUX5_H
29#define ANALOGMUX5_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#include "drv_analog_in.h"
52
67#define ANALOGMUX5_SEL_CH_1 0x01
68#define ANALOGMUX5_SEL_CH_2 0x02
69#define ANALOGMUX5_SEL_CH_3 0x03
70#define ANALOGMUX5_SEL_CH_4 0x04
71
72 // ch_select
73
88#define ANALOGMUX5_MAP_MIKROBUS( cfg, mikrobus ) \
89 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
90 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
91 cfg.a0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
92 cfg.a1 = MIKROBUS( mikrobus, MIKROBUS_INT )
93
94 // analogmux5_map
95 // analogmux5
96
101typedef struct
102{
103 digital_out_t en;
104 digital_out_t a0;
105 digital_out_t a1;
107 analog_in_t adc;
110
115typedef struct
116{
117 pin_name_t an;
118 pin_name_t en;
119 pin_name_t a0;
120 pin_name_t a1;
122 analog_in_resolution_t resolution;
123 float vref;
126
137
154
170
185
198err_t analogmux5_read_an_pin_value ( analogmux5_t *ctx, uint16_t *data_out );
199
214err_t analogmux5_read_an_pin_voltage ( analogmux5_t *ctx, float *data_out );
215
225
235
254err_t analogmux5_select_ch ( analogmux5_t *ctx, uint8_t ch_select );
255
256#ifdef __cplusplus
257}
258#endif
259#endif // ANALOGMUX5_H
260
261 // analogmux5
262
263// ------------------------------------------------------------------------ END
analogmux5_return_value_t
Analog MUX 5 Click return value data.
Definition analogmux5.h:132
@ ANALOGMUX5_OK
Definition analogmux5.h:133
@ ANALOGMUX5_ERROR
Definition analogmux5.h:134
err_t analogmux5_default_cfg(analogmux5_t *ctx)
Analog MUX 5 default configuration function.
err_t analogmux5_select_ch(analogmux5_t *ctx, uint8_t ch_select)
Analog MUX 5 set channel function.
err_t analogmux5_read_an_pin_voltage(analogmux5_t *ctx, float *data_out)
Analog MUX 5 read AN pin voltage level function.
err_t analogmux5_init(analogmux5_t *ctx, analogmux5_cfg_t *cfg)
Analog MUX 5 initialization function.
void analogmux5_disable(analogmux5_t *ctx)
Analog MUX 5 disable function.
err_t analogmux5_read_an_pin_value(analogmux5_t *ctx, uint16_t *data_out)
Analog MUX 5 read AN pin value function.
void analogmux5_cfg_setup(analogmux5_cfg_t *cfg)
Analog MUX 5 configuration object setup function.
void analogmux5_enable(analogmux5_t *ctx)
Analog MUX 5 enable function.
Analog MUX 5 Click configuration object.
Definition analogmux5.h:116
analog_in_resolution_t resolution
Definition analogmux5.h:122
float vref
Definition analogmux5.h:123
pin_name_t a0
Definition analogmux5.h:119
pin_name_t en
Definition analogmux5.h:118
pin_name_t a1
Definition analogmux5.h:120
pin_name_t an
Definition analogmux5.h:117
Analog MUX 5 Click context object.
Definition analogmux5.h:102
digital_out_t a0
Definition analogmux5.h:104
digital_out_t a1
Definition analogmux5.h:105
digital_out_t en
Definition analogmux5.h:103
analog_in_t adc
Definition analogmux5.h:107