12
|
1 ;
|
|
2 ; Copyright (c) 2025 Daniel O'Connor
|
|
3 ;
|
|
4
|
|
5 .program trigger
|
|
6 .define TRIGGER_IRQ 0
|
|
7
|
|
8 .wrap_target
|
|
9 ; Wait for trigger to be low
|
|
10 wait 0 pin 0
|
|
11 ; Wait for rising edge
|
|
12 wait 1 pin 0
|
|
13 ; Signal other state machine
|
|
14 irq nowait TRIGGER_IRQ
|
|
15 .wrap
|
|
16
|
|
17 % c-sdk {
|
|
18 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);
|
|
20
|
|
21 // Configure SM input pin mapping to point to trigger pin
|
|
22 sm_config_set_in_pins(&c, pin);
|
|
23 // Set to input
|
|
24 pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, false);
|
|
25 // Connect this GPIO to this PIO block
|
|
26 pio_gpio_init(pio, pin);
|
|
27
|
|
28 sm_config_set_clkdiv(&c, clkdiv);
|
|
29
|
|
30 // Load our configuration, and start the program from the beginning
|
|
31 pio_sm_init(pio, sm, offset, &c);
|
|
32 pio_sm_set_enabled(pio, sm, true);
|
|
33 }
|
|
34 %}
|