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 "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define MUX2_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
63  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
64  cfg.a1= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
65  cfg.a2= MIKROBUS( mikrobus, MIKROBUS_INT );
66 
72 #define MUX2_RETVAL uint8_t
73 
74 #define MUX2_OK 0x00
75 #define MUX2_INIT_ERROR 0xFF
76 
82 #define MUX2_CHANNEL_S1 0x01
83 #define MUX2_CHANNEL_S2 0x02
84 #define MUX2_CHANNEL_S3 0x03
85 #define MUX2_CHANNEL_S4 0x04
86 #define MUX2_CHANNEL_S5 0x05
87 #define MUX2_CHANNEL_S6 0x06
88 #define MUX2_CHANNEL_S7 0x07
89 #define MUX2_CHANNEL_S8 0x08
90 #define MUX2_CHANNEL_END 0x09
91  // End group macro
94 // --------------------------------------------------------------- PUBLIC TYPES
103 typedef struct
104 {
105  // Output pins
106 
107  digital_out_t a0;
108  digital_out_t en;
109  digital_out_t a1;
110  digital_out_t a2;
111 
112 } mux2_t;
113 
117 typedef struct
118 {
119  // Additional gpio pins
120 
121  //pin_name_t an;
122  pin_name_t a0;
123  pin_name_t en;
124  pin_name_t a1;
125  pin_name_t a2;
126 
127 } mux2_cfg_t;
128  // End types group
130 
131 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
132 
138 #ifdef __cplusplus
139 extern "C"{
140 #endif
141 
151 
160 
169 
178 
219 void mux2_active_mux_channel ( mux2_t *ctx, uint8_t sel_ch );
220 
221 #ifdef __cplusplus
222 }
223 #endif
224 #endif // _MUX2_H_
225  // End public_function group
228 
229 // ------------------------------------------------------------------------- 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:124
mux2_t::a1
digital_out_t a1
Definition: mux2.h:109
MUX2_RETVAL
#define MUX2_RETVAL
Definition: mux2.h:72
mux2_t::en
digital_out_t en
Definition: mux2.h:108
mux2_device_disable
void mux2_device_disable(mux2_t *ctx)
Disable MUX device function.
mux2_t
Click ctx object definition.
Definition: mux2.h:104
mux2_t::a0
digital_out_t a0
Definition: mux2.h:107
mux2_cfg_t::a2
pin_name_t a2
Definition: mux2.h:125
mux2_cfg_t::en
pin_name_t en
Definition: mux2.h:123
mux2_t::a2
digital_out_t a2
Definition: mux2.h:110
mux2_cfg_t
Click configuration structure definition.
Definition: mux2.h:118
mux2_cfg_t::a0
pin_name_t a0
Definition: mux2.h:122