1
0
Fork 0

clean up pio

sd2
radex 2024-05-30 11:47:15 +02:00
parent d43bdba36e
commit dfaf256926
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
2 changed files with 22 additions and 19 deletions

View File

@ -1,45 +1,49 @@
.define public irq_did_latch 0
.define public irq_delaying 1
; TODO: check if delays can be lowered with a PCB
.define public srclk_0_delay 1
.define public srclk_1_delay 2
.define public rclk_1_delay 3
.program leds_px_pusher
.side_set 1 opt
public entry_point:
entry_point:
.wrap_target
; get 32 bits from fifo (not required with autopull, useful for debug)
; pull
; push 24 bits to the shift registers
; also, return latch bit to 0
set x, 23 side 0
set x, 23 side 0
loop:
; TODO: check if delays can be lowered with a PCB
; set bit; lower clock edge
out pins, 1 side 0 [1]
out pins, 1 side 0 [srclk_0_delay]
; loop; latch bit (rising edge)
jmp x-- loop side 1 [2]
jmp x-- loop side 1 [srclk_1_delay]
end:
; ignore unused bits
; load MSBs into x
; lower clock edge
out x, 8 side 0
; MSB=1 indicates end of row
jmp x-- end_of_row
.wrap
jmp !x entry_point
end_of_row:
; wait until previous row's delay is complete
wait 0 irq irq_delaying
; signal that row is processed
irq set irq_did_latch
; clock RCLK (latch onto register output stage)
set pins, 1 [3]
set pins, 1 [rclk_1_delay]
set pins, 0
; wait for next row
jmp entry_point
.wrap
.program leds_delay
.side_set 1 opt
.define public output_on 0
.define public output_off 1
public entry_point:
entry_point:
.wrap_target
; begin only after data is latched
wait 1 irq irq_did_latch
; signal that delay is ongoing
@ -54,3 +58,4 @@ end:
; signal that delay is complete
; disable output
irq clear irq_delaying side output_off
.wrap

View File

@ -10,15 +10,16 @@
#define irq_did_latch 0
#define irq_delaying 1
#define srclk_0_delay 1
#define srclk_1_delay 2
#define rclk_1_delay 3
// -------------- //
// leds_px_pusher //
// -------------- //
#define leds_px_pusher_wrap_target 0
#define leds_px_pusher_wrap 4
#define leds_px_pusher_offset_entry_point 0u
#define leds_px_pusher_wrap 8
static const uint16_t leds_px_pusher_program_instructions[] = {
// .wrap_target
@ -26,19 +27,18 @@ static const uint16_t leds_px_pusher_program_instructions[] = {
0x7101, // 1: out pins, 1 side 0 [1]
0x1a41, // 2: jmp x--, 1 side 1 [2]
0x7028, // 3: out x, 8 side 0
0x0045, // 4: jmp x--, 5
// .wrap
0x0020, // 4: jmp !x, 0
0x2041, // 5: wait 0 irq, 1
0xc000, // 6: irq nowait 0
0xe301, // 7: set pins, 1 [3]
0xe000, // 8: set pins, 0
0x0000, // 9: jmp 0
// .wrap
};
#if !PICO_NO_HARDWARE
static const struct pio_program leds_px_pusher_program = {
.instructions = leds_px_pusher_program_instructions,
.length = 10,
.length = 9,
.origin = -1,
};
@ -60,8 +60,6 @@ static inline pio_sm_config leds_px_pusher_program_get_default_config(uint offse
#define leds_delay_output_on 0
#define leds_delay_output_off 1
#define leds_delay_offset_entry_point 0u
static const uint16_t leds_delay_program_instructions[] = {
// .wrap_target
0x20c0, // 0: wait 1 irq, 0