video: Allow GPIO pins for video to be configured

Adds a new build option, -DVIDEO_PIN=<n>, which sets the base GPIO
of Video (followed by syncs).

The video pins (for PIO reasons) need to be contiguous, numbered upward
from the DATA pin.  This has caught a couple of people out, so to make
it easier just define them this way.  That then gives a single
configuration option, the first GPIO, setting it all up.
This commit is contained in:
Matt Evans 2024-12-20 22:15:14 +00:00
parent 559fac339b
commit 18ab993e34
3 changed files with 17 additions and 6 deletions

View file

@ -36,6 +36,7 @@ set(SD_SCK 2 CACHE STRING "SD SPI SCK pin")
set(SD_CS 5 CACHE STRING "SD SPI CS pin")
set(SD_MHZ 5 CACHE STRING "SD SPI speed in MHz")
option(USE_VGA_RES "Video uses VGA (640x480) resolution" OFF)
set(VIDEO_PIN 18 CACHE STRING "Video GPIO base pin (followed by VS, CLK, HS)")
# See below, -DMEMSIZE=<size in KB> will configure umac's memory size,
# overriding defaults.
@ -93,6 +94,7 @@ else()
add_compile_definitions(DISP_WIDTH=512)
add_compile_definitions(DISP_HEIGHT=342)
endif()
add_compile_definitions(GPIO_VID_BASE=${VIDEO_PIN})
if (TARGET tinyusb_device)
add_executable(firmware

View file

@ -80,7 +80,8 @@ mkdir build
(cd build ; PICO_SDK_PATH=/path/to/sdk cmake .. <options>)
```
Options are required if you want SD support, or more than the default 128K of memory:
Options are required if you want SD support, more than the default 128K of memory,
higher resolution, to change pin configs, etc.:
* `-DUSE_SD=true`: Include SD card support. The GPIOs default to
`spi0` running at 5MHz, and GPIOs 2,3,4,5 for
@ -106,6 +107,8 @@ Options are required if you want SD support, or more than the default 128K of me
option makes a _Mac 128K_ configuration virtually unusable.
It is recommended only to use this when configuring >208K
using the option above.
* `-DVIDEO_PIN=<GPIO pin>`: Move the video output pins; defaults
to the pinout shown below.
Tip: `cmake` caches these variables, so if you see weird behaviour
having built previously and then changed an option, delete the `build`
@ -235,13 +238,19 @@ board with 2MB+ flash as long as all required GPIOs are pinned out:
| ------------ | ------------ | -------------- |
| GP0 | 1 | UART0 TX |
| GP1 | 2 | UART0 RX |
| GP18 | 24 | Video output |
| GP18 | 24 | Video output % |
| GP19 | 25 | VSYNC |
| GP21 | 27 | HSYNC |
| Gnd | 23, 28 | Video ground |
| VBUS (5V) | 40 | +5V supply |
| Gnd | 38 | Supply ground |
%: The video pins default here, but can be moved by building with the
`-DVIDEO_PIN` option. This sets the position of the Video pin,
which is immediately followed by VSYNC, then a gap, then HSYNC.
For example, `-DVIDEO_PIN=20` configures the Video pin at 20,
VSYNC at 21, HSYNC at 23.
Method:
* Wire 5V supply to VBUS/Gnd

View file

@ -29,9 +29,9 @@
#define GPIO_LED_PIN PICO_DEFAULT_LED_PIN
#define GPIO_VID_DATA 18
#define GPIO_VID_VS 19
#define GPIO_VID_CLK 20
#define GPIO_VID_HS 21
#define GPIO_VID_DATA GPIO_VID_BASE
#define GPIO_VID_VS (GPIO_VID_DATA + 1)
#define GPIO_VID_CLK (GPIO_VID_VS + 1)
#define GPIO_VID_HS (GPIO_VID_CLK + 1)
#endif