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
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 
59 #define ANALOGMUX4_CHANNEL_0 0x00
60 #define ANALOGMUX4_CHANNEL_1 0x01
61 #define ANALOGMUX4_CHANNEL_2 0x02
62 #define ANALOGMUX4_CHANNEL_3 0x03
63 #define ANALOGMUX4_CHANNEL_4 0x04
64 #define ANALOGMUX4_CHANNEL_5 0x05
65 #define ANALOGMUX4_CHANNEL_6 0x06
66 #define ANALOGMUX4_CHANNEL_7 0x07
67  // analogmux4_set
69 
84 #define ANALOGMUX4_MAP_MIKROBUS( cfg, mikrobus ) \
85  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
86  cfg.a2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
87  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
88  cfg.a0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
89  cfg.a1 = MIKROBUS( mikrobus, MIKROBUS_INT )
90  // analogmux4_map // analogmux4
93 
98 typedef struct
99 {
100  digital_out_t a0;
101  digital_out_t en;
102  digital_out_t a2;
103  digital_out_t a1;
105  analog_in_t adc;
107 } analogmux4_t;
108 
113 typedef struct
114 {
115  pin_name_t an;
116  pin_name_t a0;
117  pin_name_t en;
118  pin_name_t a2;
119  pin_name_t a1;
121  analog_in_resolution_t resolution;
122  float vref;
125 
130 typedef enum
131 {
133  ANALOGMUX4_ERROR = -1
134 
136 
153 
169 
182 err_t analogmux4_read_an_pin_value ( analogmux4_t *ctx, uint16_t *data_out );
183 
198 err_t analogmux4_read_an_pin_voltage ( analogmux4_t *ctx, float *data_out );
199 
209 
219 
229 void analogmux4_set_input_channel ( analogmux4_t *ctx, uint8_t channel );
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 #endif // ANALOGMUX4_H
235  // analogmux4
237 
238 // ------------------------------------------------------------------------ END
analogmux4_enable_input
void analogmux4_enable_input(analogmux4_t *ctx)
Analog MUX 4 enable input function.
analogmux4_cfg_t::a0
pin_name_t a0
Definition: analogmux4.h:116
analogmux4_cfg_t::a2
pin_name_t a2
Definition: analogmux4.h:118
analogmux4_return_value_t
analogmux4_return_value_t
Analog MUX 4 Click return value data.
Definition: analogmux4.h:131
analogmux4_cfg_t::vref
float vref
Definition: analogmux4.h:122
analogmux4_cfg_t::an
pin_name_t an
Definition: analogmux4.h:115
analogmux4_read_an_pin_value
err_t analogmux4_read_an_pin_value(analogmux4_t *ctx, uint16_t *data_out)
Analog MUX 4 read AN pin value function.
analogmux4_disable_input
void analogmux4_disable_input(analogmux4_t *ctx)
Analog MUX 4 disable input function.
analogmux4_t::en
digital_out_t en
Definition: analogmux4.h:101
ANALOGMUX4_OK
@ ANALOGMUX4_OK
Definition: analogmux4.h:132
analogmux4_t::a0
digital_out_t a0
Definition: analogmux4.h:100
analogmux4_cfg_t
Analog MUX 4 Click configuration object.
Definition: analogmux4.h:114
analogmux4_t
Analog MUX 4 Click context object.
Definition: analogmux4.h:99
analogmux4_read_an_pin_voltage
err_t analogmux4_read_an_pin_voltage(analogmux4_t *ctx, float *data_out)
Analog MUX 4 read AN pin voltage level function.
analogmux4_cfg_setup
void analogmux4_cfg_setup(analogmux4_cfg_t *cfg)
Analog MUX 4 configuration object setup function.
analogmux4_cfg_t::en
pin_name_t en
Definition: analogmux4.h:117
ANALOGMUX4_ERROR
@ ANALOGMUX4_ERROR
Definition: analogmux4.h:133
analogmux4_t::a1
digital_out_t a1
Definition: analogmux4.h:103
analogmux4_cfg_t::resolution
analog_in_resolution_t resolution
Definition: analogmux4.h:121
analogmux4_t::adc
analog_in_t adc
Definition: analogmux4.h:105
analogmux4_t::a2
digital_out_t a2
Definition: analogmux4.h:102
analogmux4_init
err_t analogmux4_init(analogmux4_t *ctx, analogmux4_cfg_t *cfg)
Analog MUX 4 initialization function.
analogmux4_cfg_t::a1
pin_name_t a1
Definition: analogmux4.h:119
analogmux4_set_input_channel
void analogmux4_set_input_channel(analogmux4_t *ctx, uint8_t channel)
Analog MUX 4 set input channel function.