Fix autopull on PIO0 using SDK setup functions.

This commit is contained in:
giomba 2022-10-13 22:05:49 +02:00
parent 151afb08b0
commit 6b6b76b212
2 changed files with 16 additions and 17 deletions

View File

@ -35,21 +35,17 @@ static Frame frames[FRAMES] = {0};
static void vga_pixel_program_init(PIO pio, uint sm, uint offset) static void vga_pixel_program_init(PIO pio, uint sm, uint offset)
{ {
// magic definition of the called function? // magic definition of the called function?
pio_sm_config c = vga_free_run_program_get_default_config(offset); pio_sm_config config = vga_free_run_program_get_default_config(offset);
// destination pins for OUT instructions // destination pins for OUT instructions
sm_config_set_out_pins(&c, 22, 1); sm_config_set_out_pins(&config, 22, 1);
sm_config_set_out_shift(&config, true, true, 0);
pio_gpio_init(pio, 22); pio_gpio_init(pio, 22);
pio_sm_set_consecutive_pindirs(pio, sm, 22, 1, true); pio_sm_set_consecutive_pindirs(pio, sm, 22, 1, true);
pio_sm_init(pio, sm, offset, &c); pio_sm_init(pio, sm, offset, &config);
pio_sm_set_clkdiv_int_frac(pio, sm, 1, 0); pio_sm_set_clkdiv_int_frac(pio, sm, 1, 0);
pio->sm->shiftctrl = (1 << PIO_SM0_SHIFTCTRL_FJOIN_TX_LSB) |
(1 << PIO_SM0_SHIFTCTRL_OUT_SHIFTDIR_LSB) |
(1 << PIO_SM0_SHIFTCTRL_OUT_SHIFTDIR_LSB) |
(1 << PIO_SM0_SHIFTCTRL_AUTOPULL_LSB);
pio_sm_set_enabled(pio, sm, true); pio_sm_set_enabled(pio, sm, true);
} }
@ -109,12 +105,6 @@ int main()
sleep_ms(5000); sleep_ms(5000);
// VGA pixel program
uint offset0 = pio_add_program(pio, &vga_free_run_program);
uint sm0 = pio_claim_unused_sm(pio, true);
printf("Starting VGA pixel machine on %u...\n", sm0);
vga_pixel_program_init(pio, sm0, offset0);
// VGA HSYNC program // VGA HSYNC program
uint offset1 = pio_add_program(pio, &vga_hsync_program); uint offset1 = pio_add_program(pio, &vga_hsync_program);
uint sm1 = pio_claim_unused_sm(pio, true); uint sm1 = pio_claim_unused_sm(pio, true);
@ -135,6 +125,12 @@ int main()
pio_sm_put_blocking(pio, sm2, 3 - 1); pio_sm_put_blocking(pio, sm2, 3 - 1);
pio_sm_put_blocking(pio, sm2, 500 - 3 - 1); pio_sm_put_blocking(pio, sm2, 500 - 3 - 1);
// VGA pixel program
uint offset0 = pio_add_program(pio, &vga_free_run_program);
uint sm0 = pio_claim_unused_sm(pio, true);
printf("Starting VGA pixel machine on %u...\n", sm0);
vga_pixel_program_init(pio, sm0, offset0);
printf("Start!\n"); printf("Start!\n");
while (true) while (true)
@ -142,8 +138,10 @@ int main()
for (size_t i = 0; i < sizeof(frames[0].data);) for (size_t i = 0; i < sizeof(frames[0].data);)
{ {
// feed pixel machine // feed pixel machine
if (!pio_sm_is_tx_fifo_full(pio, sm0))
pio_sm_put_blocking(pio, sm0, frames[0].data[i++]); pio_sm_put_blocking(pio, sm0, frames[0].data[i++]);
} // printf("%d.", i);
}
// sleep_ms(1000);
// printf(".");
} }
} }

View File

@ -1,9 +1,10 @@
.program vga_free_run .program vga_free_run
entrypoint_vga_free_run: entrypoint_vga_free_run:
pull
loop: loop:
out pins, 1 [2] out pins, 1 [2]
nop
nop
jmp loop jmp loop
.program vga_hsync .program vga_hsync