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
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define MUX3_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.a1= MIKROBUS( mikrobus, MIKROBUS_AN ); \
67 cfg.a0= MIKROBUS( mikrobus, MIKROBUS_RST ); \
68 cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
69 cfg.a2= MIKROBUS( mikrobus, MIKROBUS_PWM )
76#define MUX3_RETVAL uint8_t
77
78#define MUX3_OK 0x00
79#define MUX3_INIT_ERROR 0xFF
86#define MUX3_DISABLE_ALL_CHANNELS 0x00
87#define MUX3_ENABLE_CHANNEL_S1 0x01
88#define MUX3_ENABLE_CHANNEL_S2 0x02
89#define MUX3_ENABLE_CHANNEL_S3 0x03
90#define MUX3_ENABLE_CHANNEL_S4 0x04
91#define MUX3_ENABLE_CHANNEL_S5 0x05
92#define MUX3_ENABLE_CHANNEL_S6 0x06
93#define MUX3_ENABLE_CHANNEL_S7 0x07
94#define MUX3_ENABLE_CHANNEL_S8 0x08
97 // End group macro
98// --------------------------------------------------------------- PUBLIC TYPES
107typedef struct
108{
109 // Output pins
110
111 digital_out_t a1;
112 digital_out_t a0;
113 digital_out_t en;
114 digital_out_t a2;
115
116} mux3_t;
117
121typedef struct
122{
123 // Additional gpio pins
124
125 pin_name_t a1;
126 pin_name_t a0;
127 pin_name_t en;
128 pin_name_t a2;
129
130} mux3_cfg_t;
131
132 // End types group
133// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
134
140#ifdef __cplusplus
141extern "C"{
142#endif
143
153
162
182void mux3_set_channel ( mux3_t *ctx, uint8_t select_channel );
183
184#ifdef __cplusplus
185}
186#endif
187#endif // _MUX3_H_
188
189 // End public_function group
191
192// ------------------------------------------------------------------------- END
#define MUX3_RETVAL
Definition mux3.h:76
void mux3_cfg_setup(mux3_cfg_t *cfg)
Config Object Initialization function.
MUX3_RETVAL mux3_init(mux3_t *ctx, mux3_cfg_t *cfg)
Initialization function.
void mux3_set_channel(mux3_t *ctx, uint8_t select_channel)
Set active MUX channel function.
Click configuration structure definition.
Definition mux3.h:122
pin_name_t a0
Definition mux3.h:126
pin_name_t a2
Definition mux3.h:128
pin_name_t en
Definition mux3.h:127
pin_name_t a1
Definition mux3.h:125
Click ctx object definition.
Definition mux3.h:108
digital_out_t a0
Definition mux3.h:112
digital_out_t a1
Definition mux3.h:111
digital_out_t en
Definition mux3.h:113
digital_out_t a2
Definition mux3.h:114