Skip to content

Commit ae364b1

Browse files
authored
Merge pull request #2390 from hathach/max3421e-support-rp2040
support max3421e for rp2040
2 parents 804f671 + 551e47a commit ae364b1

File tree

16 files changed

+358
-215
lines changed

16 files changed

+358
-215
lines changed

.idea/cmake.xml

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/host/bare_api/src/tusb_config.h

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,8 @@
3030
extern "C" {
3131
#endif
3232

33-
//--------------------------------------------------------------------+
34-
// Board Specific Configuration
35-
//--------------------------------------------------------------------+
36-
37-
#if CFG_TUSB_MCU == OPT_MCU_RP2040
38-
// change to 1 if using pico-pio-usb as host controller for raspberry rp2040
39-
#define CFG_TUH_RPI_PIO_USB 0
40-
#define BOARD_TUH_RHPORT CFG_TUH_RPI_PIO_USB
41-
#endif
42-
43-
// RHPort number used for host can be defined by board.mk, default to port 0
44-
#ifndef BOARD_TUH_RHPORT
45-
#define BOARD_TUH_RHPORT 0
46-
#endif
47-
48-
// RHPort max operational speed can defined by board.mk
49-
#ifndef BOARD_TUH_MAX_SPEED
50-
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
51-
#endif
52-
5333
//--------------------------------------------------------------------
54-
// COMMON CONFIGURATION
34+
// Common Configuration
5535
//--------------------------------------------------------------------
5636

5737
// defined by compiler flags for flexibility
@@ -67,12 +47,6 @@
6747
#define CFG_TUSB_DEBUG 0
6848
#endif
6949

70-
// Enable Host stack
71-
#define CFG_TUH_ENABLED 1
72-
73-
// Default is max speed that hardware controller could support with on-chip PHY
74-
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
75-
7650
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
7751
* Tinyusb use follows macros to declare transferring memory so that they can be put
7852
* into those specific section.
@@ -85,11 +59,43 @@
8559
#endif
8660

8761
#ifndef CFG_TUH_MEM_ALIGN
88-
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
62+
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
63+
#endif
64+
65+
//--------------------------------------------------------------------
66+
// Host Configuration
67+
//--------------------------------------------------------------------
68+
69+
// Enable Host stack
70+
#define CFG_TUH_ENABLED 1
71+
72+
#if CFG_TUSB_MCU == OPT_MCU_RP2040
73+
// #define CFG_TUH_RPI_PIO_USB 1 // use pio-usb as host controller
74+
// #define CFG_TUH_RPI_PIO_USB 1 // use max3421 as host controller
75+
76+
// host roothub port is 1 if using either pio-usb or max3421
77+
#if (defined(CFG_TUH_RPI_PIO_USB) && CFG_TUH_RPI_PIO_USB) || (defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421)
78+
#define BOARD_TUH_RHPORT 1
79+
#endif
80+
#endif
81+
82+
// Default is max speed that hardware controller could support with on-chip PHY
83+
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
84+
85+
//------------------------- Board Specific --------------------------
86+
87+
// RHPort number used for host can be defined by board.mk, default to port 0
88+
#ifndef BOARD_TUH_RHPORT
89+
#define BOARD_TUH_RHPORT 0
90+
#endif
91+
92+
// RHPort max operational speed can defined by board.mk
93+
#ifndef BOARD_TUH_MAX_SPEED
94+
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
8995
#endif
9096

9197
//--------------------------------------------------------------------
92-
// CONFIGURATION
98+
// Driver Configuration
9399
//--------------------------------------------------------------------
94100

95101
// Size of buffer to hold descriptors and other data used for enumeration

examples/host/cdc_msc_hid/src/tusb_config.h

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,8 @@
3030
extern "C" {
3131
#endif
3232

33-
//--------------------------------------------------------------------+
34-
// Board Specific Configuration
35-
//--------------------------------------------------------------------+
36-
37-
#if CFG_TUSB_MCU == OPT_MCU_RP2040
38-
// change to 1 if using pico-pio-usb as host controller for raspberry rp2040
39-
#define CFG_TUH_RPI_PIO_USB 0
40-
#define BOARD_TUH_RHPORT CFG_TUH_RPI_PIO_USB
41-
#endif
42-
43-
// RHPort number used for host can be defined by board.mk, default to port 0
44-
#ifndef BOARD_TUH_RHPORT
45-
#define BOARD_TUH_RHPORT 0
46-
#endif
47-
48-
// RHPort max operational speed can defined by board.mk
49-
#ifndef BOARD_TUH_MAX_SPEED
50-
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
51-
#endif
52-
5333
//--------------------------------------------------------------------
54-
// COMMON CONFIGURATION
34+
// Common Configuration
5535
//--------------------------------------------------------------------
5636

5737
// defined by compiler flags for flexibility
@@ -67,12 +47,6 @@
6747
#define CFG_TUSB_DEBUG 0
6848
#endif
6949

70-
// Enable Host stack
71-
#define CFG_TUH_ENABLED 1
72-
73-
// Default is max speed that hardware controller could support with on-chip PHY
74-
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
75-
7650
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
7751
* Tinyusb use follows macros to declare transferring memory so that they can be put
7852
* into those specific section.
@@ -85,11 +59,43 @@
8559
#endif
8660

8761
#ifndef CFG_TUH_MEM_ALIGN
88-
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
62+
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
63+
#endif
64+
65+
//--------------------------------------------------------------------
66+
// Host Configuration
67+
//--------------------------------------------------------------------
68+
69+
// Enable Host stack
70+
#define CFG_TUH_ENABLED 1
71+
72+
#if CFG_TUSB_MCU == OPT_MCU_RP2040
73+
// #define CFG_TUH_RPI_PIO_USB 1 // use pio-usb as host controller
74+
// #define CFG_TUH_RPI_PIO_USB 1 // use max3421 as host controller
75+
76+
// host roothub port is 1 if using either pio-usb or max3421
77+
#if (defined(CFG_TUH_RPI_PIO_USB) && CFG_TUH_RPI_PIO_USB) || (defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421)
78+
#define BOARD_TUH_RHPORT 1
79+
#endif
80+
#endif
81+
82+
// Default is max speed that hardware controller could support with on-chip PHY
83+
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
84+
85+
//------------------------- Board Specific --------------------------
86+
87+
// RHPort number used for host can be defined by board.mk, default to port 0
88+
#ifndef BOARD_TUH_RHPORT
89+
#define BOARD_TUH_RHPORT 0
90+
#endif
91+
92+
// RHPort max operational speed can defined by board.mk
93+
#ifndef BOARD_TUH_MAX_SPEED
94+
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
8995
#endif
9096

9197
//--------------------------------------------------------------------
92-
// CONFIGURATION
98+
// Driver Configuration
9399
//--------------------------------------------------------------------
94100

95101
// Size of buffer to hold descriptors and other data used for enumeration

examples/host/cdc_msc_hid_freertos/src/tusb_config.h

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,8 @@
3030
extern "C" {
3131
#endif
3232

33-
//--------------------------------------------------------------------+
34-
// Board Specific Configuration
35-
//--------------------------------------------------------------------+
36-
37-
#if CFG_TUSB_MCU == OPT_MCU_RP2040
38-
// change to 1 if using pico-pio-usb as host controller for raspberry rp2040
39-
#define CFG_TUH_RPI_PIO_USB 0
40-
#define BOARD_TUH_RHPORT CFG_TUH_RPI_PIO_USB
41-
#endif
42-
43-
// RHPort number used for host can be defined by board.mk, default to port 0
44-
#ifndef BOARD_TUH_RHPORT
45-
#define BOARD_TUH_RHPORT 0
46-
#endif
47-
48-
// RHPort max operational speed can defined by board.mk
49-
#ifndef BOARD_TUH_MAX_SPEED
50-
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
51-
#endif
52-
5333
//--------------------------------------------------------------------
54-
// COMMON CONFIGURATION
34+
// Common Configuration
5535
//--------------------------------------------------------------------
5636

5737
// defined by compiler flags for flexibility
@@ -72,12 +52,6 @@
7252
#define CFG_TUSB_DEBUG 0
7353
#endif
7454

75-
// Enable Host stack
76-
#define CFG_TUH_ENABLED 1
77-
78-
// Default is max speed that hardware controller could support with on-chip PHY
79-
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
80-
8155
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
8256
* Tinyusb use follows macros to declare transferring memory so that they can be put
8357
* into those specific section.
@@ -90,11 +64,43 @@
9064
#endif
9165

9266
#ifndef CFG_TUH_MEM_ALIGN
93-
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
67+
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
68+
#endif
69+
70+
//--------------------------------------------------------------------
71+
// Host Configuration
72+
//--------------------------------------------------------------------
73+
74+
// Enable Host stack
75+
#define CFG_TUH_ENABLED 1
76+
77+
#if CFG_TUSB_MCU == OPT_MCU_RP2040
78+
// #define CFG_TUH_RPI_PIO_USB 1 // use pio-usb as host controller
79+
// #define CFG_TUH_RPI_PIO_USB 1 // use max3421 as host controller
80+
81+
// host roothub port is 1 if using either pio-usb or max3421
82+
#if (defined(CFG_TUH_RPI_PIO_USB) && CFG_TUH_RPI_PIO_USB) || (defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421)
83+
#define BOARD_TUH_RHPORT 1
84+
#endif
85+
#endif
86+
87+
// Default is max speed that hardware controller could support with on-chip PHY
88+
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
89+
90+
//------------------------- Board Specific --------------------------
91+
92+
// RHPort number used for host can be defined by board.mk, default to port 0
93+
#ifndef BOARD_TUH_RHPORT
94+
#define BOARD_TUH_RHPORT 0
95+
#endif
96+
97+
// RHPort max operational speed can defined by board.mk
98+
#ifndef BOARD_TUH_MAX_SPEED
99+
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
94100
#endif
95101

96102
//--------------------------------------------------------------------
97-
// CONFIGURATION
103+
// Driver Configuration
98104
//--------------------------------------------------------------------
99105

100106
// Size of buffer to hold descriptors and other data used for enumeration

examples/host/hid_controller/src/tusb_config.h

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,8 @@
3030
extern "C" {
3131
#endif
3232

33-
//--------------------------------------------------------------------+
34-
// Board Specific Configuration
35-
//--------------------------------------------------------------------+
36-
37-
#if CFG_TUSB_MCU == OPT_MCU_RP2040
38-
// change to 1 if using pico-pio-usb as host controller for raspberry rp2040
39-
#define CFG_TUH_RPI_PIO_USB 0
40-
#define BOARD_TUH_RHPORT CFG_TUH_RPI_PIO_USB
41-
#endif
42-
43-
// RHPort number used for host can be defined by board.mk, default to port 0
44-
#ifndef BOARD_TUH_RHPORT
45-
#define BOARD_TUH_RHPORT 0
46-
#endif
47-
48-
// RHPort max operational speed can defined by board.mk
49-
#ifndef BOARD_TUH_MAX_SPEED
50-
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
51-
#endif
52-
5333
//--------------------------------------------------------------------
54-
// COMMON CONFIGURATION
34+
// Common Configuration
5535
//--------------------------------------------------------------------
5636

5737
// defined by compiler flags for flexibility
@@ -67,12 +47,6 @@
6747
#define CFG_TUSB_DEBUG 0
6848
#endif
6949

70-
// Enable Host stack
71-
#define CFG_TUH_ENABLED 1
72-
73-
// Default is max speed that hardware controller could support with on-chip PHY
74-
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
75-
7650
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
7751
* Tinyusb use follows macros to declare transferring memory so that they can be put
7852
* into those specific section.
@@ -85,11 +59,43 @@
8559
#endif
8660

8761
#ifndef CFG_TUH_MEM_ALIGN
88-
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
62+
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
63+
#endif
64+
65+
//--------------------------------------------------------------------
66+
// Host Configuration
67+
//--------------------------------------------------------------------
68+
69+
// Enable Host stack
70+
#define CFG_TUH_ENABLED 1
71+
72+
#if CFG_TUSB_MCU == OPT_MCU_RP2040
73+
// #define CFG_TUH_RPI_PIO_USB 1 // use pio-usb as host controller
74+
// #define CFG_TUH_RPI_PIO_USB 1 // use max3421 as host controller
75+
76+
// host roothub port is 1 if using either pio-usb or max3421
77+
#if (defined(CFG_TUH_RPI_PIO_USB) && CFG_TUH_RPI_PIO_USB) || (defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421)
78+
#define BOARD_TUH_RHPORT 1
79+
#endif
80+
#endif
81+
82+
// Default is max speed that hardware controller could support with on-chip PHY
83+
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
84+
85+
//------------------------- Board Specific --------------------------
86+
87+
// RHPort number used for host can be defined by board.mk, default to port 0
88+
#ifndef BOARD_TUH_RHPORT
89+
#define BOARD_TUH_RHPORT 0
90+
#endif
91+
92+
// RHPort max operational speed can defined by board.mk
93+
#ifndef BOARD_TUH_MAX_SPEED
94+
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
8995
#endif
9096

9197
//--------------------------------------------------------------------
92-
// CONFIGURATION
98+
// Driver Configuration
9399
//--------------------------------------------------------------------
94100

95101
// Size of buffer to hold descriptors and other data used for enumeration

0 commit comments

Comments
 (0)