mux3  2.0.0.0
mux3.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 MUX3_H
36 #define MUX3_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 MUX3_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.a1= MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
64  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
65  cfg.a2= MIKROBUS( mikrobus, MIKROBUS_PWM )
66 
72 #define MUX3_RETVAL uint8_t
73 
74 #define MUX3_OK 0x00
75 #define MUX3_INIT_ERROR 0xFF
76 
82 #define MUX3_DISABLE_ALL_CHANNELS 0x00
83 #define MUX3_ENABLE_CHANNEL_S1 0x01
84 #define MUX3_ENABLE_CHANNEL_S2 0x02
85 #define MUX3_ENABLE_CHANNEL_S3 0x03
86 #define MUX3_ENABLE_CHANNEL_S4 0x04
87 #define MUX3_ENABLE_CHANNEL_S5 0x05
88 #define MUX3_ENABLE_CHANNEL_S6 0x06
89 #define MUX3_ENABLE_CHANNEL_S7 0x07
90 #define MUX3_ENABLE_CHANNEL_S8 0x08
91  // End group macro
94 // --------------------------------------------------------------- PUBLIC TYPES
103 typedef struct
104 {
105  // Output pins
106 
107  digital_out_t a1;
108  digital_out_t a0;
109  digital_out_t en;
110  digital_out_t a2;
111 
112 } mux3_t;
113 
117 typedef struct
118 {
119  // Additional gpio pins
120 
121  pin_name_t a1;
122  pin_name_t a0;
123  pin_name_t en;
124  pin_name_t a2;
125 
126 } mux3_cfg_t;
127  // End types group
129 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130 
136 #ifdef __cplusplus
137 extern "C"{
138 #endif
139 
149 
158 
178 void mux3_set_channel ( mux3_t *ctx, uint8_t select_channel );
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 #endif // _MUX3_H_
184  // End public_function group
187 
188 // ------------------------------------------------------------------------- END
mux3_set_channel
void mux3_set_channel(mux3_t *ctx, uint8_t select_channel)
Set active MUX channel function.
mux3_t::a2
digital_out_t a2
Definition: mux3.h:110
mux3_t::en
digital_out_t en
Definition: mux3.h:109
mux3_cfg_t::en
pin_name_t en
Definition: mux3.h:123
mux3_t::a0
digital_out_t a0
Definition: mux3.h:108
MUX3_RETVAL
#define MUX3_RETVAL
Definition: mux3.h:72
mux3_t::a1
digital_out_t a1
Definition: mux3.h:107
mux3_cfg_setup
void mux3_cfg_setup(mux3_cfg_t *cfg)
Config Object Initialization function.
mux3_cfg_t::a2
pin_name_t a2
Definition: mux3.h:124
mux3_cfg_t::a1
pin_name_t a1
Definition: mux3.h:121
mux3_t
Click ctx object definition.
Definition: mux3.h:104
mux3_cfg_t::a0
pin_name_t a0
Definition: mux3.h:122
mux3_cfg_t
Click configuration structure definition.
Definition: mux3.h:118
mux3_init
MUX3_RETVAL mux3_init(mux3_t *ctx, mux3_cfg_t *cfg)
Initialization function.