Mercurial > ~darius > hgwebdir.cgi > modulator
annotate ctrl.pio @ 24:c7845db23ab2
Add sideset for trigger output.
Trigger both SMs
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Tue, 25 Feb 2025 16:47:00 +1030 |
parents | 8d759cf5a9e7 |
children | 6070d2e66b4c |
rev | line source |
---|---|
16 | 1 ; |
2 ; Copyright (c) 2025 Daniel O'Connor | |
3 ; | |
4 | |
5 .program ctrl | |
21
8d759cf5a9e7
Load correct program, use a separate IRQ
Daniel O'Connor <darius@dons.net.au>
parents:
18
diff
changeset
|
6 .define TRIGGER_IRQ 1 |
16 | 7 ; Assert all 0s |
8 mov pins, null | |
9 ; Wait for start trigger and clear IRQ | |
10 wait 1 irq TRIGGER_IRQ | |
11 .wrap_target | |
12 out pins 8 | |
13 nop | |
14 out pins 8 | |
15 nop | |
16 out pins 8 | |
17 nop | |
18 out pins 8 | |
19 nop | |
20 .wrap | |
21 | |
22 % c-sdk { | |
23 static inline void ctrl_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { | |
21
8d759cf5a9e7
Load correct program, use a separate IRQ
Daniel O'Connor <darius@dons.net.au>
parents:
18
diff
changeset
|
24 pio_sm_config c = ctrl_program_get_default_config(offset); |
16 | 25 |
26 // Set the OUT base pin to the provided `pin` parameter. | |
27 // Note: We only need 6 pins but pull a byte at a time to make | |
28 // generating the data simpler | |
29 sm_config_set_out_pins(&c, pin, 6); | |
30 // Set the pin directions to output at the PIO | |
31 pio_sm_set_consecutive_pindirs(pio, sm, pin, 6, true); | |
32 // Connect these GPIOs to this PIO block | |
33 for (int i = 0; i < 6; i++) | |
34 pio_gpio_init(pio, pin + i); | |
35 | |
36 sm_config_set_out_shift( | |
37 &c, | |
38 true, // Shift-to-right | |
39 true, // Autopull enabled | |
40 32 // Autopull threshold (bits!) | |
41 ); | |
42 | |
43 // We only send, so disable the RX FIFO to make the TX FIFO deeper. | |
44 sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); | |
45 | |
46 sm_config_set_clkdiv(&c, clkdiv); | |
47 | |
48 // Load our configuration, and start the program from the beginning | |
49 pio_sm_init(pio, sm, offset, &c); | |
50 pio_sm_set_enabled(pio, sm, true); | |
51 } | |
52 %} |