8000 metro rp2350: Enable USB host by default · chbeer/circuitpython@b13f470 · GitHub
[go: up one dir, main page]

Skip to content

Commit b13f470

Browse files
committed
metro rp2350: Enable USB host by default
Testing performed: This allows a plugged-in USB keyboard to be used to enter the repl with ctrl-c & type text.
1 parent 65556b4 commit b13f470

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

ports/raspberrypi/boards/adafruit_metro_rp2350/board.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@
44
//
55
// SPDX-License-Identifier: MIT
66

7+
#include "common-hal/microcontroller/Pin.h"
8+
#include "hardware/gpio.h"
9+
#include "shared-bindings/usb_host/Port.h"
710
#include "supervisor/board.h"
811

912
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
13+
14+
15+
#if defined(DEFAULT_USB_HOST_5V_POWER)
16+
bool board_reset_pin_number(uint8_t pin_number) {
17+
if (pin_number == DEFAULT_USB_HOST_5V_POWER->number) {
18+
// doing this (rather than gpio_init) in this specific order ensures no
19+
// glitch if pin was already configured as a high output. gpio_init() temporarily
20+
// configures the pin as an input, so the power enable value would potentially
21+
// glitch.
22+
gpio_put(pin_number, 1);
23+
gpio_set_dir(pin_number, GPIO_OUT);
24+
gpio_set_function(pin_number, GPIO_FUNC_SIO);
25+
26+
return true;
27+
}
28+
return false;
29+
}
30+
#endif
31+
32+
#if defined(DEFAULT_USB_HOST_DATA_PLUS)
33+
void board_init(void) {
34+
common_hal_usb_host_port_construct(DEFAULT_USB_HOST_DATA_PLUS, DEFAULT_USB_HOST_DATA_MINUS);
35+
}
36+
#endif

ports/raspberrypi/boards/adafruit_metro_rp2350/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@
2222
// #define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX
2323
// #define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX
2424

25+
#define DEFAULT_USB_HOST_DATA_PLUS (&pin_GPIO32)
26+
#define DEFAULT_USB_HOST_DATA_MINUS (&pin_GPIO33)
27+
#define DEFAULT_USB_HOST_5V_POWER (&pin_GPIO29)
2528
#define CIRCUITPY_PSRAM_CHIP_SELECT (&pin_GPIO47)

0 commit comments

Comments
 (0)
0