BSB Developer Docs
Loading...
Searching...
No Matches
tusb_config.h
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2022 Nathaniel Brough
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 */
25
26#ifndef _TUSB_CONFIG_H_
27#define _TUSB_CONFIG_H_
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <furi.h>
34
35//--------------------------------------------------------------------+
36// Board Specific Configuration
37//--------------------------------------------------------------------+
38
39// RHPort number used for device can be defined by board.mk, default to port 0
40#ifndef BOARD_TUD_RHPORT
41#define BOARD_TUD_RHPORT 0
42#endif
43
44// RHPort max operational speed can defined by board.mk
45#ifndef BOARD_TUD_MAX_SPEED
46#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
47#endif
48
49//--------------------------------------------------------------------
50// Common Configuration
51//--------------------------------------------------------------------
52
53// defined by compiler flags for flexibility
54#ifndef CFG_TUSB_MCU
55#define CFG_TUSB_MCU OPT_MCU_STM32U5
56#endif
57
58#define CFG_TUSB_OS OPT_OS_CUSTOM
59
60// Enable Device stack
61#define CFG_TUD_ENABLED 1
62
63// Default is max speed that hardware controller could support with on-chip PHY
64#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
65
66/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
67 * Tinyusb use follows macros to declare transferring memory so that they can be put
68 * into those specific section.
69 * e.g
70 * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
71 * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
72 */
73#ifndef CFG_TUSB_MEM_SECTION
74#define CFG_TUSB_MEM_SECTION
75#endif
76
77#ifndef CFG_TUSB_MEM_ALIGN
78#define CFG_TUSB_MEM_ALIGN __attribute__((aligned(4)))
79#endif
80
81//--------------------------------------------------------------------
82// DEVICE CONFIGURATION
83//--------------------------------------------------------------------
84
85#ifndef CFG_TUD_ENDPOINT0_SIZE
86#define CFG_TUD_ENDPOINT0_SIZE 64
87#endif
88
89#define CFG_TUD_DWC2_DMA_ENABLE 1
90
91#define CFG_TUD_NCM_OUT_NTB_N 1
92#define CFG_TUD_NCM_IN_NTB_N 1
93
94#define CFG_TUD_NCM_IN_MAX_DATAGRAMS_PER_NTB 8
95#define CFG_TUD_NCM_OUT_MAX_DATAGRAMS_PER_NTB 8
96
97#define CFG_TUD_NCM_OUT_NTB_MAX_SIZE 2048 //3020
98#define CFG_TUD_NCM_IN_NTB_MAX_SIZE 2048
99
100//------------- CLASS -------------//
101#define CFG_TUD_CDC 0
102#define CFG_TUD_MSC 0
103#define CFG_TUD_HID 0
104#define CFG_TUD_MIDI 0
105#define CFG_TUD_VENDOR 0
106#define CFG_TUD_NCM 1
107#define CFG_TUD_ECM_RNDIS 0
108
109#define CFG_TUD_TASK_QUEUE_SZ 32
110
111#define CFG_TUSB_DEBUG 1
112#define CFG_TUD_NCM_LOG_LEVEL 2
113
114#define CFG_TUSB_DEBUG_PRINTF usb_srv_log
115
116#define TU_ASSERT_1(_cond) furi_assert(_cond)
117#define TU_ASSERT_2(_cond, _ret) furi_assert(_cond)
118#define TU_ASSERT(...) TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2, TU_ASSERT_1, _dummy)(__VA_ARGS__)
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* _TUSB_CONFIG_H_ */