mux4 2.0.0.0
mux4.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 MUX4_H
29#define MUX4_H
30
31#ifdef __cplusplus
32extern "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 MUX4_ENABLE_INPUT 0
60#define MUX4_DISABLE_INPUT 1
61
66#define MUX4_SELECT_INPUT_1 1
67#define MUX4_SELECT_INPUT_2 2
68#define MUX4_SELECT_INPUT_3 3
69#define MUX4_SELECT_INPUT_4 4
70#define MUX4_SELECT_INPUT_5 5
71#define MUX4_SELECT_INPUT_6 6
72#define MUX4_SELECT_INPUT_7 7
73#define MUX4_SELECT_INPUT_8 8
74 // mux4_set
76
91#define MUX4_MAP_MIKROBUS( cfg, mikrobus ) \
92 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
93 cfg.s2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
94 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
95 cfg.s0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
96 cfg.s1 = MIKROBUS( mikrobus, MIKROBUS_INT )
97 // mux4_map // mux4
100
105typedef struct
106{
107 digital_out_t s2;
108 digital_out_t en;
109 digital_out_t s0;
110 digital_out_t s1;
112 analog_in_t adc;
114} mux4_t;
115
120typedef struct
121{
122 pin_name_t an;
123 pin_name_t s2;
124 pin_name_t en;
125 pin_name_t s0;
126 pin_name_t s1;
128 analog_in_resolution_t resolution;
129 float vref;
131} mux4_cfg_t;
132
137typedef enum
138{
140 MUX4_ERROR = -1
141
143
160
175err_t mux4_init ( mux4_t *ctx, mux4_cfg_t *cfg );
176
189err_t mux4_read_an_pin_value ( mux4_t *ctx, uint16_t *data_out );
190
205err_t mux4_read_an_pin_voltage ( mux4_t *ctx, float *data_out );
206
217void mux4_enable_input ( mux4_t *ctx, uint8_t en_state );
218
228void mux4_select_input ( mux4_t *ctx, uint8_t input );
229
230#ifdef __cplusplus
231}
232#endif
233#endif // MUX4_H
234 // mux4
236
237// ------------------------------------------------------------------------ END
err_t mux4_init(mux4_t *ctx, mux4_cfg_t *cfg)
MUX 4 initialization function.
void mux4_select_input(mux4_t *ctx, uint8_t input)
MUX 4 select input function.
err_t mux4_read_an_pin_voltage(mux4_t *ctx, float *data_out)
MUX 4 read AN pin voltage level function.
void mux4_cfg_setup(mux4_cfg_t *cfg)
MUX 4 configuration object setup function.
void mux4_enable_input(mux4_t *ctx, uint8_t en_state)
MUX 4 enable input function.
err_t mux4_read_an_pin_value(mux4_t *ctx, uint16_t *data_out)
MUX 4 read AN pin value function.
mux4_return_value_t
MUX 4 Click return value data.
Definition: mux4.h:138
@ MUX4_ERROR
Definition: mux4.h:140
@ MUX4_OK
Definition: mux4.h:139
MUX 4 Click configuration object.
Definition: mux4.h:121
pin_name_t s2
Definition: mux4.h:123
pin_name_t s0
Definition: mux4.h:125
analog_in_resolution_t resolution
Definition: mux4.h:128
float vref
Definition: mux4.h:129
pin_name_t s1
Definition: mux4.h:126
pin_name_t en
Definition: mux4.h:124
pin_name_t an
Definition: mux4.h:122
MUX 4 Click context object.
Definition: mux4.h:106
digital_out_t s2
Definition: mux4.h:107
digital_out_t en
Definition: mux4.h:108
digital_out_t s1
Definition: mux4.h:110
analog_in_t adc
Definition: mux4.h:112
digital_out_t s0
Definition: mux4.h:109