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 
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  // 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  // analogmux5_map // analogmux5
96 
101 typedef struct
102 {
103  digital_out_t en;
104  digital_out_t a0;
105  digital_out_t a1;
107  analog_in_t adc;
109 } analogmux5_t;
110 
115 typedef 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 
131 typedef enum
132 {
134  ANALOGMUX5_ERROR = -1
135 
137 
154 
170 
185 
198 err_t analogmux5_read_an_pin_value ( analogmux5_t *ctx, uint16_t *data_out );
199 
214 err_t analogmux5_read_an_pin_voltage ( analogmux5_t *ctx, float *data_out );
215 
225 
235 
254 err_t analogmux5_select_ch ( analogmux5_t *ctx, uint8_t ch_select );
255 
256 #ifdef __cplusplus
257 }
258 #endif
259 #endif // ANALOGMUX5_H
260  // analogmux5
262 
263 // ------------------------------------------------------------------------ END
analogmux5_t::a0
digital_out_t a0
Definition: analogmux5.h:104
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:107
analogmux5_cfg_t::vref
float vref
Definition: analogmux5.h:123
analogmux5_cfg_t::an
pin_name_t an
Definition: analogmux5.h:117
analogmux5_cfg_t::a1
pin_name_t a1
Definition: analogmux5.h:120
ANALOGMUX5_OK
@ ANALOGMUX5_OK
Definition: analogmux5.h:133
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:134
analogmux5_t::a1
digital_out_t a1
Definition: analogmux5.h:105
analogmux5_cfg_t
Analog MUX 5 Click configuration object.
Definition: analogmux5.h:116
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:102
analogmux5_cfg_t::en
pin_name_t en
Definition: analogmux5.h:118
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:122
analogmux5_t::en
digital_out_t en
Definition: analogmux5.h:103
analogmux5_return_value_t
analogmux5_return_value_t
Analog MUX 5 Click return value data.
Definition: analogmux5.h:132
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:119