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
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_analog_in.h"
48 
63 #define ANALOGMUX5_SEL_CH_1 0x01
64 #define ANALOGMUX5_SEL_CH_2 0x02
65 #define ANALOGMUX5_SEL_CH_3 0x03
66 #define ANALOGMUX5_SEL_CH_4 0x04
67  // ch_select
69 
84 #define ANALOGMUX5_MAP_MIKROBUS( cfg, mikrobus ) \
85  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
86  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
87  cfg.a0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
88  cfg.a1 = MIKROBUS( mikrobus, MIKROBUS_INT )
89  // analogmux5_map // analogmux5
92 
97 typedef struct
98 {
99  digital_out_t en;
100  digital_out_t a0;
101  digital_out_t a1;
103  analog_in_t adc;
105 } analogmux5_t;
106 
111 typedef struct
112 {
113  pin_name_t an;
114  pin_name_t en;
115  pin_name_t a0;
116  pin_name_t a1;
118  analog_in_resolution_t resolution;
119  float vref;
122 
127 typedef enum
128 {
130  ANALOGMUX5_ERROR = -1
131 
133 
150 
166 
181 
194 err_t analogmux5_read_an_pin_value ( analogmux5_t *ctx, uint16_t *data_out );
195 
210 err_t analogmux5_read_an_pin_voltage ( analogmux5_t *ctx, float *data_out );
211 
221 
231 
250 err_t analogmux5_select_ch ( analogmux5_t *ctx, uint8_t ch_select );
251 
252 #ifdef __cplusplus
253 }
254 #endif
255 #endif // ANALOGMUX5_H
256  // analogmux5
258 
259 // ------------------------------------------------------------------------ END
analogmux5_t::a0
digital_out_t a0
Definition: analogmux5.h:100
analogmux5_init
err_t analogmux5_init(analogmux5_t *ctx, analogmux5_cfg_t *cfg)
Analog MUX 5 initialization function.
analogmux5_cfg_setup
void analogmux5_cfg_setup(analogmux5_cfg_t *cfg)
Analog MUX 5 configuration object setup function.
analogmux5_t::adc
analog_in_t adc
Definition: analogmux5.h:103
analogmux5_cfg_t::vref
float vref
Definition: analogmux5.h:119
analogmux5_cfg_t::an
pin_name_t an
Definition: analogmux5.h:113
analogmux5_cfg_t::a1
pin_name_t a1
Definition: analogmux5.h:116
ANALOGMUX5_OK
@ ANALOGMUX5_OK
Definition: analogmux5.h:129
analogmux5_disable
void analogmux5_disable(analogmux5_t *ctx)
Analog MUX 5 disable function.
analogmux5_select_ch
err_t analogmux5_select_ch(analogmux5_t *ctx, uint8_t ch_select)
Analog MUX 5 set channel function.
ANALOGMUX5_ERROR
@ ANALOGMUX5_ERROR
Definition: analogmux5.h:130
analogmux5_t::a1
digital_out_t a1
Definition: analogmux5.h:101
analogmux5_cfg_t
Analog MUX 5 Click configuration object.
Definition: analogmux5.h:112
analogmux5_read_an_pin_value
err_t analogmux5_read_an_pin_value(analogmux5_t *ctx, uint16_t *data_out)
Analog MUX 5 read AN pin value function.
analogmux5_t
Analog MUX 5 Click context object.
Definition: analogmux5.h:98
analogmux5_cfg_t::en
pin_name_t en
Definition: analogmux5.h:114
analogmux5_enable
void analogmux5_enable(analogmux5_t *ctx)
Analog MUX 5 enable function.
analogmux5_cfg_t::resolution
analog_in_resolution_t resolution
Definition: analogmux5.h:118
analogmux5_t::en
digital_out_t en
Definition: analogmux5.h:99
analogmux5_return_value_t
analogmux5_return_value_t
Analog MUX 5 Click return value data.
Definition: analogmux5.h:128
analogmux5_read_an_pin_voltage
err_t analogmux5_read_an_pin_voltage(analogmux5_t *ctx, float *data_out)
Analog MUX 5 read AN pin voltage level function.
analogmux5_default_cfg
err_t analogmux5_default_cfg(analogmux5_t *ctx)
Analog MUX 5 default configuration function.
analogmux5_cfg_t::a0
pin_name_t a0
Definition: analogmux5.h:115