Skip to content

Commit 0c6476d

Browse files
committed
PICO-56 Code: Initial add
1 parent fbfe690 commit 0c6476d

File tree

199 files changed

+14089
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+14089
-0
lines changed

.gitmodules

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[submodule "submodules/vrEmuTms9918"]
2+
path = submodules/vrEmuTms9918
3+
url = https://github.com/visrealm/vrEmuTms9918.git
4+
[submodule "submodules/vrEmu6502"]
5+
path = submodules/vrEmu6502
6+
url = https://github.com/visrealm/vrEmu6502.git
7+
[submodule "submodules/vrEmu6522"]
8+
path = submodules/vrEmu6522
9+
url = https://github.com/visrealm/vrEmu6522.git
10+
[submodule "submodules/sdcard"]
11+
path = submodules/sdcard
12+
url = https://github.com/visrealm/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico.git
13+
[submodule "submodules/emu2149"]
14+
path = submodules/emu2149
15+
url = https://github.com/visrealm/emu2149.git

episodes/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_subdirectory(ep00-intro)
2+
add_subdirectory(ep01-vga)
3+
add_subdirectory(ep02-tms)

episodes/ep00-intro/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(EPISODE ep00-intro)
2+
3+
add_subdirectory(${EPISODE}-00-blink)
4+
add_subdirectory(${EPISODE}-01-pio-blink)
5+
add_subdirectory(${EPISODE}-02-pio-dma-blink)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(PROGRAM ${EPISODE}-00-blink)
2+
3+
add_executable(${PROGRAM})
4+
5+
target_sources(${PROGRAM} PRIVATE main.c)
6+
7+
pico_add_extra_outputs(${PROGRAM})
8+
9+
target_link_libraries(${PROGRAM} PRIVATE pico_stdlib)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Project: pico-56 - episode 0
3+
*
4+
* Copyright (c) 2023 Troy Schrapel
5+
*
6+
* This code is licensed under the MIT license
7+
*
8+
* https://github.com/visrealm/pico-56
9+
*
10+
*/
11+
12+
#include "pico/stdlib.h"
13+
14+
int main(void)
15+
{
16+
// initialise the pin (standard io)
17+
gpio_init(PICO_DEFAULT_LED_PIN);
18+
19+
// set as output
20+
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
21+
22+
while (1)
23+
{
24+
// on
25+
gpio_put(PICO_DEFAULT_LED_PIN, true);
26+
sleep_ms(500);
27+
28+
// off
29+
gpio_put(PICO_DEFAULT_LED_PIN, false);
30+
sleep_ms(500);
31+
}
32+
33+
return 0;
34+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(PROGRAM ${EPISODE}-01-pio-blink)
2+
3+
add_executable(${PROGRAM})
4+
5+
target_sources(${PROGRAM} PRIVATE main.c)
6+
7+
# generate header file from pio
8+
pico_generate_pio_header(${PROGRAM} ${CMAKE_CURRENT_LIST_DIR}/blink.pio)
9+
10+
pico_add_extra_outputs(${PROGRAM})
11+
12+
target_link_libraries(${PROGRAM} PRIVATE pico_stdlib hardware_pio)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Project: pico-56
3+
*
4+
* Copyright (c) 2023 Troy Schrapel
5+
*
6+
* This code is licensed under the MIT license
7+
*
8+
* https://github.com/visrealm/pico-56
9+
*
10+
*/
11+
12+
.program blink
13+
pull block
14+
.wrap_target
15+
set pins, 1
16+
mov x, osr
17+
onDelay:
18+
jmp x-- onDelay
19+
set pins, 0
20+
mov x, osr
21+
offDelay:
22+
jmp x-- offDelay
23+
.wrap
24+
25+
26+
% c-sdk {
27+
28+
void blink_program_init(PIO pio, uint sm, uint offset, uint pin) {
29+
pio_gpio_init(pio, pin);
30+
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
31+
pio_sm_config c = blink_program_get_default_config(offset);
32+
sm_config_set_set_pins(&c, pin, 1);
33+
pio_sm_init(pio, sm, offset, &c);
34+
}
35+
%}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Project: pico-56 - episode 0
3+
*
4+
* Copyright (c) 2023 Troy Schrapel
5+
*
6+
* This code is licensed under the MIT license
7+
*
8+
* https://github.com/visrealm/pico-56
9+
*
10+
*/
11+
12+
#include "pico/stdlib.h"
13+
#include "hardware/pio.h"
14+
#include "hardware/clocks.h"
15+
#include "blink.pio.h"
16+
17+
void blinkPinForever(PIO pio, uint offset, uint pin, float freq);
18+
19+
int main() {
20+
21+
uint offset = pio_add_program(pio0, &blink_program);
22+
23+
blinkPinForever(pio0, offset, PICO_DEFAULT_LED_PIN, 4.0f);
24+
25+
// here we can do whatever we want. the led will continue to blink
26+
27+
return 0;
28+
}
29+
30+
void blinkPinForever(PIO pio, uint offset, uint pin, float freq) {
31+
uint sm = pio_claim_unused_sm(pio, true);
32+
33+
blink_program_init(pio, sm, offset, pin);
34+
pio_sm_set_enabled(pio, sm, true);
35+
36+
uint delay = (uint)(clock_get_hz(clk_sys) / (2.0f * freq)) - 3.0f;
37+
38+
pio_sm_put(pio, sm, delay);
39+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(PROGRAM ${EPISODE}-02-pio-dma-blink)
2+
3+
add_executable(${PROGRAM})
4+
5+
target_sources(${PROGRAM} PRIVATE main.c)
6+
7+
# generate header file from pio
8+
pico_generate_pio_header(${PROGRAM} ${CMAKE_CURRENT_LIST_DIR}/dma-blink.pio)
9+
10+
pico_add_extra_outputs(${PROGRAM})
11+
12+
target_link_libraries(${PROGRAM} PRIVATE pico_stdlib hardware_pio hardware_dma)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Project: pico-56
3+
*
4+
* Copyright (c) 2023 Troy Schrapel
5+
*
6+
* This code is licensed under the MIT license
7+
*
8+
* https://github.com/visrealm/pico-56
9+
*
10+
*/
11+
12+
.program blink
13+
.wrap_target
14+
set pins, 1
15+
pull block
16+
mov x, osr
17+
onDelay:
18+
jmp x-- onDelay
19+
20+
set pins, 0
21+
pull block
22+
mov x, osr
23+
offDelay:
24+
jmp x-- offDelay
25+
.wrap
26+
27+
28+
% c-sdk {
29+
30+
void blink_program_init(PIO pio, uint sm, uint offset, uint pin) {
31+
pio_gpio_init(pio, pin);
32+
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
33+
pio_sm_config c = blink_program_get_default_config(offset);
34+
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
35+
sm_config_set_set_pins(&c, pin, 1);
36+
pio_sm_init(pio, sm, offset, &c);
37+
}
38+
%}

0 commit comments

Comments
 (0)