analogmux4 2.0.0.0
analogmux4.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 ANALOGMUX4_H
29#define ANALOGMUX4_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
73#define ANALOGMUX4_CHANNEL_0 0x00
74#define ANALOGMUX4_CHANNEL_1 0x01
75#define ANALOGMUX4_CHANNEL_2 0x02
76#define ANALOGMUX4_CHANNEL_3 0x03
77#define ANALOGMUX4_CHANNEL_4 0x04
78#define ANALOGMUX4_CHANNEL_5 0x05
79#define ANALOGMUX4_CHANNEL_6 0x06
80#define ANALOGMUX4_CHANNEL_7 0x07
81
82 // analogmux4_set
83
98#define ANALOGMUX4_MAP_MIKROBUS( cfg, mikrobus ) \
99 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
100 cfg.a2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
101 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
102 cfg.a0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
103 cfg.a1 = MIKROBUS( mikrobus, MIKROBUS_INT )
104
105 // analogmux4_map
106 // analogmux4
107
112typedef struct
113{
114 digital_out_t a0;
115 digital_out_t en;
116 digital_out_t a2;
117 digital_out_t a1;
119 analog_in_t adc;
122
127typedef struct
128{
129 pin_name_t an;
130 pin_name_t a0;
131 pin_name_t en;
132 pin_name_t a2;
133 pin_name_t a1;
135 analog_in_resolution_t resolution;
136 float vref;
139
150
167
183
196err_t analogmux4_read_an_pin_value ( analogmux4_t *ctx, uint16_t *data_out );
197
212err_t analogmux4_read_an_pin_voltage ( analogmux4_t *ctx, float *data_out );
213
223
233
243void analogmux4_set_input_channel ( analogmux4_t *ctx, uint8_t channel );
244
245#ifdef __cplusplus
246}
247#endif
248#endif // ANALOGMUX4_H
249
250 // analogmux4
251
252// ------------------------------------------------------------------------ END
analogmux4_return_value_t
Analog MUX 4 Click return value data.
Definition analogmux4.h:145
@ ANALOGMUX4_ERROR
Definition analogmux4.h:147
@ ANALOGMUX4_OK
Definition analogmux4.h:146
void analogmux4_set_input_channel(analogmux4_t *ctx, uint8_t channel)
Analog MUX 4 set input channel function.
void analogmux4_cfg_setup(analogmux4_cfg_t *cfg)
Analog MUX 4 configuration object setup function.
err_t analogmux4_read_an_pin_voltage(analogmux4_t *ctx, float *data_out)
Analog MUX 4 read AN pin voltage level function.
void analogmux4_disable_input(analogmux4_t *ctx)
Analog MUX 4 disable input function.
err_t analogmux4_read_an_pin_value(analogmux4_t *ctx, uint16_t *data_out)
Analog MUX 4 read AN pin value function.
err_t analogmux4_init(analogmux4_t *ctx, analogmux4_cfg_t *cfg)
Analog MUX 4 initialization function.
void analogmux4_enable_input(analogmux4_t *ctx)
Analog MUX 4 enable input function.
Analog MUX 4 Click configuration object.
Definition analogmux4.h:128
analog_in_resolution_t resolution
Definition analogmux4.h:135
float vref
Definition analogmux4.h:136
pin_name_t a0
Definition analogmux4.h:130
pin_name_t a2
Definition analogmux4.h:132
pin_name_t en
Definition analogmux4.h:131
pin_name_t a1
Definition analogmux4.h:133
pin_name_t an
Definition analogmux4.h:129
Analog MUX 4 Click context object.
Definition analogmux4.h:113
digital_out_t a0
Definition analogmux4.h:114
digital_out_t a1
Definition analogmux4.h:117
digital_out_t en
Definition analogmux4.h:115
digital_out_t a2
Definition analogmux4.h:116
analog_in_t adc
Definition analogmux4.h:119