I'm using pico-pio-usb as host on rp2040 on gpio pins 2,3. I've noticed a few issues which prevented the library from working correctly out of the box.
Both these functions have same issue, where t is no longer used to prevent inf loops after the first 2 bytes. I made a change locally to prevent inf loops here and it works well. As an aside, these functions have some other problems:
they do not return number of bytes read in all cases
they do not indicate error in all cases (e.g. timeout)
there is no max length check - rx buffer could be overflowed
t should probably not be constant and instead based on sys clk or something (I'm running the rp2040 at 240mhz)
probably more resilient to have timeout based on last rx'd byte instead of total, too.
16bit values are probably not good choice for "fast" code (it adds an extra instruction to sign-extend the value each loop iteration - just use something register-sized). int_fast16_t/uint_fast16_t also works for this.
I'm using pico-pio-usb as host on rp2040 on gpio pins 2,3. I've noticed a few issues which prevented the library from working correctly out of the box.
I've noticed that sometimes the code locks up. This is because there are infinite loops in the RX path. This is because the following code does not handle timeouts: https://github.com/sekigon-gonnoc/Pico-PIO-USB/blob/fe9133fc513b82cc3dc62c67cb51f2339cf29ef7/src/pio_usb.c#L161 https://github.com/sekigon-gonnoc/Pico-PIO-USB/blob/fe9133fc513b82cc3dc62c67cb51f2339cf29ef7/src/pio_usb.c#L195 https://github.com/sekigon-gonnoc/Pico-PIO-USB/blob/fe9133fc513b82cc3dc62c67cb51f2339cf29ef7/src/pio_usb.c#L215
Both these functions have same issue, where
t
is no longer used to prevent inf loops after the first 2 bytes. I made a change locally to prevent inf loops here and it works well. As an aside, these functions have some other problems:t
should probably not be constant and instead based on sys clk or something (I'm running the rp2040 at 240mhz)int_fast16_t
/uint_fast16_t
also works for this.