1+ /*
2+ * Copyright (c) 2024 Raspberry Pi (Trading) Ltd.
3+ *
4+ * SPDX-License-Identifier: BSD-3-Clause
5+ */
6+
7+ // -----------------------------------------------------
8+ // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
9+ // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
10+ // -----------------------------------------------------
11+
12+ #ifndef _BOARDS_RASPBERRY_PI_PI500_RP2040_H
13+ #define _BOARDS_RASPBERRY_PI_PI500_RP2040_H
14+
15+ pico_board_cmake_set (PICO_PLATFORM , rp2040 )
16+
17+ // For board detection
18+ #define RASPBERRY_PI_PI500_RP2040
19+
20+ // --- UART ---
21+ #ifndef PICO_DEFAULT_UART
22+ #define PICO_DEFAULT_UART 0
23+ #endif
24+ #ifndef PICO_DEFAULT_UART_TX_PIN
25+ #define PICO_DEFAULT_UART_TX_PIN 16 // Pi 500 debug UART on GP16
26+ #endif
27+ #ifndef PICO_DEFAULT_UART_RX_PIN
28+ #define PICO_DEFAULT_UART_RX_PIN 1 // Standard RX pin
29+ #endif
30+
31+ // --- LED ---
32+ #ifndef PICO_DEFAULT_LED_PIN
33+ #define PICO_DEFAULT_LED_PIN 17 // Pi 500 LED on GP17
34+ #endif
35+
36+ // --- I2C ---
37+ #ifndef PICO_DEFAULT_I2C
38+ #define PICO_DEFAULT_I2C 0
39+ #endif
40+ #ifndef PICO_DEFAULT_I2C_SDA_PIN
41+ #define PICO_DEFAULT_I2C_SDA_PIN 4
42+ #endif
43+ #ifndef PICO_DEFAULT_I2C_SCL_PIN
44+ #define PICO_DEFAULT_I2C_SCL_PIN 5
45+ #endif
46+
47+ // --- SPI ---
48+ #ifndef PICO_DEFAULT_SPI
49+ #define PICO_DEFAULT_SPI 0
50+ #endif
51+ #ifndef PICO_DEFAULT_SPI_SCK_PIN
52+ #define PICO_DEFAULT_SPI_SCK_PIN 18
53+ #endif
54+ #ifndef PICO_DEFAULT_SPI_TX_PIN
55+ #define PICO_DEFAULT_SPI_TX_PIN 19
56+ #endif
57+ #ifndef PICO_DEFAULT_SPI_RX_PIN
58+ #define PICO_DEFAULT_SPI_RX_PIN 16
59+ #endif
60+ #ifndef PICO_DEFAULT_SPI_CSN_PIN
61+ #define PICO_DEFAULT_SPI_CSN_PIN 17
62+ #endif
63+
64+ // --- FLASH ---
65+ // Pi 500 uses W25X10CL flash (differs from standard Pico W25Q080)
66+ #define PICO_BOOT_STAGE2_CHOOSE_W25X10CL 1
67+
68+ #ifndef PICO_FLASH_SPI_CLKDIV
69+ #define PICO_FLASH_SPI_CLKDIV 2
70+ #endif
71+
72+ pico_board_cmake_set_default (PICO_FLASH_SIZE_BYTES , (1 * 1024 * 1024 )) // 1MB W25X10CL
73+ #ifndef PICO_FLASH_SIZE_BYTES
74+ #define PICO_FLASH_SIZE_BYTES (1 * 1024 * 1024)
75+ #endif
76+
77+ // Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
78+ #define PICO_SMPS_MODE_PIN 23
79+
80+ #ifndef PICO_RP2040_B0_SUPPORTED
81+ #define PICO_RP2040_B0_SUPPORTED 1
82+ #endif
83+
84+ // The GPIO Pin used to read VBUS to determine if the device is battery powered.
85+ #ifndef PICO_VBUS_PIN
86+ #define PICO_VBUS_PIN 24
87+ #endif
88+
89+ // The GPIO Pin used to monitor VSYS. Typically you would use this with ADC.
90+ #ifndef PICO_VSYS_PIN
91+ #define PICO_VSYS_PIN 29
92+ #endif
93+
94+ // --- USB CONFIGURATION ---
95+ // Crucial for Pi 500 keyboard function when Pi is off - ignores USB startup check
96+ #define PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE 0
97+ #define PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED 0
98+
99+ // --- BOOTLOADER CONFIGURATION ---
100+ // Disable double tap reset timeout for Pi 500
101+ #define PICO_BOOTSEL_VIA_DOUBLE_RESET_ACTIVITY_LED 0
102+
103+ // --- PI 500 KEYBOARD MATRIX CONFIGURATION ---
104+ // Complete GPIO pin mapping for 8×18 keyboard matrix
105+ // Rows (8): GP0, GP1, GP2, GP3, GP4, GP5, GP6, GP7
106+ // Cols (18): GP27, GP8, GP9, GP10, GP11, GP12, GP13, GP14, GP23, GP24, GP22, GP20, GP29, GP18, GP15, GP21, GP28, GP26
107+ // Matrix scanning: ROW2COL, no diodes (ghost keys possible with 3+ key combinations)
108+
109+ // --- PI 500 SYSTEM PINS ---
110+ // These pins are reserved for Pi 500 hardware functions:
111+ // GP0-GP7: Keyboard matrix rows
112+ // GP8-GP15: Keyboard matrix columns (partial)
113+ // GP16: Debug UART TX
114+ // GP17: LED (heartbeat/debug)
115+ // GP18: Keyboard matrix column
116+ // GP19: Power button control (PWR_BTN) - CRITICAL for Pi power management
117+ // GP20: Power key detection column (separate from matrix)
118+ // GP21-GP24: Keyboard matrix columns
119+ // GP25: Caps Lock LED
120+ // GP26-GP29: Keyboard matrix columns
121+
122+ // --- POWER MANAGEMENT WARNING ---
123+ // Custom firmware MUST implement power button handling via GP19 or the Pi 500
124+ // power button will stop working, potentially making the device unbootable.
125+ // See QMK pi500.c for reference implementation.
126+
127+ #endif
0 commit comments