SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
audio_mic/tusb_config.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2019 Ha Thach (tinyusb.org)
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//--------------------------------------------------------------------+
34// STK Specific Configuration
35//--------------------------------------------------------------------+
36
37// Use C++ OSAL interface (it implies compilation of osal_stk.cpp)
38#define CFG_TUH_OSAL_STK_USE_CPP 1
39
40//--------------------------------------------------------------------+
41// Board Specific Configuration
42//--------------------------------------------------------------------+
43
44// RHPort number used for device can be defined by board.mk, default to port 0
45#ifndef BOARD_TUD_RHPORT
46#define BOARD_TUD_RHPORT 0
47#endif
48
49// RHPort max operational speed can defined by board.mk
50#ifndef BOARD_TUD_MAX_SPEED
51#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
52#endif
53
54//--------------------------------------------------------------------
55// COMMON CONFIGURATION
56//--------------------------------------------------------------------
57
58// defined by compiler flags for flexibility
59#ifndef CFG_TUSB_MCU
60//#error CFG_TUSB_MCU must be defined
61#define CFG_TUSB_MCU OPT_MCU_STM32F4
62#endif
63
64// This examples use FreeRTOS
65#ifndef CFG_TUSB_OS
66#define CFG_TUSB_OS OPT_OS_CUSTOM
67#endif
68
69// Espressif IDF requires "freertos/" prefix in include path
70#ifdef ESP_PLATFORM
71#define CFG_TUSB_OS_INC_PATH freertos/
72#endif
73
74#ifndef CFG_TUSB_DEBUG
75#define CFG_TUSB_DEBUG 0
76#endif
77
78// Enable Device stack
79#define CFG_TUD_ENABLED 1
80
81// Default is max speed that hardware controller could support with on-chip PHY
82#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
83
84// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
85// #define CFG_TUSB_DEBUG 0
86
87/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
88 * Tinyusb use follows macros to declare transferring memory so that they can be put
89 * into those specific section.
90 * e.g
91 * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
92 * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
93 */
94#ifndef CFG_TUSB_MEM_SECTION
95#define CFG_TUSB_MEM_SECTION
96#endif
97
98#ifndef CFG_TUSB_MEM_ALIGN
99#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
100#endif
101
102//--------------------------------------------------------------------
103// DEVICE CONFIGURATION
104//--------------------------------------------------------------------
105
106#ifndef CFG_TUD_ENDPOINT0_SIZE
107#define CFG_TUD_ENDPOINT0_SIZE 64
108#endif
109
110//------------- CLASS -------------//
111#define CFG_TUD_AUDIO 1
112#define CFG_TUD_CDC 0
113#define CFG_TUD_MSC 0
114#define CFG_TUD_HID 0
115#define CFG_TUD_MIDI 0
116#define CFG_TUD_VENDOR 0
117
118//--------------------------------------------------------------------
119// AUDIO CLASS DRIVER CONFIGURATION
120//--------------------------------------------------------------------
121
122// Have a look into audio_device.h for all configurations
123#define CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE 48000
124
125#define CFG_TUD_AUDIO_ENABLE_EP_IN 1
126#define CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX 2 // Driver gets this info from the descriptors - we define it here to use it to setup the descriptors and to do calculations with it below
127#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX 1 // Driver gets this info from the descriptors - we define it here to use it to setup the descriptors and to do calculations with it below - be aware: for different number of channels you need another descriptor!
128#define CFG_TUD_AUDIO_EP_SZ_IN TUD_AUDIO_EP_SIZE(TUD_OPT_HIGH_SPEED, CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE, CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX)
129#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX CFG_TUD_AUDIO_EP_SZ_IN
130#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ (TUD_OPT_HIGH_SPEED ? 32 : 4) * CFG_TUD_AUDIO_EP_SZ_IN // Example write FIFO every 1ms, so it should be 8 times larger for HS device
131
132#ifdef __cplusplus
133}
134#endif
135
136#endif /* TUSB_CONFIG_H_ */