Skip to content

Commit 1cfc88d

Browse files
authored
Merge pull request #2994 from hathach/enhance-hub
Enhance hub driver
2 parents 9d2fd6c + 61aab7a commit 1cfc88d

File tree

21 files changed

+808
-426
lines changed

21 files changed

+808
-426
lines changed

hw/bsp/family_support.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ function(family_flash_openocd TARGET)
476476
set(OPENOCD_OPTION2 "")
477477
endif ()
478478

479+
if (DEFINED OPENOCD_SERIAL)
480+
set(OPENOCD_OPTION "-c \"adapter serial ${OPENOCD_SERIAL}\" ${OPENOCD_OPTION}")
481+
endif ()
482+
479483
separate_arguments(OPTION_LIST UNIX_COMMAND ${OPENOCD_OPTION})
480484
separate_arguments(OPTION_LIST2 UNIX_COMMAND ${OPENOCD_OPTION2})
481485

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set(PICO_PLATFORM rp2040)
2+
set(PICO_BOARD adafruit_feather_rp2040_usb_host)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2025 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+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef TUSB_BOARD_H
28+
#define TUSB_BOARD_H
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
// UART and LED are already defined in pico-sdk board
35+
36+
//--------------------------------------------------------------------+
37+
// PIO_USB
38+
//--------------------------------------------------------------------+
39+
40+
#define PICO_DEFAULT_PIO_USB_DP_PIN 16
41+
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 18
42+
#define PICO_DEFAULT_PIO_USB_VBUSEN_STATE 1
43+
44+
//--------------------------------------------------------------------
45+
// USB Host MAX3421E
46+
//--------------------------------------------------------------------
47+
48+
#ifdef PICO_DEFAULT_SPI
49+
#define MAX3421_SPI PICO_DEFAULT_SPI // sdk v2
50+
#else
51+
#define MAX3421_SPI PICO_DEFAULT_SPI_INSTANCE // sdk v1
52+
#endif
53+
54+
#define MAX3421_SCK_PIN PICO_DEFAULT_SPI_SCK_PIN
55+
#define MAX3421_MOSI_PIN PICO_DEFAULT_SPI_TX_PIN
56+
#define MAX3421_MISO_PIN PICO_DEFAULT_SPI_RX_PIN
57+
#define MAX3421_CS_PIN 10
58+
#define MAX3421_INTR_PIN 9
59+
60+
#ifdef __cplusplus
61+
}
62+
#endif
63+
64+
#endif
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2025 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+
* This file is part of the TinyUSB stack.
25+
*/
26+
#ifndef BOARDS_ADAFRUIT_FRUIT_JAM_H
27+
#define BOARDS_ADAFRUIT_FRUIT_JAM_H
28+
29+
// required for board that is not part of pico-sdk
30+
31+
// -----------------------------------------------------
32+
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
33+
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
34+
// -----------------------------------------------------
35+
36+
// pico_cmake_set PICO_PLATFORM=rp2350
37+
38+
// On some samples, the xosc can take longer to stabilize than is usual
39+
#ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER
40+
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
41+
#endif
42+
43+
// For board detection
44+
#define ADAFRUIT_FRUIT_JAM
45+
46+
// --- RP2350 VARIANT ---
47+
#define PICO_RP2350A 0
48+
49+
// --- UART ---
50+
#ifndef PICO_DEFAULT_UART
51+
#define PICO_DEFAULT_UART 1
52+
#endif
53+
#ifndef PICO_DEFAULT_UART_TX_PIN
54+
#define PICO_DEFAULT_UART_TX_PIN 8
55+
#endif
56+
#ifndef PICO_DEFAULT_UART_RX_PIN
57+
#define PICO_DEFAULT_UART_RX_PIN 9
58+
#endif
59+
60+
// --- LED ---
61+
#ifndef PICO_DEFAULT_LED_PIN
62+
#define PICO_DEFAULT_LED_PIN 29
63+
#endif
64+
65+
#ifndef PICO_DEFAULT_WS2812_PIN
66+
#define PICO_DEFAULT_WS2812_PIN 32
67+
#endif
68+
69+
// --- I2C ---
70+
#ifndef PICO_DEFAULT_I2C
71+
#define PICO_DEFAULT_I2C 0
72+
#endif
73+
#ifndef PICO_DEFAULT_I2C_SDA_PIN
74+
#define PICO_DEFAULT_I2C_SDA_PIN 20
75+
#endif
76+
#ifndef PICO_DEFAULT_I2C_SCL_PIN
77+
#define PICO_DEFAULT_I2C_SCL_PIN 21
78+
#endif
79+
80+
// --- SPI ---
81+
#ifndef PICO_DEFAULT_SPI
82+
#define PICO_DEFAULT_SPI 1
83+
#endif
84+
#ifndef PICO_DEFAULT_SPI_SCK_PIN
85+
#define PICO_DEFAULT_SPI_SCK_PIN 30
86+
#endif
87+
#ifndef PICO_DEFAULT_SPI_TX_PIN
88+
#define PICO_DEFAULT_SPI_TX_PIN 31
89+
#endif
90+
#ifndef PICO_DEFAULT_SPI_RX_PIN
91+
#define PICO_DEFAULT_SPI_RX_PIN 28
92+
#endif
93+
94+
// --- FLASH ---
95+
96+
// FruitJam use w25q128 but sdk does not have .s for it, use q080 instead
97+
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
98+
99+
#ifndef PICO_FLASH_SPI_CLKDIV
100+
#define PICO_FLASH_SPI_CLKDIV 2
101+
#endif
102+
103+
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
104+
#ifndef PICO_FLASH_SIZE_BYTES
105+
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
106+
#endif
107+
108+
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
109+
#ifndef PICO_RP2350_A2_SUPPORTED
110+
#define PICO_RP2350_A2_SUPPORTED 1
111+
#endif
112+
113+
#endif
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set(PICO_PLATFORM rp2350-arm-s)
2+
set(PICO_BOARD adafruit_fruit_jam)
3+
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
4+
#set(OPENOCD_SERIAL E6614103E78E8324)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2025 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+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef TUSB_BOARD_H
28+
#define TUSB_BOARD_H
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
// UART and LED are already defined in pico-sdk board
35+
36+
//--------------------------------------------------------------------+
37+
// PIO_USB
38+
//--------------------------------------------------------------------+
39+
// default to pico brain tester
40+
#define PICO_DEFAULT_PIO_USB_DP_PIN 1
41+
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 11
42+
#define PICO_DEFAULT_PIO_USB_VBUSEN_STATE 1
43+
44+
//--------------------------------------------------------------------
45+
// USB Host MAX3421E
46+
//--------------------------------------------------------------------
47+
48+
#ifdef __cplusplus
49+
}
50+
#endif
51+
52+
#endif
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2025 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+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef TUSB_BOARD_H
28+
#define TUSB_BOARD_H
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
// UART and LED are already defined in pico-sdk board
35+
36+
//--------------------------------------------------------------------+
37+
// PIO_USB
38+
//--------------------------------------------------------------------+
39+
40+
#define PICO_DEFAULT_PIO_USB_DP_PIN 16
41+
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 18
42+
#define PICO_DEFAULT_PIO_USB_VBUSEN_STATE 1
43+
44+
//--------------------------------------------------------------------
45+
// USB Host MAX3421E
46+
//--------------------------------------------------------------------
47+
48+
#ifdef PICO_DEFAULT_SPI
49+
#define MAX3421_SPI PICO_DEFAULT_SPI // sdk v2
50+
#else
51+
#define MAX3421_SPI PICO_DEFAULT_SPI_INSTANCE // sdk v1
52+
#endif
53+
54+
#define MAX3421_SCK_PIN PICO_DEFAULT_SPI_SCK_PIN
55+
#define MAX3421_MOSI_PIN PICO_DEFAULT_SPI_TX_PIN
56+
#define MAX3421_MISO_PIN PICO_DEFAULT_SPI_RX_PIN
57+
#define MAX3421_CS_PIN 10
58+
#define MAX3421_INTR_PIN 9
59+
60+
#ifdef __cplusplus
61+
}
62+
#endif
63+
64+
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
set(PICO_PLATFORM rp2040)
22
set(PICO_BOARD pico)
3+
#set(OPENOCD_SERIAL E6614103E719612F)
Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2021, Ha Thach (tinyusb.org)
4+
* Copyright (c) 2025 Ha Thach (tinyusb.org)
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -29,55 +29,22 @@
2929
url: https://www.raspberrypi.org/products/raspberry-pi-pico/
3030
*/
3131

