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
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37
53#define USBMUX_PIN_STATE_LOW 0x00
54#define USBMUX_PIN_STATE_HIGH 0x01
55
60#define USBMUX_USB1_SELECT 0x00
61#define USBMUX_USB2_SELECT 0x01
62 // usbmux_set
64
79#define USBMUX_MAP_MIKROBUS( cfg, mikrobus ) \
80 cfg.oe = MIKROBUS( mikrobus, MIKROBUS_RST ); \
81 cfg.sel = MIKROBUS( mikrobus, MIKROBUS_PWM )
82 // usbmux_map // usbmux
85
90typedef struct
91{
92 digital_out_t oe;
93 digital_out_t sel;
95} usbmux_t;
96
101typedef struct
102{
103 pin_name_t oe;
104 pin_name_t sel;
107
112typedef enum
113{
115 USBMUX_ERROR = -1
116
118
135
149err_t usbmux_init ( usbmux_t *ctx, usbmux_cfg_t *cfg );
150
162
173void usbmux_set_oe_pin ( usbmux_t *ctx, uint8_t pin_state );
174
185void usbmux_set_sel_pin ( usbmux_t *ctx, uint8_t pin_state );
186
197
208
219void usbmux_set_output ( usbmux_t *ctx, uint8_t out_sel );
220
221#ifdef __cplusplus
222}
223#endif
224#endif // USBMUX_H
225 // usbmux
227
228// ------------------------------------------------------------------------ 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:102
pin_name_t oe
Definition: usbmux.h:103
pin_name_t sel
Definition: usbmux.h:104
USB MUX Click context object.
Definition: usbmux.h:91
digital_out_t sel
Definition: usbmux.h:93
digital_out_t oe
Definition: usbmux.h:92
usbmux_return_value_t
USB MUX Click return value data.
Definition: usbmux.h:113
@ USBMUX_ERROR
Definition: usbmux.h:115
@ USBMUX_OK
Definition: usbmux.h:114