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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define MUX3_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.a1= MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
54  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
55  cfg.a2= MIKROBUS( mikrobus, MIKROBUS_PWM )
56 
62 #define MUX3_RETVAL uint8_t
63 
64 #define MUX3_OK 0x00
65 #define MUX3_INIT_ERROR 0xFF
66 
72 #define MUX3_DISABLE_ALL_CHANNELS 0x00
73 #define MUX3_ENABLE_CHANNEL_S1 0x01
74 #define MUX3_ENABLE_CHANNEL_S2 0x02
75 #define MUX3_ENABLE_CHANNEL_S3 0x03
76 #define MUX3_ENABLE_CHANNEL_S4 0x04
77 #define MUX3_ENABLE_CHANNEL_S5 0x05
78 #define MUX3_ENABLE_CHANNEL_S6 0x06
79 #define MUX3_ENABLE_CHANNEL_S7 0x07
80 #define MUX3_ENABLE_CHANNEL_S8 0x08
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef struct
94 {
95  // Output pins
96 
97  digital_out_t a1;
98  digital_out_t a0;
99  digital_out_t en;
100  digital_out_t a2;
101 
102 } mux3_t;
103 
107 typedef struct
108 {
109  // Additional gpio pins
110 
111  pin_name_t a1;
112  pin_name_t a0;
113  pin_name_t en;
114  pin_name_t a2;
115 
116 } mux3_cfg_t;
117  // End types group
119 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
120 
126 #ifdef __cplusplus
127 extern "C"{
128 #endif
129 
139 
148 
168 void mux3_set_channel ( mux3_t *ctx, uint8_t select_channel );
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 #endif // _MUX3_H_
174  // End public_function group
177 
178 // ------------------------------------------------------------------------- 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:100
mux3_t::en
digital_out_t en
Definition: mux3.h:99
mux3_cfg_t::en
pin_name_t en
Definition: mux3.h:113
mux3_t::a0
digital_out_t a0
Definition: mux3.h:98
MUX3_RETVAL
#define MUX3_RETVAL
Definition: mux3.h:62
mux3_t::a1
digital_out_t a1
Definition: mux3.h:97
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:114
mux3_cfg_t::a1
pin_name_t a1
Definition: mux3.h:111
mux3_t
Click ctx object definition.
Definition: mux3.h:94
mux3_cfg_t::a0
pin_name_t a0
Definition: mux3.h:112
mux3_cfg_t
Click configuration structure definition.
Definition: mux3.h:108
mux3_init
MUX3_RETVAL mux3_init(mux3_t *ctx, mux3_cfg_t *cfg)
Initialization function.