usbmux 2.1.0.0
usbmux.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef USBMUX_H
29#define USBMUX_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51
67#define USBMUX_PIN_STATE_LOW 0x00
68#define USBMUX_PIN_STATE_HIGH 0x01
69
74#define USBMUX_USB1_SELECT 0x00
75#define USBMUX_USB2_SELECT 0x01
76
77 // usbmux_set
78
93#define USBMUX_MAP_MIKROBUS( cfg, mikrobus ) \
94 cfg.oe = MIKROBUS( mikrobus, MIKROBUS_RST ); \
95 cfg.sel = MIKROBUS( mikrobus, MIKROBUS_PWM )
96
97 // usbmux_map
98 // usbmux
99
104typedef struct
105{
106 digital_out_t oe;
107 digital_out_t sel;
109} usbmux_t;
110
115typedef struct
116{
117 pin_name_t oe;
118 pin_name_t sel;
121
126typedef enum
127{
129 USBMUX_ERROR = -1
130
132
149
163err_t usbmux_init ( usbmux_t *ctx, usbmux_cfg_t *cfg );
164
176
187void usbmux_set_oe_pin ( usbmux_t *ctx, uint8_t pin_state );
188
199void usbmux_set_sel_pin ( usbmux_t *ctx, uint8_t pin_state );
200
211
222
233void usbmux_set_output ( usbmux_t *ctx, uint8_t out_sel );
234
235#ifdef __cplusplus
236}
237#endif
238#endif // USBMUX_H
239
240 // usbmux
241
242// ------------------------------------------------------------------------ END
void usbmux_set_oe_pin(usbmux_t *ctx, uint8_t pin_state)
USB MUX set OE pin output function.
err_t usbmux_init(usbmux_t *ctx, usbmux_cfg_t *cfg)
USB MUX initialization function.
void usbmux_set_output(usbmux_t *ctx, uint8_t out_sel)
USB MUX select output function.
void usbmux_set_sel_pin(usbmux_t *ctx, uint8_t pin_state)
USB MUX set SEL pin output function.
void usbmux_default_cfg(usbmux_t *ctx)
USB MUX default configuration function.
void usbmux_cfg_setup(usbmux_cfg_t *cfg)
USB MUX configuration object setup function.
void usbmux_enable_output(usbmux_t *ctx)
USB MUX enable output function.
void usbmux_disable_output(usbmux_t *ctx)
USB MUX disable output function.
USB MUX Click configuration object.
Definition usbmux.h:116
pin_name_t oe
Definition usbmux.h:117
pin_name_t sel
Definition usbmux.h:118
USB MUX Click context object.
Definition usbmux.h:105
digital_out_t sel
Definition usbmux.h:107
digital_out_t oe
Definition usbmux.h:106
usbmux_return_value_t
USB MUX Click return value data.
Definition usbmux.h:127
@ USBMUX_ERROR
Definition usbmux.h:129
@ USBMUX_OK
Definition usbmux.h:128