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
32 extern "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  // 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  // usbmux_map // usbmux
99 
104 typedef struct
105 {
106  digital_out_t oe;
107  digital_out_t sel;
109 } usbmux_t;
110 
115 typedef struct
116 {
117  pin_name_t oe;
118  pin_name_t sel;
120 } usbmux_cfg_t;
121 
126 typedef enum
127 {
129  USBMUX_ERROR = -1
130 
132 
149 
163 err_t usbmux_init ( usbmux_t *ctx, usbmux_cfg_t *cfg );
164 
176 
187 void usbmux_set_oe_pin ( usbmux_t *ctx, uint8_t pin_state );
188 
199 void usbmux_set_sel_pin ( usbmux_t *ctx, uint8_t pin_state );
200 
211 
222 
233 void usbmux_set_output ( usbmux_t *ctx, uint8_t out_sel );
234 
235 #ifdef __cplusplus
236 }
237 #endif
238 #endif // USBMUX_H
239  // usbmux
241 
242 // ------------------------------------------------------------------------ END
usbmux_t::oe
digital_out_t oe
Definition: usbmux.h:106
usbmux_disable_output
void usbmux_disable_output(usbmux_t *ctx)
USB MUX disable output function.
usbmux_return_value_t
usbmux_return_value_t
USB MUX Click return value data.
Definition: usbmux.h:127
usbmux_init
err_t usbmux_init(usbmux_t *ctx, usbmux_cfg_t *cfg)
USB MUX initialization function.
usbmux_set_oe_pin
void usbmux_set_oe_pin(usbmux_t *ctx, uint8_t pin_state)
USB MUX set OE pin output function.
usbmux_cfg_t
USB MUX Click configuration object.
Definition: usbmux.h:116
usbmux_t
USB MUX Click context object.
Definition: usbmux.h:105
usbmux_set_output
void usbmux_set_output(usbmux_t *ctx, uint8_t out_sel)
USB MUX select output function.
USBMUX_OK
@ USBMUX_OK
Definition: usbmux.h:128
usbmux_t::sel
digital_out_t sel
Definition: usbmux.h:107
usbmux_default_cfg
void usbmux_default_cfg(usbmux_t *ctx)
USB MUX default configuration function.
USBMUX_ERROR
@ USBMUX_ERROR
Definition: usbmux.h:129
usbmux_set_sel_pin
void usbmux_set_sel_pin(usbmux_t *ctx, uint8_t pin_state)
USB MUX set SEL pin output function.
usbmux_cfg_setup
void usbmux_cfg_setup(usbmux_cfg_t *cfg)
USB MUX configuration object setup function.
usbmux_cfg_t::sel
pin_name_t sel
Definition: usbmux.h:118
usbmux_enable_output
void usbmux_enable_output(usbmux_t *ctx)
USB MUX enable output function.
usbmux_cfg_t::oe
pin_name_t oe
Definition: usbmux.h:117