mirror of
https://github.com/radex/radmatrix.git
synced 2024-10-12 07:37:45 +00:00
clean up pio
This commit is contained in:
parent
d43bdba36e
commit
dfaf256926
2 changed files with 22 additions and 19 deletions
|
@ -1,9 +1,14 @@
|
||||||
.define public irq_did_latch 0
|
.define public irq_did_latch 0
|
||||||
.define public irq_delaying 1
|
.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
|
.program leds_px_pusher
|
||||||
.side_set 1 opt
|
.side_set 1 opt
|
||||||
public entry_point:
|
entry_point:
|
||||||
.wrap_target
|
.wrap_target
|
||||||
; get 32 bits from fifo (not required with autopull, useful for debug)
|
; get 32 bits from fifo (not required with autopull, useful for debug)
|
||||||
; pull
|
; pull
|
||||||
|
@ -11,35 +16,34 @@ public entry_point:
|
||||||
; also, return latch bit to 0
|
; also, return latch bit to 0
|
||||||
set x, 23 side 0
|
set x, 23 side 0
|
||||||
loop:
|
loop:
|
||||||
; TODO: check if delays can be lowered with a PCB
|
|
||||||
; set bit; lower clock edge
|
; set bit; lower clock edge
|
||||||
out pins, 1 side 0 [1]
|
out pins, 1 side 0 [srclk_0_delay]
|
||||||
; loop; latch bit (rising edge)
|
; loop; latch bit (rising edge)
|
||||||
jmp x-- loop side 1 [2]
|
jmp x-- loop side 1 [srclk_1_delay]
|
||||||
end:
|
end:
|
||||||
; ignore unused bits
|
; ignore unused bits
|
||||||
; load MSBs into x
|
; load MSBs into x
|
||||||
; lower clock edge
|
; lower clock edge
|
||||||
out x, 8 side 0
|
out x, 8 side 0
|
||||||
; MSB=1 indicates end of row
|
; MSB=1 indicates end of row
|
||||||
jmp x-- end_of_row
|
jmp !x entry_point
|
||||||
.wrap
|
|
||||||
end_of_row:
|
end_of_row:
|
||||||
; wait until previous row's delay is complete
|
; wait until previous row's delay is complete
|
||||||
wait 0 irq irq_delaying
|
wait 0 irq irq_delaying
|
||||||
; signal that row is processed
|
; signal that row is processed
|
||||||
irq set irq_did_latch
|
irq set irq_did_latch
|
||||||
; clock RCLK (latch onto register output stage)
|
; clock RCLK (latch onto register output stage)
|
||||||
set pins, 1 [3]
|
set pins, 1 [rclk_1_delay]
|
||||||
set pins, 0
|
set pins, 0
|
||||||
; wait for next row
|
; wait for next row
|
||||||
jmp entry_point
|
.wrap
|
||||||
|
|
||||||
.program leds_delay
|
.program leds_delay
|
||||||
.side_set 1 opt
|
.side_set 1 opt
|
||||||
.define public output_on 0
|
.define public output_on 0
|
||||||
.define public output_off 1
|
.define public output_off 1
|
||||||
public entry_point:
|
entry_point:
|
||||||
|
.wrap_target
|
||||||
; begin only after data is latched
|
; begin only after data is latched
|
||||||
wait 1 irq irq_did_latch
|
wait 1 irq irq_did_latch
|
||||||
; signal that delay is ongoing
|
; signal that delay is ongoing
|
||||||
|
@ -54,3 +58,4 @@ end:
|
||||||
; signal that delay is complete
|
; signal that delay is complete
|
||||||
; disable output
|
; disable output
|
||||||
irq clear irq_delaying side output_off
|
irq clear irq_delaying side output_off
|
||||||
|
.wrap
|
||||||
|
|
|
@ -10,15 +10,16 @@
|
||||||
|
|
||||||
#define irq_did_latch 0
|
#define irq_did_latch 0
|
||||||
#define irq_delaying 1
|
#define irq_delaying 1
|
||||||
|
#define srclk_0_delay 1
|
||||||
|
#define srclk_1_delay 2
|
||||||
|
#define rclk_1_delay 3
|
||||||
|
|
||||||
// -------------- //
|
// -------------- //
|
||||||
// leds_px_pusher //
|
// leds_px_pusher //
|
||||||
// -------------- //
|
// -------------- //
|
||||||
|
|
||||||
#define leds_px_pusher_wrap_target 0
|
#define leds_px_pusher_wrap_target 0
|
||||||
#define leds_px_pusher_wrap 4
|
#define leds_px_pusher_wrap 8
|
||||||
|
|
||||||
#define leds_px_pusher_offset_entry_point 0u
|
|
||||||
|
|
||||||
static const uint16_t leds_px_pusher_program_instructions[] = {
|
static const uint16_t leds_px_pusher_program_instructions[] = {
|
||||||
// .wrap_target
|
// .wrap_target
|
||||||
|
@ -26,19 +27,18 @@ static const uint16_t leds_px_pusher_program_instructions[] = {
|
||||||
0x7101, // 1: out pins, 1 side 0 [1]
|
0x7101, // 1: out pins, 1 side 0 [1]
|
||||||
0x1a41, // 2: jmp x--, 1 side 1 [2]
|
0x1a41, // 2: jmp x--, 1 side 1 [2]
|
||||||
0x7028, // 3: out x, 8 side 0
|
0x7028, // 3: out x, 8 side 0
|
||||||
0x0045, // 4: jmp x--, 5
|
0x0020, // 4: jmp !x, 0
|
||||||
// .wrap
|
|
||||||
0x2041, // 5: wait 0 irq, 1
|
0x2041, // 5: wait 0 irq, 1
|
||||||
0xc000, // 6: irq nowait 0
|
0xc000, // 6: irq nowait 0
|
||||||
0xe301, // 7: set pins, 1 [3]
|
0xe301, // 7: set pins, 1 [3]
|
||||||
0xe000, // 8: set pins, 0
|
0xe000, // 8: set pins, 0
|
||||||
0x0000, // 9: jmp 0
|
// .wrap
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !PICO_NO_HARDWARE
|
#if !PICO_NO_HARDWARE
|
||||||
static const struct pio_program leds_px_pusher_program = {
|
static const struct pio_program leds_px_pusher_program = {
|
||||||
.instructions = leds_px_pusher_program_instructions,
|
.instructions = leds_px_pusher_program_instructions,
|
||||||
.length = 10,
|
.length = 9,
|
||||||
.origin = -1,
|
.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_on 0
|
||||||
#define leds_delay_output_off 1
|
#define leds_delay_output_off 1
|
||||||
|
|
||||||
#define leds_delay_offset_entry_point 0u
|
|
||||||
|
|
||||||
static const uint16_t leds_delay_program_instructions[] = {
|
static const uint16_t leds_delay_program_instructions[] = {
|
||||||
// .wrap_target
|
// .wrap_target
|
||||||
0x20c0, // 0: wait 1 irq, 0
|
0x20c0, // 0: wait 1 irq, 0
|
||||||
|
|
Loading…
Reference in a new issue