Seeing if i can get this to work
This commit is contained in:
BIN
.cache/clangd/index/main.c.FD33880BB41924A3.idx
Normal file
BIN
.cache/clangd/index/main.c.FD33880BB41924A3.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/vga.c.0DFA730AD660A07F.idx
Normal file
BIN
.cache/clangd/index/vga.c.0DFA730AD660A07F.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/vga.h.DADCA5B487311169.idx
Normal file
BIN
.cache/clangd/index/vga.h.DADCA5B487311169.idx
Normal file
Binary file not shown.
@@ -1,42 +1,29 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
|
|
||||||
# initalize pico_sdk from installed location
|
|
||||||
# (note this can come from environment, CMake cache etc)
|
|
||||||
set(PICO_SDK_PATH "/home/ben/pico/pico-sdk")
|
|
||||||
|
|
||||||
# Pull in Raspberry Pi Pico SDK (must be before project)
|
# Pull in Raspberry Pi Pico SDK (must be before project)
|
||||||
|
set(PICO_SDK_FETCH_FROM_GIT on)
|
||||||
include(pico_sdk_import.cmake)
|
include(pico_sdk_import.cmake)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
project(pico_vga C CXX ASM)
|
project(pico_vga C CXX ASM)
|
||||||
|
|
||||||
add_executable(pico_vga)
|
|
||||||
|
|
||||||
# Initialise the Raspberry Pi Pico SDK
|
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
||||||
|
|
||||||
pico_set_program_name(pico_vga "pico_vga")
|
# pico_generate_pio_header(pico_vga ${CMAKE_CURRENT_LIST_DIR}/video.pio)
|
||||||
pico_set_program_version(pico_vga "0.1")
|
|
||||||
|
|
||||||
pico_enable_stdio_usb(pico_vga 1)
|
add_executable(pico_vga
|
||||||
pico_enable_stdio_uart(pico_vga 0)
|
src/main.c
|
||||||
|
|
||||||
pico_generate_pio_header(pico_vga ${CMAKE_CURRENT_LIST_DIR}/video.pio)
|
|
||||||
|
|
||||||
target_sources(pico_vga PRIVATE
|
|
||||||
main.c
|
|
||||||
vga.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add the standard library to the build
|
# Add the standard library to the build
|
||||||
target_link_libraries(pico_vga
|
target_link_libraries(pico_vga
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
hardware_pio
|
# hardware_pio
|
||||||
hardware_dma
|
# hardware_dma
|
||||||
hardware_irq
|
# hardware_irq
|
||||||
)
|
)
|
||||||
|
|
||||||
pico_add_extra_outputs(pico_vga)
|
pico_add_extra_outputs(pico_vga)
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
40
main.c
40
main.c
@@ -1,40 +0,0 @@
|
|||||||
// Copyright Benjamin Kyd 2021 All Rights Reserved
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "pico/stdlib.h"
|
|
||||||
#include "hardware/clocks.h"
|
|
||||||
#include "hardware/pio.h"
|
|
||||||
#include "hardware/dma.h"
|
|
||||||
#include "hardware/irq.h"
|
|
||||||
|
|
||||||
#include "pico/stdlib.h"
|
|
||||||
|
|
||||||
#include "vga.h"
|
|
||||||
|
|
||||||
// PIN LAYOUT
|
|
||||||
// PIN 0-3 RED DAC
|
|
||||||
// PIN 4-7 GREEN DAC
|
|
||||||
// PIN 8-11 BLUE DAC
|
|
||||||
// PIN 12 HSYNC
|
|
||||||
// PIN 13 VSYNC
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
stdio_init_all();
|
|
||||||
sleep_ms(1400);
|
|
||||||
|
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
|
||||||
|
|
||||||
printf("VGA Initalizing...\n");
|
|
||||||
|
|
||||||
const video_timing_t video_timing = vga_timing_800x600_60;
|
|
||||||
vga_init(&video_timing);
|
|
||||||
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
tight_loop_contents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
16
makefile
Normal file
16
makefile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
.ONESHELL:
|
||||||
|
|
||||||
|
all: compile flash
|
||||||
|
|
||||||
|
compile:
|
||||||
|
cd build && cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=on && make
|
||||||
|
|
||||||
|
flash: compile
|
||||||
|
sudo mount -L RPI-RP2 /mnt
|
||||||
|
sudo cp build/pico_vga.uf2 /mnt
|
||||||
|
echo "Copied pico_vga.uf2 to pico"
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build
|
||||||
|
mkdir build
|
||||||
|
|
||||||
@@ -29,11 +29,22 @@ if (NOT PICO_SDK_PATH)
|
|||||||
if (PICO_SDK_FETCH_FROM_GIT_PATH)
|
if (PICO_SDK_FETCH_FROM_GIT_PATH)
|
||||||
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
endif ()
|
endif ()
|
||||||
FetchContent_Declare(
|
# GIT_SUBMODULES_RECURSE was added in 3.17
|
||||||
pico_sdk
|
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
|
||||||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
FetchContent_Declare(
|
||||||
GIT_TAG master
|
pico_sdk
|
||||||
)
|
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||||
|
GIT_TAG master
|
||||||
|
GIT_SUBMODULES_RECURSE FALSE
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
FetchContent_Declare(
|
||||||
|
pico_sdk
|
||||||
|
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||||
|
GIT_TAG master
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (NOT pico_sdk)
|
if (NOT pico_sdk)
|
||||||
message("Downloading Raspberry Pi Pico SDK")
|
message("Downloading Raspberry Pi Pico SDK")
|
||||||
FetchContent_Populate(pico_sdk)
|
FetchContent_Populate(pico_sdk)
|
||||||
|
|||||||
17
src/main.c
Normal file
17
src/main.c
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// Copyright Benjamin Kyd 2021 All Rights Reserved
|
||||||
|
|
||||||
|
// PIN LAYOUT
|
||||||
|
// PIN 0-3 RED DAC
|
||||||
|
// PIN 4-7 GREEN DAC
|
||||||
|
// PIN 8-11 BLUE DAC
|
||||||
|
// PIN 12 HSYNC
|
||||||
|
// PIN 13 VSYNC
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "pico/stdlib.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
setup_default_uart();
|
||||||
|
printf("Hello, world!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -11,28 +11,28 @@
|
|||||||
#include "vga.h"
|
#include "vga.h"
|
||||||
#include "video.pio.h"
|
#include "video.pio.h"
|
||||||
|
|
||||||
const video_timing_t vga_timing_800x600_60 =
|
// const video_timing_t vga_timing_800x600_60 =
|
||||||
{
|
// {
|
||||||
.clock_freq = 38400000,
|
// .clock_freq = 38400000,
|
||||||
|
//
|
||||||
.h_active = 800,
|
// .h_active = 800,
|
||||||
.v_active = 600,
|
// .v_active = 600,
|
||||||
|
//
|
||||||
.h_front_porch = 4 * 8,
|
// .h_front_porch = 4 * 8,
|
||||||
.h_pulse = 10 * 8,
|
// .h_pulse = 10 * 8,
|
||||||
.h_total = 128 * 8,
|
// .h_total = 128 * 8,
|
||||||
.h_sync_polarity = 0,
|
// .h_sync_polarity = 0,
|
||||||
|
//
|
||||||
.v_front_porch = 1,
|
// .v_front_porch = 1,
|
||||||
.v_pulse = 3,
|
// .v_pulse = 3,
|
||||||
.v_total = 625,
|
// .v_total = 625,
|
||||||
.v_sync_polarity = 0,
|
// .v_sync_polarity = 0,
|
||||||
|
//
|
||||||
.enable_clock = 0,
|
// .enable_clock = 0,
|
||||||
.clock_polarity = 0,
|
// .clock_polarity = 0,
|
||||||
|
//
|
||||||
.enable_den = 0
|
// .enable_den = 0
|
||||||
};
|
// };
|
||||||
|
|
||||||
#define PIN_START 8
|
#define PIN_START 8
|
||||||
#define PIN_COUNT 2
|
#define PIN_COUNT 2
|
||||||
40
src/vga.h
Normal file
40
src/vga.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef PICOVGA_VGA_H_
|
||||||
|
#define PICOVGA_VGA_H_
|
||||||
|
|
||||||
|
#include "pico/types.h"
|
||||||
|
//
|
||||||
|
// typedef struct video_timing {
|
||||||
|
// uint32_t clock_freq;
|
||||||
|
//
|
||||||
|
// uint16_t h_active;
|
||||||
|
// uint16_t v_active;
|
||||||
|
//
|
||||||
|
// uint16_t h_front_porch;
|
||||||
|
// uint16_t h_pulse;
|
||||||
|
// uint16_t h_total;
|
||||||
|
// uint8_t h_sync_polarity;
|
||||||
|
//
|
||||||
|
// uint16_t v_front_porch;
|
||||||
|
// uint16_t v_pulse;
|
||||||
|
// uint16_t v_total;
|
||||||
|
// uint8_t v_sync_polarity;
|
||||||
|
//
|
||||||
|
// uint8_t enable_clock;
|
||||||
|
// uint8_t clock_polarity;
|
||||||
|
//
|
||||||
|
// uint8_t enable_den;
|
||||||
|
// } video_timing_t;
|
||||||
|
//
|
||||||
|
// const video_timing_t vga_timing_800x600_60;
|
||||||
|
//
|
||||||
|
// // typedef struct video {
|
||||||
|
// // uint16_t*
|
||||||
|
// // } video_t;
|
||||||
|
//
|
||||||
|
// void vga_init(const video_timing_t* timing);
|
||||||
|
//
|
||||||
|
// void vga_start();
|
||||||
|
//
|
||||||
|
// void vga_swap_buffers();
|
||||||
|
//
|
||||||
|
#endif
|
||||||
40
vga.h
40
vga.h
@@ -1,40 +0,0 @@
|
|||||||
#ifndef PICOVGA_VGA_H_
|
|
||||||
#define PICOVGA_VGA_H_
|
|
||||||
|
|
||||||
#include "pico/types.h"
|
|
||||||
|
|
||||||
typedef struct video_timing {
|
|
||||||
uint32_t clock_freq;
|
|
||||||
|
|
||||||
uint16_t h_active;
|
|
||||||
uint16_t v_active;
|
|
||||||
|
|
||||||
uint16_t h_front_porch;
|
|
||||||
uint16_t h_pulse;
|
|
||||||
uint16_t h_total;
|
|
||||||
uint8_t h_sync_polarity;
|
|
||||||
|
|
||||||
uint16_t v_front_porch;
|
|
||||||
uint16_t v_pulse;
|
|
||||||
uint16_t v_total;
|
|
||||||
uint8_t v_sync_polarity;
|
|
||||||
|
|
||||||
uint8_t enable_clock;
|
|
||||||
uint8_t clock_polarity;
|
|
||||||
|
|
||||||
uint8_t enable_den;
|
|
||||||
} video_timing_t;
|
|
||||||
|
|
||||||
const video_timing_t vga_timing_800x600_60;
|
|
||||||
|
|
||||||
// typedef struct video {
|
|
||||||
// uint16_t*
|
|
||||||
// } video_t;
|
|
||||||
|
|
||||||
void vga_init(const video_timing_t* timing);
|
|
||||||
|
|
||||||
void vga_start();
|
|
||||||
|
|
||||||
void vga_swap_buffers();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
5
vga.txt
5
vga.txt
@@ -1,5 +0,0 @@
|
|||||||
WHITE - VSYNC -
|
|
||||||
BLACK - HSYNC -
|
|
||||||
RED - VGA_R -
|
|
||||||
GREEN - VGA_G -
|
|
||||||
BLUE - VGA_B -
|
|
||||||
28
video.pio
28
video.pio
@@ -1,28 +0,0 @@
|
|||||||
; Copyright Benjamin Kyd 2021 All Rights Reserved
|
|
||||||
|
|
||||||
.program video
|
|
||||||
|
|
||||||
; write 5 bits from the TX FIFO to the pin mask
|
|
||||||
|
|
||||||
.wrap_target
|
|
||||||
out pins 2
|
|
||||||
.wrap
|
|
||||||
|
|
||||||
% c-sdk {
|
|
||||||
static inline void video_program_init(PIO pio, uint sm, uint offset, uint pin, float clk_div) {
|
|
||||||
pio_sm_config c = video_program_get_default_config(offset);
|
|
||||||
|
|
||||||
// Map the state machine's OUT pin group to one pin, namely the `pin`
|
|
||||||
// parameter to this function.
|
|
||||||
sm_config_set_out_pins(&c, pin, 1);
|
|
||||||
// Set this pin's GPIO function (connect PIO to the pad)
|
|
||||||
pio_gpio_init(pio, pin);
|
|
||||||
// Set the pin direction to output at the PIO
|
|
||||||
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
|
|
||||||
|
|
||||||
// Load our configuration, and jump to the start of the program
|
|
||||||
pio_sm_init(pio, sm, offset, &c);
|
|
||||||
// Set the state machine running
|
|
||||||
pio_sm_set_enabled(pio, sm, true);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
Reference in New Issue
Block a user