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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_analog_in.h"
38 
53 #define ANALOGMUX5_SEL_CH_1 0x01
54 #define ANALOGMUX5_SEL_CH_2 0x02
55 #define ANALOGMUX5_SEL_CH_3 0x03
56 #define ANALOGMUX5_SEL_CH_4 0x04
57  // ch_select
59 
74 #define ANALOGMUX5_MAP_MIKROBUS( cfg, mikrobus ) \
75  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
76  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
77  cfg.a0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
78  cfg.a1 = MIKROBUS( mikrobus, MIKROBUS_INT )
79  // analogmux5_map // analogmux5
82 
87 typedef struct
88 {
89  digital_out_t en;
90  digital_out_t a0;
91  digital_out_t a1;
93  analog_in_t adc;
95 } analogmux5_t;
96 
101 typedef struct
102 {
103  pin_name_t an;
104  pin_name_t en;
105  pin_name_t a0;
106  pin_name_t a1;
108  analog_in_resolution_t resolution;
109  float vref;
112 
117 typedef enum
118 {
120  ANALOGMUX5_ERROR = -1
121 
123 
140 
156 
171 
184 err_t analogmux5_read_an_pin_value ( analogmux5_t *ctx, uint16_t *data_out );
185 
200 err_t analogmux5_read_an_pin_voltage ( analogmux5_t *ctx, float *data_out );
201 
211 
221 
240 err_t analogmux5_select_ch ( analogmux5_t *ctx, uint8_t ch_select );
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 #endif // ANALOGMUX5_H
246  // analogmux5
248 
249 // ------------------------------------------------------------------------ END
analogmux5_t::a0
digital_out_t a0
Definition: analogmux5.h:90
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:93
analogmux5_cfg_t::vref
float vref
Definition: analogmux5.h:109
analogmux5_cfg_t::an
pin_name_t an
Definition: analogmux5.h:103
analogmux5_cfg_t::a1
pin_name_t a1
Definition: analogmux5.h:106
ANALOGMUX5_OK
@ ANALOGMUX5_OK
Definition: analogmux5.h:119
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:120
analogmux5_t::a1
digital_out_t a1
Definition: analogmux5.h:91
analogmux5_cfg_t
Analog MUX 5 Click configuration object.
Definition: analogmux5.h:102
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:88
analogmux5_cfg_t::en
pin_name_t en
Definition: analogmux5.h:104
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:108
analogmux5_t::en
digital_out_t en
Definition: analogmux5.h:89
analogmux5_return_value_t
analogmux5_return_value_t
Analog MUX 5 Click return value data.
Definition: analogmux5.h:118
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:105