Loading...
Searching...
No Matches
tinyusb_hw_defaults.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Gunar Schorcht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#pragma once
24
35
36#include "periph_conf.h"
37
38#if !DOXYGEN
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
62#if defined(DWC2_USB_OTG_HS_ENABLED) && defined(DWC2_USB_OTG_FS_ENABLED)
63
64#ifndef TINYUSB_TUD_RHPORT
65#define TINYUSB_TUD_RHPORT 0
66#endif
67
68#ifndef TINYUSB_TUH_RHPORT
69#define TINYUSB_TUH_RHPORT 1
70#endif
71
72#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
73#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_HOST | OPT_MODE_HIGH_SPEED)
74
75#elif defined(DWC2_USB_OTG_HS_ENABLED)
76
77#ifndef TINYUSB_TUD_RHPORT
78#define TINYUSB_TUD_RHPORT 1
79#endif
80
81#ifndef TINYUSB_TUH_RHPORT
82#define TINYUSB_TUH_RHPORT 1
83#endif
84
85/*
86 * Only if the module `periph_usbdev_hs_utmi` or `periph_usbdev_hs_ulpi` is
87 * enabled for the HS port, a HS PHY is used and OPT_MODE_HIGH_SPEED must be
88 * set. Otherwise, the built-in on-chip FS PHY is used and
89 * OPT_MODE_DEFAULT_SPEED should be set so tinyUSB can select the correct speed.
90 */
91#if (MODULE_PERIPH_USBDEV_HS_UTMI || MODULE_PERIPH_USBDEV_HS_ULPI)
92#define TINYUSB_OPT_SPEED OPT_MODE_HIGH_SPEED
93#else
94#define TINYUSB_OPT_SPEED OPT_MODE_DEFAULT_SPEED
95#endif
96
97/*
98 * Since tinyUSB does not support host mode for STM32 MCUs yet, only
99 * OPT_MODE_DEVICE is enabled for the port. Once tinyUSB supports the host mode,
100 * OPT_MODE_HOST could be added to CFG_TUSB_RHPORT1_MODE
101 */
102#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | TINYUSB_OPT_SPEED)
103
104#else
105
106#ifndef TINYUSB_TUD_RHPORT
107#define TINYUSB_TUD_RHPORT 0
108#endif
109
110#ifndef TINYUSB_TUH_RHPORT
111#define TINYUSB_TUH_RHPORT 0
112#endif
113
114/*
115 * Since tinyUSB does not support host mode for STM32 MCUs yet, only
116 * OPT_MODE_DEVICE is enabled for the port. Once tinyUSB supports the host mode,
117 * OPT_MODE_HOST could be added to CFG_TUSB_RHPORT0_MODE.
118 */
119#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
120
121#endif
123
124#ifdef USB_HS_PHYC
131#define HSE_VALUE CONFIG_CLOCK_HSE
132#endif
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif /* !DOXYGEN */