1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg/tinyusb: add tinyusb_hw_defaults.h for platform specific defaults

This commit is contained in:
Gunar Schorcht 2022-09-30 09:38:58 +02:00
parent 3367b106bb
commit 9cf0119233
4 changed files with 151 additions and 16 deletions

View File

@ -34,22 +34,6 @@
#include "cfg_timer_tim5.h"
#include "cfg_usb_otg_hs_fs.h"
#ifdef MODULE_TINYUSB
/**
* @brief tinyUSB device stack uses the USB OTG HS port on this board
*/
#ifndef TINYUSB_TUD_RHPORT
#define TINYUSB_TUD_RHPORT 1
#endif /* TINYUSB_TUD_RHPORT */
/**
* @brief tinyUSB host stack uses the USB OTG HS port on this board
*/
#ifndef TINYUSB_TUH_RHPORT
#define TINYUSB_TUH_RHPORT 1
#endif /* TINYUSB_TUH_RHPORT */
#endif /* MODULE_TINYUSB */
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -0,0 +1,99 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @ingroup pkg_tinyusb
* @ingroup cpu_stm32
* @{
*
* @file
* @brief STM32 specific default configurations for tinyUSB
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/
#ifndef TINYUSB_HW_DEFAULTS_H
#define TINYUSB_HW_DEFAULTS_H
#include "periph_conf.h"
#if !DOXYGEN
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Definition of ports used by tinyUSB host and device stack
*
* The tinyUSB device driver used for the STM32 USB-OTG controller supposes
* that the USB-OTG-FS port is port 0 and the USB-OTG-HS port is port 1.
* Therefore, the following default definitions can be used:
*
* - If both USB OTG FS and USB OTG HS ports are used, the device stack uses
* port 0 and the host stack uses port 1.
* - If only USB OTG HS is used, both the device and the host stack use port 1.
* - In all other cases, both the device and the host stack use port 0.
* This also applies if only the USB FS controller is used.
*
* @{
*/
#if defined(DWC2_USB_OTG_HS_ENABLED) && defined(DWC2_USB_OTG_FS_ENABLED)
#ifndef TINYUSB_TUD_RHPORT
#define TINYUSB_TUD_RHPORT 0
#endif
#ifndef TINYUSB_TUH_RHPORT
#define TINYUSB_TUH_RHPORT 1
#endif
#elif defined(DWC2_USB_OTG_HS_ENABLED)
#ifndef TINYUSB_TUD_RHPORT
#define TINYUSB_TUD_RHPORT 1
#endif
#ifndef TINYUSB_TUH_RHPORT
#define TINYUSB_TUH_RHPORT 1
#endif
#else
#ifndef TINYUSB_TUD_RHPORT
#define TINYUSB_TUD_RHPORT 0
#endif
#ifndef TINYUSB_TUH_RHPORT
#define TINYUSB_TUH_RHPORT 0
#endif
#endif
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* !DOXYGEN */
#endif /* TINYUSB_HW_DEFAULTS_H */
/** @} */

View File

@ -20,6 +20,7 @@
#define TINYUSB_H
#include "periph_conf.h"
#include "tinyusb_hw_defaults.h"
#ifndef TINYUSB_THREAD_STACKSIZE_MAIN
/** Stack size used for the tinyUSB thread */

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @ingroup pkg_tinyusb
* @{
*
* @file
* @brief Hardware specific default configurations for tinyUSB
*
* The platform or the board can define a file `tinyusb_hw_defaults.h`
* to define default values for tinyUSB such as `TINYUSB_TUD_RHORT`
* or `TINYUSB_TUH_RHPORT` according to the given hardware. In case
* the platform or board does not define such a file, this dummy file
* is used instead.
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/
#ifndef TINYUSB_HW_DEFAULTS_H
#define TINYUSB_HW_DEFAULTS_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* TINYUSB_HW_DEFAULTS_H */
/** @} */