Skip to content

Commit 947e958

Browse files
authored
Merge pull request #18 from visrealm/dev
0.4.3
2 parents 8d696b6 + aae034f commit 947e958

File tree

11 files changed

+262
-48
lines changed

11 files changed

+262
-48
lines changed

.vscode/c_cpp_properties.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Pico",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"${userHome}/.pico-sdk/sdk/2.0.0/**"
8+
],
9+
"forcedInclude": [
10+
"${workspaceFolder}/build/generated/pico_base/pico/config_autogen.h",
11+
"${userHome}/.pico-sdk/sdk/2.0.0/src/common/pico_base_headers/include/pico.h"
12+
],
13+
"defines": [],
14+
"compilerPath": "${userHome}/.pico-sdk/toolchain/13_3_Rel1/bin/arm-none-eabi-gcc",
15+
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
16+
"cStandard": "c17",
17+
"cppStandard": "c++14",
18+
"intelliSenseMode": "linux-gcc-arm"
19+
}
20+
],
21+
"version": 4
22+
}

.vscode/cmake-kits.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"name": "Pico",
4+
"compilers": {
5+
"C": "${userHome}/.pico-sdk/toolchain/13_2_Rel1/bin/arm-none-eabi-gcc.exe",
6+
"CXX": "${userHome}/.pico-sdk/toolchain/13_2_Rel1/bin/arm-none-eabi-gcc.exe"
7+
},
8+
"toolchainFile": "${env:USERPROFILE}/.pico-sdk/sdk/2.0.0/cmake/preload/toolchains/pico_arm_cortex_m0plus_gcc.cmake",
9+
"environmentVariables": {
10+
"PATH": "${command:raspberry-pi-pico.getEnvPath};${env:PATH}"
11+
},
12+
"cmakeSettings": {
13+
"Python3_EXECUTABLE": "${command:raspberry-pi-pico.getPythonPath}"
14+
}
15+
}
16+
]

.vscode/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"marus25.cortex-debug",
4+
"ms-vscode.cpptools",
5+
"ms-vscode.cpptools-extension-pack",
6+
"ms-vscode.vscode-serial-monitor",
7+
"raspberry-pi.raspberry-pi-pico",
8+
]
9+
}

.vscode/launch.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Pico Debug (Cortex-Debug)",
6+
"cwd": "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
7+
"executable": "${command:raspberry-pi-pico.launchTargetPath}",
8+
"request": "launch",
9+
"type": "cortex-debug",
10+
"servertype": "openocd",
11+
"serverpath": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
12+
"gdbPath": "${command:raspberry-pi-pico.getGDBPath}",
13+
"device": "${command:raspberry-pi-pico.getChipUppercase}",
14+
"configFiles": [
15+
"interface/cmsis-dap.cfg",
16+
"target/${command:raspberry-pi-pico.getTarget}.cfg"
17+
],
18+
"svdFile": "${userHome}/.pico-sdk/sdk/2.0.0/src/${command:raspberry-pi-pico.getChip}/hardware_regs/${command:raspberry-pi-pico.getChipUppercase}.svd",
19+
"runToEntryPoint": "main",
20+
// Fix for no_flash binaries, where monitor reset halt doesn't do what is expected
21+
// Also works fine for flash binaries
22+
"overrideLaunchCommands": [
23+
"monitor reset init",
24+
"load \"${command:raspberry-pi-pico.launchTargetPath}\""
25+
],
26+
"openOCDLaunchCommands": [
27+
"adapter speed 5000"
28+
]
29+
},
30+
{
31+
"name": "Pico Debug (Cortex-Debug with external OpenOCD)",
32+
"cwd": "${workspaceRoot}",
33+
"executable": "${command:raspberry-pi-pico.launchTargetPath}",
34+
"request": "launch",
35+
"type": "cortex-debug",
36+
"servertype": "external",
37+
"gdbTarget": "localhost:3333",
38+
"gdbPath": "${command:raspberry-pi-pico.getGDBPath}",
39+
"device": "${command:raspberry-pi-pico.getChipUppercase}",
40+
"svdFile": "${userHome}/.pico-sdk/sdk/2.0.0/src/${command:raspberry-pi-pico.getChip}/hardware_regs/${command:raspberry-pi-pico.getChipUppercase}.svd",
41+
"runToEntryPoint": "main",
42+
// Give restart the same functionality as runToEntryPoint - main
43+
"postRestartCommands": [
44+
"break main",
45+
"continue"
46+
]
47+
},
48+
{
49+
"name": "Pico Debug (C++ Debugger)",
50+
"type": "cppdbg",
51+
"request": "launch",
52+
"cwd": "${workspaceRoot}",
53+
"program": "${command:raspberry-pi-pico.launchTargetPath}",
54+
"MIMode": "gdb",
55+
"miDebuggerPath": "${command:raspberry-pi-pico.getGDBPath}",
56+
"miDebuggerServerAddress": "localhost:3333",
57+
"debugServerPath": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
58+
"debugServerArgs": "-f interface/cmsis-dap.cfg -f target/${command:raspberry-pi-pico.getTarget}.cfg -c \"adapter speed 5000\"",
59+
"serverStarted": "Listening on port .* for gdb connections",
60+
"filterStderr": true,
61+
"hardwareBreakpoints": {
62+
"require": true,
63+
"limit": 4
64+
},
65+
"preLaunchTask": "Flash",
66+
"svdPath": "${userHome}/.pico-sdk/sdk/2.0.0/src/${command:raspberry-pi-pico.getChip}/hardware_regs/${command:raspberry-pi-pico.getChipUppercase}.svd"
67+
},
68+
]
69+
}

.vscode/tasks.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Compile Project",
6+
"type": "process",
7+
"isBuildCommand": true,
8+
"command": "${userHome}/.pico-sdk/ninja/v1.12.1/ninja",
9+
"args": ["-C", "${workspaceFolder}/build"],
10+
"group": "build",
11+
"presentation": {
12+
"reveal": "always",
13+
"panel": "dedicated"
14+
},
15+
"problemMatcher": "$gcc",
16+
"windows": {
17+
"command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe"
18+
}
19+
},
20+
{
21+
"label": "Run Project",
22+
"type": "process",
23+
"command": "${env:HOME}/.pico-sdk/picotool/2.0.0/picotool/picotool",
24+
"args": [
25+
"load",
26+
"${command:raspberry-pi-pico.launchTargetPath}",
27+
"-fx"
28+
],
29+
"presentation": {
30+
"reveal": "always",
31+
"panel": "dedicated"
32+
},
33+
"problemMatcher": [],
34+
"windows": {
35+
"command": "${env:USERPROFILE}/.pico-sdk/picotool/2.0.0/picotool/picotool.exe"
36+
}
37+
},
38+
{
39+
"label": "Flash",
40+
"type": "process",
41+
"command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
42+
"args": [
43+
"-s",
44+
"${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
45+
"-f",
46+
"interface/cmsis-dap.cfg",
47+
"-f",
48+
"target/${command:raspberry-pi-pico.getTarget}.cfg",
49+
"-c",
50+
"adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit"
51+
],
52+
"problemMatcher": [],
53+
"windows": {
54+
"command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
55+
}
56+
}
57+
]
58+
}

src/CMakeLists.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ cmake_minimum_required(VERSION 3.13)
33

44
# compile-time options
55

6-
set(PICO9918_VERSION "0.4.2")
6+
set(PICO9918_VERSION "0.4.3")
77
set(PICO9918_PCB_MAJOR_VER 0)
88
set(PICO9918_PCB_MINOR_VER 4)
99

1010
set(PICO9918_SCANLINES 1)
1111

12+
# SCART RGBs options
13+
set(PICO9918_SCART_RGBS 0) # 1 for RGBs, 0 for VGA
14+
set(PICO9918_SCART_PAL 0) # 1 for PAL 576i, 0 for NTSC 480i
15+
1216
# end compile-time options
1317

1418

@@ -21,9 +25,19 @@ execute_process(
2125
OUTPUT_STRIP_TRAILING_WHITESPACE
2226
)
2327

28+
if (${PICO9918_SCART_RGBS})
29+
if (${PICO9918_SCART_PAL})
30+
set(PICO9918_OUTPUT_STR "rgbs-pal576i")
31+
else()
32+
set(PICO9918_OUTPUT_STR "rgbs-ntsc480i")
33+
endif()
34+
else()
35+
set(PICO9918_OUTPUT_STR "vga")
36+
endif()
37+
2438
string(REPLACE "." "-" PICO9918_VERSION_STR "${PICO9918_VERSION}")
2539

26-
set(PICO9918_BINARY_SUFFIX -pcb-v${PICO9918_PCB_MAJOR_VER}-${PICO9918_PCB_MINOR_VER}-${PICO9918_GIT_BRANCH}-build-${PICO9918_VERSION_STR})
40+
set(PICO9918_BINARY_SUFFIX -pcb-v${PICO9918_PCB_MAJOR_VER}-${PICO9918_PCB_MINOR_VER}-${PICO9918_OUTPUT_STR}-build-${PICO9918_VERSION_STR})
2741

2842
if (${PICO9918_SCANLINES})
2943
set(PICO9918_BINARY_SUFFIX ${PICO9918_BINARY_SUFFIX}-sl)
@@ -55,12 +69,14 @@ pico_add_extra_outputs(${PROGRAM})
5569
pico_enable_stdio_usb(${PROGRAM} 0)
5670
pico_enable_stdio_uart(${PROGRAM} 0)
5771

58-
pico_set_binary_type(${PROGRAM} copy_to_ram) # TOO SLOW TO BOOT
72+
pico_set_binary_type(${PROGRAM} copy_to_ram)
5973

6074
add_definitions(-DPICO9918_VERSION="${PICO9918_VERSION}")
6175
add_definitions(-DPICO9918_PCB_MAJOR_VER=${PICO9918_PCB_MAJOR_VER})
6276
add_definitions(-DPICO9918_PCB_MINOR_VER=${PICO9918_PCB_MINOR_VER})
6377
add_definitions(-DPICO9918_SCANLINES=${PICO9918_SCANLINES})
78+
add_definitions(-DPICO9918_SCART_RGBS=${PICO9918_SCART_RGBS})
79+
add_definitions(-DPICO9918_SCART_PAL=${PICO9918_SCART_PAL})
6480

6581
add_definitions(-DPICO_DISABLE_SHARED_IRQ_HANDLERS=1)
6682
#add_definitions(-DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1)

src/main.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
* https://www.aliexpress.com/item/1005007066733934.html
6464
*/
6565

