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 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
63 #define USBMUX_PIN_STATE_LOW 0x00
64 #define USBMUX_PIN_STATE_HIGH 0x01
65 
70 #define USBMUX_USB1_SELECT 0x00
71 #define USBMUX_USB2_SELECT 0x01
72  // usbmux_set
74 
89 #define USBMUX_MAP_MIKROBUS( cfg, mikrobus ) \
90  cfg.oe = MIKROBUS( mikrobus, MIKROBUS_RST ); \
91  cfg.sel = MIKROBUS( mikrobus, MIKROBUS_PWM )
92  // usbmux_map // usbmux
95 
100 typedef struct
101 {
102  digital_out_t oe;
103  digital_out_t sel;
105 } usbmux_t;
106 
111 typedef struct
112 {
113  pin_name_t oe;
114  pin_name_t sel;
116 } usbmux_cfg_t;
117 
122 typedef enum
123 {
125  USBMUX_ERROR = -1
126 
128 
145 
159 err_t usbmux_init ( usbmux_t *ctx, usbmux_cfg_t *cfg );
160 
172 
183 void usbmux_set_oe_pin ( usbmux_t *ctx, uint8_t pin_state );
184 
195 void usbmux_set_sel_pin ( usbmux_t *ctx, uint8_t pin_state );
196 
207 
218 
229 void usbmux_set_output ( usbmux_t *ctx, uint8_t out_sel );
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 #endif // USBMUX_H
235  // usbmux
237 
238 // ------------------------------------------------------------------------ END
usbmux_t::oe
digital_out_t oe
Definition: usbmux.h:102
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:123
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:112
usbmux_t
USB MUX Click context object.
Definition: usbmux.h:101
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:124
usbmux_t::sel
digital_out_t sel
Definition: usbmux.h:103
usbmux_default_cfg
void usbmux_default_cfg(usbmux_t *ctx)
USB MUX default configuration function.
USBMUX_ERROR
@ USBMUX_ERROR
Definition: usbmux.h:125
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:114
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:113