Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8026

General • PIO multiple input passthrough configuration

$
0
0
I'm trying to write a PIO program that simply takes one range of pins and passes it to another range of pins.

As described in this post (viewtopic.php?p=2133330), my program is a one-liner:

Code:

.program passthrough    mov pins, pins
With a single pin configured, this works perfectly. However, I can't seem to figure out how to apply this to multiple pins in a range. In my setup, I'm currently doing the following:

Code:

static inline void passthrough_program_init(PIO pio, uint sm, uint offset, uint in_base, uint out_base, uint pin_count) {    pio_sm_config conf = passthrough_program_get_default_config(offset);    for(uint i = 0u; i < pin_count; i++) {        pio_sm_set_in_pins(pio, sm, in_base + i);        pio_gpio_init(pio, in_base + i);        pio_gpio_init(pio, out_base + i);    }    // configure in pins    pio_sm_set_consecutive_pindirs(pio, sm, in_base, pin_count, false);    sm_config_set_in_pin_base(&conf, in_base);    sm_config_set_in_pin_count(&conf, pin_count);    // configure out pins    pio_sm_set_out_pins(pio, sm, out_base, pin_count);    pio_sm_set_consecutive_pindirs(pio, sm, out_base, pin_count, true);    sm_config_set_out_pins(&conf, out_base, pin_count);    pio_sm_init(pio, sm, offset, &conf);}
Again, this works well for a single pin, but not when I set the pin count to 2 or more. Only the first pin ever performs the passthrough.

On a somewhat related note:
Why do the 'sm_config_set_out_pins' and 'sm_config_set_set_pins' have a 'pin_count' parameter, but not 'sm_config_set_in_pins' even though a 'sm_config_set_in_pin_count' exists in the 'pio.h'?

Statistics: Posted by Lithimlin — Tue Oct 15, 2024 8:49 am



Viewing all articles
Browse latest Browse all 8026

Trending Articles