66-
#define PCB_MAJOR_VERSION 0
67-
#define PCB_MINOR_VERSION 4
66+
#define PCB_MAJOR_VERSION PICO9918_PCB_MAJOR_VER
67+
#define PCB_MINOR_VERSION PICO9918_PCB_MINOR_VER
6868

6969
#define GPIO_CD7 14
7070
#define GPIO_CSR tmsRead_CSR_PIN // defined in tms9918.pio
@@ -97,9 +97,16 @@
9797

9898
#define TMS_CRYSTAL_FREQ_HZ 10738635.0f
9999

100-
#define PICO_CLOCK_PLL 1260000000
101-
#define PICO_CLOCK_PLL_DIV1 5
102-
#define PICO_CLOCK_PLL_DIV2 1
100+
#if PICO9918_SCART_RGBS // for 15kHz
101+
#define PICO_CLOCK_PLL 1536000000
102+
#define PICO_CLOCK_PLL_DIV1 3
103+
#define PICO_CLOCK_PLL_DIV2 2
104+
#else // for 31.46875 kHz
105+
#define PICO_CLOCK_PLL 1260000000
106+
#define PICO_CLOCK_PLL_DIV1 5
107+
#define PICO_CLOCK_PLL_DIV2 1
108+
#endif
109+
103110
#define PICO_CLOCK_HZ (PICO_CLOCK_PLL / PICO_CLOCK_PLL_DIV1 / PICO_CLOCK_PLL_DIV2)
104111