32-
#ifndef BOARD_H_
33-
#define BOARD_H_
32+
#ifndef TUSB_BOARD_H
33+
#define TUSB_BOARD_H
3434

3535
#ifdef __cplusplus
3636
extern "C" {
3737
#endif
3838

39-
// LED
40-
#ifdef PICO_DEFAULT_LED_PIN
41-
#define LED_PIN PICO_DEFAULT_LED_PIN
42-
#define LED_STATE_ON (!(PICO_DEFAULT_LED_PIN_INVERTED))
43-
#endif
44-
45-
// Button pin is BOOTSEL which is flash CS pin
46-
#define BUTTON_BOOTSEL
47-
#define BUTTON_STATE_ACTIVE 0
48-
49-
// UART
50-
#if defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN) && \
51-
defined(PICO_DEFAULT_UART) && defined(LIB_PICO_STDIO_UART)
52-
#define UART_DEV PICO_DEFAULT_UART
53-
#define UART_TX_PIN PICO_DEFAULT_UART_TX_PIN
54-
#define UART_RX_PIN PICO_DEFAULT_UART_RX_PIN
55-
#endif
39+
// UART and LED are already defined in pico-sdk board
5640

5741
//--------------------------------------------------------------------+
5842
// PIO_USB
59-
// default to pin on Adafruit Feather rp2040 USB Host or Tester if defined
6043
//--------------------------------------------------------------------+
61-
62-
// #define USE_ADAFRUIT_FEATHER_RP2040_USBHOST
63-
#ifdef USE_ADAFRUIT_FEATHER_RP2040_USBHOST
64-
#define PICO_DEFAULT_PIO_USB_DP_PIN 16
65-
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 18
66-
#endif
67-
68-
#ifndef PICO_DEFAULT_PIO_USB_DP_PIN
44+
// default to pico brain tester
6945
#define PICO_DEFAULT_PIO_USB_DP_PIN 20
70-
#endif
71-
72-
// VBUS enable pin and its active state
73-
#ifndef PICO_DEFAULT_PIO_USB_VBUSEN_PIN
7446
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 22
75-
#endif
76-
77-
// VBUS enable state
78-
#ifndef PICO_DEFAULT_PIO_USB_VBUSEN_STATE
7947
#define PICO_DEFAULT_PIO_USB_VBUSEN_STATE 1
80-
#endif
8148

8249
//--------------------------------------------------------------------
8350
// USB Host MAX3421E
@@ -99,4 +66,4 @@
9966
}
10067
#endif
10168

102-
#endif /* BOARD_H_ */
69+
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
set(PICO_PLATFORM rp2350-arm-s)
22
set(PICO_BOARD pico2)
3+
#set(OPENOCD_SERIAL E6614103E77C5A24)

0 commit comments

Comments
 (0)