mux2  2.0.0.0
mux2.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef MUX2_H
36 #define MUX2_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define MUX2_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
53  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
54  cfg.a1= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
55  cfg.a2= MIKROBUS( mikrobus, MIKROBUS_INT );
56 
62 #define MUX2_RETVAL uint8_t
63 
64 #define MUX2_OK 0x00
65 #define MUX2_INIT_ERROR 0xFF
66 
72 #define MUX2_CHANNEL_S1 0x01
73 #define MUX2_CHANNEL_S2 0x02
74 #define MUX2_CHANNEL_S3 0x03
75 #define MUX2_CHANNEL_S4 0x04
76 #define MUX2_CHANNEL_S5 0x05
77 #define MUX2_CHANNEL_S6 0x06
78 #define MUX2_CHANNEL_S7 0x07
79 #define MUX2_CHANNEL_S8 0x08
80 #define MUX2_CHANNEL_END 0x09
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef struct
94 {
95  // Output pins
96 
97  digital_out_t a0;
98  digital_out_t en;
99  digital_out_t a1;
100  digital_out_t a2;
101 
102 } mux2_t;
103 
107 typedef struct
108 {
109  // Additional gpio pins
110 
111  //pin_name_t an;
112  pin_name_t a0;
113  pin_name_t en;
114  pin_name_t a1;
115  pin_name_t a2;
116 
117 } mux2_cfg_t;
118  // End types group
120 
121 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122 
128 #ifdef __cplusplus
129 extern "C"{
130 #endif
131 
141 
150 
159 
168 
209 void mux2_active_mux_channel ( mux2_t *ctx, uint8_t sel_ch );
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // _MUX2_H_
215  // End public_function group
218 
219 // ------------------------------------------------------------------------- END
mux2_active_mux_channel
void mux2_active_mux_channel(mux2_t *ctx, uint8_t sel_ch)
Seelect active MUX channel.
mux2_cfg_setup
void mux2_cfg_setup(mux2_cfg_t *cfg)
Config Object Initialization function.
mux2_device_enable
void mux2_device_enable(mux2_t *ctx)
Enable MUX device function.
mux2_init
MUX2_RETVAL mux2_init(mux2_t *ctx, mux2_cfg_t *cfg)
Initialization function.
mux2_cfg_t::a1
pin_name_t a1
Definition: mux2.h:114
mux2_t::a1
digital_out_t a1
Definition: mux2.h:99
MUX2_RETVAL
#define MUX2_RETVAL
Definition: mux2.h:62
mux2_t::en
digital_out_t en
Definition: mux2.h:98
mux2_device_disable
void mux2_device_disable(mux2_t *ctx)
Disable MUX device function.
mux2_t
Click ctx object definition.
Definition: mux2.h:94
mux2_t::a0
digital_out_t a0
Definition: mux2.h:97
mux2_cfg_t::a2
pin_name_t a2
Definition: mux2.h:115
mux2_cfg_t::en
pin_name_t en
Definition: mux2.h:113
mux2_t::a2
digital_out_t a2
Definition: mux2.h:100
mux2_cfg_t
Click configuration structure definition.
Definition: mux2.h:108
mux2_cfg_t::a0
pin_name_t a0
Definition: mux2.h:112