this is funky

This commit is contained in:
Benjamin Kyd
2021-06-20 16:12:57 +01:00
parent 4dc3f05c7c
commit f9f43874a4
2 changed files with 36 additions and 10 deletions

View File

@@ -1,22 +1,19 @@
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/pio.h"
// "assembled program"
#include "video.pio.h"
const uint OUTPIN = 1;
int main()
{
stdio_init_all();
gpio_init(OUTPIN);
gpio_set_dir(OUTPIN, 1);
while (1)
{
gpio_put(OUTPIN, 1);
}
PIO pio = pio0;
return 0;
}

View File

@@ -0,0 +1,29 @@
.program video
; recieve one word from TX FIFO (to the OSR)
; stall when FIFO empty
; pop the lsb in the out pin
loop:
pull
out pins, 1
jmp loop
% c-sdk {
static inline void video_program_init(PIO pio, uint sm, uint offset, uint pin) {
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);
}
%}