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 
42 #ifdef PREINIT_SUPPORTED
43 #include "preinit.h"
44 #endif
45 
46 #ifdef MikroCCoreVersion
47  #if MikroCCoreVersion >= 1
48  #include "delays.h"
49  #endif
50 #endif
51 
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 
55 // -------------------------------------------------------------- PUBLIC MACROS
65 #define MUX2_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
67  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
68  cfg.a1= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
69  cfg.a2= MIKROBUS( mikrobus, MIKROBUS_INT );
70 
76 #define MUX2_RETVAL uint8_t
77 
78 #define MUX2_OK 0x00
79 #define MUX2_INIT_ERROR 0xFF
80 
86 #define MUX2_CHANNEL_S1 0x01
87 #define MUX2_CHANNEL_S2 0x02
88 #define MUX2_CHANNEL_S3 0x03
89 #define MUX2_CHANNEL_S4 0x04
90 #define MUX2_CHANNEL_S5 0x05
91 #define MUX2_CHANNEL_S6 0x06
92 #define MUX2_CHANNEL_S7 0x07
93 #define MUX2_CHANNEL_S8 0x08
94 #define MUX2_CHANNEL_END 0x09
95  // End group macro
98 // --------------------------------------------------------------- PUBLIC TYPES
107 typedef struct
108 {
109  // Output pins
110 
111  digital_out_t a0;
112  digital_out_t en;
113  digital_out_t a1;
114  digital_out_t a2;
115 
116 } mux2_t;
117 
121 typedef struct
122 {
123  // Additional gpio pins
124 
125  //pin_name_t an;
126  pin_name_t a0;
127  pin_name_t en;
128  pin_name_t a1;
129  pin_name_t a2;
130 
131 } mux2_cfg_t;
132  // End types group
134 
135 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
136 
142 #ifdef __cplusplus
143 extern "C"{
144 #endif
145 
155 
164 
173 
182 
223 void mux2_active_mux_channel ( mux2_t *ctx, uint8_t sel_ch );
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 #endif // _MUX2_H_
229  // End public_function group
232 
233 // ------------------------------------------------------------------------- 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:128
mux2_t::a1
digital_out_t a1
Definition: mux2.h:113
MUX2_RETVAL
#define MUX2_RETVAL
Definition: mux2.h:76
mux2_t::en
digital_out_t en
Definition: mux2.h:112
mux2_device_disable
void mux2_device_disable(mux2_t *ctx)
Disable MUX device function.
mux2_t
Click ctx object definition.
Definition: mux2.h:108
mux2_t::a0
digital_out_t a0
Definition: mux2.h:111
mux2_cfg_t::a2
pin_name_t a2
Definition: mux2.h:129
mux2_cfg_t::en
pin_name_t en
Definition: mux2.h:127
mux2_t::a2
digital_out_t a2
Definition: mux2.h:114
mux2_cfg_t
Click configuration structure definition.
Definition: mux2.h:122
mux2_cfg_t::a0
pin_name_t a0
Definition: mux2.h:126