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