Mercurial > ~darius > hgwebdir.cgi > modulator
comparison trigger.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 | 283955273884 |
children | 6070d2e66b4c |
comparison
equal
deleted
inserted
replaced
23:3c713073dd0c | 24:c7845db23ab2 |
---|---|
1 ; | 1 ; |
2 ; Copyright (c) 2025 Daniel O'Connor | 2 ; Copyright (c) 2025 Daniel O'Connor |
3 ; | 3 ; |
4 | 4 |
5 .program trigger | 5 .program trigger |
6 .define TRIGGER_IRQ 0 | 6 .define DAC_TRIGGER_IRQ 0 |
7 .define CTRL_TRIGGER_IRQ 1 | |
8 ; Use 1 side set pin for debugging | |
9 .side_set 1 | |
7 | 10 |
8 .wrap_target | 11 .wrap_target |
9 ; Wait for trigger to be low | 12 ; Wait for trigger to be low |
10 wait 0 pin 0 | 13 wait 0 pin 0 side 0 |
11 ; Wait for rising edge | 14 ; Wait for rising edge |
12 wait 1 pin 0 | 15 wait 1 pin 0 side 0 |
13 ; Signal other state machine | 16 ; Signal other state machines |
14 irq nowait TRIGGER_IRQ | 17 irq nowait DAC_TRIGGER_IRQ side 1 |
18 irq nowait CTRL_TRIGGER_IRQ side 1 | |
15 .wrap | 19 .wrap |
16 | 20 |
17 % c-sdk { | 21 % c-sdk { |
18 static inline void trigger_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { | 22 static inline void trigger_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { |
19 pio_sm_config c = trigger_program_get_default_config(offset); | 23 pio_sm_config c = trigger_program_get_default_config(offset); |
23 // Set to input | 27 // Set to input |
24 pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, false); | 28 pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, false); |
25 // Connect this GPIO to this PIO block | 29 // Connect this GPIO to this PIO block |
26 pio_gpio_init(pio, pin); | 30 pio_gpio_init(pio, pin); |
27 | 31 |
32 // Configure side pin mapping to point to debug pin | |
33 sm_config_set_sideset_pins(&c, pin + 1); | |
34 // Set to output | |
35 pio_sm_set_consecutive_pindirs(pio, sm, pin + 1, 1, true); | |
36 // Connect this GPIO to this PIO block | |
37 pio_gpio_init(pio, pin + 1); | |
38 | |
28 sm_config_set_clkdiv(&c, clkdiv); | 39 sm_config_set_clkdiv(&c, clkdiv); |
29 | 40 |
30 // Load our configuration, and start the program from the beginning | 41 // Load our configuration, and start the program from the beginning |
31 pio_sm_init(pio, sm, offset, &c); | 42 pio_sm_init(pio, sm, offset, &c); |
32 pio_sm_set_enabled(pio, sm, true); | 43 pio_sm_set_enabled(pio, sm, true); |