mux2  2.0.0.0
mux2.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef MUX2_H
36 #define MUX2_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define MUX2_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
53  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
54  cfg.a1= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
55  cfg.a2= MIKROBUS( mikrobus, MIKROBUS_INT );
56 
62 #define MUX2_RETVAL uint8_t
63 
64 #define MUX2_OK 0x00
65 #define MUX2_INIT_ERROR 0xFF
66 
72 #define MUX2_CHANNEL_S1 0x01
73 #define MUX2_CHANNEL_S2 0x02
74 #define MUX2_CHANNEL_S3 0x03
75 #define MUX2_CHANNEL_S4 0x04
76 #define MUX2_CHANNEL_S5 0x05
77 #define MUX2_CHANNEL_S6 0x06
78 #define MUX2_CHANNEL_S7 0x07
79 #define MUX2_CHANNEL_S8 0x08
80 #define MUX2_CHANNEL_END 0x09
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef struct
94 {
95  // Output pins
96 
97  digital_out_t a0;
98  digital_out_t en;
99  digital_out_t a1;
100  digital_out_t a2;
101 
102 } mux2_t;
103 
107 typedef struct
108 {
109  // Additional gpio pins
110 
111  //pin_name_t an;
112  pin_name_t a0;
113  pin_name_t en;
114  pin_name_t a1;
115  pin_name_t a2;
116 
117 } mux2_cfg_t;
118  // End types group
120 
121 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122 
128 #ifdef __cplusplus
129 extern "C"{
130 #endif
131 
140 void mux2_cfg_setup ( mux2_cfg_t *cfg );
141 
149 MUX2_RETVAL mux2_init ( mux2_t *ctx, mux2_cfg_t *cfg );
150 
158 void mux2_device_enable ( mux2_t *ctx );
159 
167 void mux2_device_disable ( mux2_t *ctx );
168 
209 void mux2_active_mux_channel ( mux2_t *ctx, uint8_t sel_ch );
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // _MUX2_H_
215  // End public_function group
218 
219 // ------------------------------------------------------------------------- END
void mux2_active_mux_channel(mux2_t *ctx, uint8_t sel_ch)
Seelect active MUX channel.
MUX2_RETVAL mux2_init(mux2_t *ctx, mux2_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition: mux2.h:107
digital_out_t a0
Definition: mux2.h:97
void mux2_device_enable(mux2_t *ctx)
Enable MUX device function.
Click ctx object definition.
Definition: mux2.h:93
void mux2_cfg_setup(mux2_cfg_t *cfg)
Config Object Initialization function.
digital_out_t a2
Definition: mux2.h:100
void mux2_device_disable(mux2_t *ctx)
Disable MUX device function.
pin_name_t en
Definition: mux2.h:113
#define MUX2_RETVAL
Definition: mux2.h:62
pin_name_t a0
Definition: mux2.h:112
pin_name_t a2
Definition: mux2.h:115
digital_out_t a1
Definition: mux2.h:99
digital_out_t en
Definition: mux2.h:98
pin_name_t a1
Definition: mux2.h:114