Skip to content

Commit 3fae073

Browse files
committed
move tusb_config for each ports into library to make it more portable
1 parent 39d6187 commit 3fae073

File tree

7 files changed

+320
-0
lines changed

7 files changed

+320
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018, hathach for Adafruit
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+
#ifndef _TUSB_CONFIG_NRF_H_
26+
#define _TUSB_CONFIG_NRF_H_
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
//--------------------------------------------------------------------
33+
// COMMON CONFIGURATION
34+
//--------------------------------------------------------------------
35+
#define CFG_TUSB_MCU OPT_MCU_NRF5X
36+
37+
#ifdef USE_TINYUSB
38+
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
39+
#else
40+
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE
41+
#endif
42+
43+
#define CFG_TUSB_OS OPT_OS_FREERTOS
44+
#define CFG_TUSB_MEM_SECTION
45+
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
46+
47+
#ifndef CFG_TUSB_DEBUG
48+
#define CFG_TUSB_DEBUG 0
49+
#endif
50+
51+
//--------------------------------------------------------------------
52+
// DEVICE CONFIGURATION
53+
//--------------------------------------------------------------------
54+
55+
#define CFG_TUD_ENDOINT0_SIZE 64
56+
57+
//------------- CLASS -------------//
58+
#define CFG_TUD_CDC 1
59+
#define CFG_TUD_MSC 1
60+
#define CFG_TUD_HID 1
61+
#define CFG_TUD_MIDI 1
62+
#define CFG_TUD_VENDOR 1
63+
64+
// CDC FIFO size of TX and RX
65+
#define CFG_TUD_CDC_RX_BUFSIZE 256
66+
#define CFG_TUD_CDC_TX_BUFSIZE 256
67+
68+
// MSC Buffer size of Device Mass storage
69+
#define CFG_TUD_MSC_BUFSIZE 512
70+
71+
// HID buffer size Should be sufficient to hold ID (if any) + Data
72+
#define CFG_TUD_HID_BUFSIZE 64
73+
74+
// MIDI FIFO size of TX and RX
75+
#define CFG_TUD_MIDI_RX_BUFSIZE 128
76+
#define CFG_TUD_MIDI_TX_BUFSIZE 128
77+
78+
// Vendor FIFO size of TX and RX
79+
#ifndef CFG_TUD_VENDOR_RX_BUFSIZE
80+
#define CFG_TUD_VENDOR_RX_BUFSIZE 64
81+
#endif
82+
#ifndef CFG_TUD_VENDOR_TX_BUFSIZE
83+
#define CFG_TUD_VENDOR_TX_BUFSIZE 64
84+
#endif
85+
86+
#ifdef __cplusplus
87+
}
88+
#endif
89+
90+
#endif /* _TUSB_CONFIG_NRF_H_ */
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2018, hathach for Adafruit
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+
#ifndef _TUSB_CONFIG_RP2040_H_
26+
#define _TUSB_CONFIG_RP2040_H_
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
//--------------------------------------------------------------------
33+
// COMMON CONFIGURATION
34+
//--------------------------------------------------------------------
35+
#ifdef USE_TINYUSB
36+
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
37+
#else
38+
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE
39+
#endif
40+
41+
#ifndef CFG_TUSB_MCU
42+
#define CFG_TUSB_MCU OPT_MCU_RP2040
43+
#endif
44+
#define CFG_TUSB_OS OPT_OS_PICO
45+
46+
#define CFG_TUSB_DEBUG 0
47+
//#if CFG_TUSB_DEBUG
48+
// #define tu_printf serial1_printf
49+
// extern int serial1_printf(const char *__restrict __format, ...);
50+
//#endif
51+
52+
#define CFG_TUSB_MEM_SECTION
53+
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
54+
55+
//--------------------------------------------------------------------
56+
// DEVICE CONFIGURATION
57+
//--------------------------------------------------------------------
58+
59+
#define CFG_TUD_ENDOINT0_SIZE 64
60+
61+
//------------- CLASS -------------//
62+
#define CFG_TUD_CDC 1
63+
#define CFG_TUD_MSC 1
64+
#define CFG_TUD_HID 1
65+
#define CFG_TUD_MIDI 1
66+
#define CFG_TUD_VENDOR 1
67+
68+
// CDC FIFO size of TX and RX
69+
#define CFG_TUD_CDC_RX_BUFSIZE 256
70+
#define CFG_TUD_CDC_TX_BUFSIZE 256
71+
72+
// MSC Buffer size of Device Mass storage
73+
#define CFG_TUD_MSC_BUFSIZE 512
74+
75+
// HID buffer size Should be sufficient to hold ID (if any) + Data
76+
#define CFG_TUD_HID_BUFSIZE 64
77+
78+
// MIDI FIFO size of TX and RX
79+
#define CFG_TUD_MIDI_RX_BUFSIZE 128
80+
#define CFG_TUD_MIDI_TX_BUFSIZE 128
81+
82+
// Vendor FIFO size of TX and RX
83+
#define CFG_TUD_VENDOR_RX_BUFSIZE 64
84+
#define CFG_TUD_VENDOR_TX_BUFSIZE 64
85+
86+
#ifdef __cplusplus
87+
}
88+
#endif
89+
90+
#endif /* _TUSB_CONFIG_RP2040_H_ */
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018, hathach for Adafruit
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+
#ifndef _TUSB_CONFIG_SAMD_H_
26+
#define _TUSB_CONFIG_SAMD_H_
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
//--------------------------------------------------------------------
33+
// COMMON CONFIGURATION
34+
//--------------------------------------------------------------------
35+
#ifdef __SAMD51__
36+
#define CFG_TUSB_MCU OPT_MCU_SAMD51
37+
#else
38+
#define CFG_TUSB_MCU OPT_MCU_SAMD21
39+
#endif
40+
41+
#ifdef USE_TINYUSB
42+
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
43+
#else
44+
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE
45+
#endif
46+
47+
#define CFG_TUSB_OS OPT_OS_NONE
48+
49+
#define CFG_TUSB_DEBUG 2
50+
#if CFG_TUSB_DEBUG
51+
#define CFG_TUSB_DEBUG_PRINTF serial1_printf
52+
#endif
53+
54+
#define CFG_TUSB_MEM_SECTION
55+
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
56+
57+
//--------------------------------------------------------------------
58+
// DEVICE CONFIGURATION
59+
//--------------------------------------------------------------------
60+
61+
#define CFG_TUD_ENDOINT0_SIZE 64
62+
63+
//------------- CLASS -------------//
64+
#define CFG_TUD_CDC 1
65+
#define CFG_TUD_MSC 1
66+
#define CFG_TUD_HID 1
67+
#define CFG_TUD_MIDI 1
68+
#define CFG_TUD_VENDOR 1
69+
70+
// CDC FIFO size of TX and RX
71+
#define CFG_TUD_CDC_RX_BUFSIZE 256
72+
#define CFG_TUD_CDC_TX_BUFSIZE 256
73+
74+
// MSC Buffer size of Device Mass storage
75+
#define CFG_TUD_MSC_BUFSIZE 512
76+
77+
// HID buffer size Should be sufficient to hold ID (if any) + Data
78+
#define CFG_TUD_HID_BUFSIZE 64
79+
80+
// MIDI FIFO size of TX and RX
81+
#define CFG_TUD_MIDI_RX_BUFSIZE 128
82+
#define CFG_TUD_MIDI_TX_BUFSIZE 128
83+
84+
// Vendor FIFO size of TX and RX
85+
#define CFG_TUD_VENDOR_RX_BUFSIZE 64
86+
#define CFG_TUD_VENDOR_TX_BUFSIZE 64
87+
88+
#ifdef __cplusplus
89+
}
90+
#endif
91+
92+
#endif /* _TUSB_CONFIG_SAMD_H_ */

src/tusb_config.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018, hathach for Adafruit
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+
#ifndef _TUSB_CONFIG_ARDUINO_H_
26+
#define _TUSB_CONFIG_ARDUINO_H_
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
#if defined(ARDUINO_ARCH_SAMD)
33+
#include "arduino/ports/samd/tusb_config_samd.h"
34+
#endif
35+
36+
#if defined(ARDUINO_ARCH_NRF52)
37+
#include "arduino/ports/nrf/tusb_config_nrf.h"
38+
#endif
39+
40+
#if defined(ARDUINO_ARCH_RP2040)
41+
#include "arduino/ports/rp2040/tusb_config_rp2040.h"
42+
#endif
43+
44+
#ifdef __cplusplus
45+
}
46+
#endif
47+
48+
#endif /* _TUSB_CONFIG_ARDUINO_H_ */

0 commit comments

Comments
 (0)