105112
#define TMS_PIO pio1
@@ -206,7 +213,7 @@ static inline void disableTmsPioInterrupts()
206213
static void __time_critical_func(tmsScanline)(uint16_t y, VgaParams* params, uint16_t* pixels)
207214
{
208215

209-
#if 1
216+
#if 0
210217
// better compile-time optimizations if we hard-code these
211218
#define VIRTUAL_PIXELS_X 640
212219
#define VIRTUAL_PIXELS_Y 240
@@ -394,7 +401,7 @@ void tmsPioInit()
394401
sm_config_set_out_pins(&readConfig, GPIO_CD7, 8);
395402
sm_config_set_in_shift(&readConfig, false, false, 32); // L shift
396403
sm_config_set_out_shift(&readConfig, true, false, 32); // R shift
397-
sm_config_set_clkdiv(&readConfig, 1.0f);
404+
sm_config_set_clkdiv(&readConfig, 4.0f);
398405

399406
pio_sm_init(TMS_PIO, tmsReadSm, tmsReadProgram, &readConfig);
400407
pio_sm_set_enabled(TMS_PIO, tmsReadSm, true);
@@ -446,10 +453,19 @@ int main(void)
446453

447454
/* then set up VGA output */
448455
VgaInitParams params = { 0 };
456+
457+
#if PICO9918_SCART_RGBS
458+
#if PICO9918_SCART_PAL
459+
params.params = vgaGetParams(RGBS_PAL_720_576i_50HZ);
460+
#else
461+
params.params = vgaGetParams(RGBS_NTSC_720_480i_60HZ);
462+
#endif
463+
#else // VGA
449464
params.params = vgaGetParams(VGA_640_480_60HZ);
450465

451-
/* virtual size will be 640 x 320 to accomodate 80-column mode */
466+
/* virtual size will be 640 x 240 to accomodate 80-column mode */
452467
setVgaParamsScaleY(&params.params, 2);
468+
#endif
453469

454470
/* set vga scanline callback to generate tms9918 scanlines */
455471
params.scanlineFn = tmsScanline;

src/res/splash.png

-1 Bytes
Loading

src/vga/vga-modes.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,37 @@ VgaParams vgaGetParams(VgaMode mode)
9696
params.vSyncParams.backPorchPixels = 38;
9797
params.vSyncParams.syncHigh = true;
9898
break;
99+
100+
case RGBS_PAL_720_576i_50HZ:
101+
params.pixelClockKHz = 13500;
102+
params.hSyncParams.displayPixels = 720;
103+
params.hSyncParams.frontPorchPixels = 22;
104+
params.hSyncParams.syncPixels = 64;
105+
params.hSyncParams.backPorchPixels = 74;
106+
params.hSyncParams.syncHigh = false;
107+
108+
params.vSyncParams.displayPixels = 576 / 2; // halving since... interlaced
109+
params.vSyncParams.frontPorchPixels = 8;
110+
params.vSyncParams.syncPixels = 3; // this should be 2.5
111+
params.vSyncParams.backPorchPixels = 14;
112+
params.vSyncParams.syncHigh = false;
113+
break;
114+
115+
case RGBS_NTSC_720_480i_60HZ:
116+
params.pixelClockKHz = 13500;
117+
params.hSyncParams.displayPixels = 720;
118+
params.hSyncParams.frontPorchPixels = 22;
119+
params.hSyncParams.syncPixels = 64;
120+
params.hSyncParams.backPorchPixels = 74;
121+
params.hSyncParams.syncHigh = false;
122+
123+
params.vSyncParams.displayPixels = 480 / 2; // halving since... interlaced
124+
params.vSyncParams.frontPorchPixels = 3;
125+
params.vSyncParams.syncPixels = 3;
126+
params.vSyncParams.backPorchPixels = 17; // this should be 16.5
127+
params.vSyncParams.syncHigh = false;
128+
break;
129+
99130
}
100131

101132
if (params.pixelClockKHz && params.hSyncParams.displayPixels && params.vSyncParams.displayPixels)

src/vga/vga-modes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ typedef enum
2020
VGA_800_600_60HZ,
2121
VGA_1024_768_60HZ,
2222
VGA_1280_1024_60HZ,
23+
RGBS_PAL_720_576i_50HZ,
24+
RGBS_NTSC_720_480i_60HZ,
2325
} VgaMode;
2426

2527

0 commit comments

Comments
 (0)