mux  2.0.0.0
mux.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 MUX_H
36 #define MUX_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 MUX_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 
71 #define MUX_RETVAL uint8_t
72 
73 #define MUX_OK 0x00
74 #define MUX_INIT_ERROR 0xFF
75 
81 #define MUX_CHANNEL_1A_AND_1B 0x01
82 #define MUX_CHANNEL_2A_AND_2B 0x02
83 #define MUX_CHANNEL_3A_AND_3B 0x03
84 #define MUX_CHANNEL_4A_AND_4B 0x04
85 #define MUX_CHANNEL_END 0x05
86  // End group macro
89 // --------------------------------------------------------------- PUBLIC TYPES
98 typedef struct
99 {
100  // Output pins
101 
102  digital_out_t a0;
103  digital_out_t en;
104  digital_out_t a1;
105 
106 } mux_t;
107 
111 typedef struct
112 {
113  // Additional gpio pins
114 
115  pin_name_t a0;
116  pin_name_t en;
117  pin_name_t a1;
118 
119 } mux_cfg_t;
120  // End types group
122 
123 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
124 
130 #ifdef __cplusplus
131 extern "C"{
132 #endif
133 
142 void mux_cfg_setup ( mux_cfg_t *cfg );
143 
152 
160 void mux_device_enable ( mux_t *ctx );
161 
169 void mux_device_disable ( mux_t *ctx );
170 
195 void mux_active_mux_channel ( mux_t *ctx, uint8_t sel_ch );
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 #endif // _MUX_H_
201  // End public_function group
204 
205 // ------------------------------------------------------------------------- END
mux_active_mux_channel
void mux_active_mux_channel(mux_t *ctx, uint8_t sel_ch)
Seelect active MUX channel.
mux_t::en
digital_out_t en
Definition: mux.h:103
mux_device_disable
void mux_device_disable(mux_t *ctx)
Disable MUX device function.
mux_device_enable
void mux_device_enable(mux_t *ctx)
Enable MUX device function.
mux_cfg_t::a0
pin_name_t a0
Definition: mux.h:115
mux_t::a0
digital_out_t a0
Definition: mux.h:102
MUX_RETVAL
#define MUX_RETVAL
Definition: mux.h:71
mux_cfg_t::a1
pin_name_t a1
Definition: mux.h:117
mux_cfg_setup
void mux_cfg_setup(mux_cfg_t *cfg)
Config Object Initialization function.
mux_cfg_t::en
pin_name_t en
Definition: mux.h:116
mux_init
MUX_RETVAL mux_init(mux_t *ctx, mux_cfg_t *cfg)
Initialization function.
mux_t::a1
digital_out_t a1
Definition: mux.h:104
mux_t
Click ctx object definition.
Definition: mux.h:99
mux_cfg_t
Click configuration structure definition.
Definition: mux.h:112