Closed abauske closed 2 years ago
I don't have my test setup immediately available, but does the following change to the can2040.c code resolve the issue?
--- a/src/can2040.c
+++ b/src/can2040.c
@@ -368,8 +368,6 @@ pio_sm_setup(struct can2040 *cd)
pio_hw->ctrl = 0x07 << PIO_CTRL_SM_ENABLE_LSB;
}
-#define PIO_FUNC 6
-
// Initial setup of gpio pins and PIO state machines
static void
pio_setup(struct can2040 *cd, uint32_t sys_clock, uint32_t bitrate)
@@ -389,8 +387,9 @@ pio_setup(struct can2040 *cd, uint32_t sys_clock, uint32_t bitrate)
pio_sm_setup(cd);
// Map Rx/Tx gpios
- rp2040_gpio_peripheral(cd->gpio_rx, PIO_FUNC, 1);
- rp2040_gpio_peripheral(cd->gpio_tx, PIO_FUNC, 0);
+ uint32_t pio_func = cd->pio_num ? 7 : 6;
+ rp2040_gpio_peripheral(cd->gpio_rx, pio_func, 1);
+ rp2040_gpio_peripheral(cd->gpio_tx, pio_func, 0);
}
-Kevin
I will try next two days and report back
Yeah! That makes the trick! Thanks for the quick solution!
Thanks. I committed the corresponding change (commit e60fbf65).
-Kevin
Hi, thanks for this great implementation! I am, however, struggling to get PIO1 to work (minimal example code see down below). PIO0 works fine but as soon as I set pio_num to 1 (2nd argument in can2040_setup call) and change irq nums from PIO0_IRQ_0 to PIO1_IRQ_0 (in all three lines after "Enable irqs" comment) its not working. I checked using an Oszilloscope: I don't even see any initial signal edges (e.g. of first bit). Do you see any problem in my code? Is it a problem of this project? Is it a usage error?
Cheers, Adrian