-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpu/rpx0xx: initial PIO support #17425
Conversation
Great work! I'm waiting for this device as I have some plans for WS2812B project ... and my old Arduino UNO is far too small. However, I have some doubts if manual downloading of tools outside RIOT directory is a good idea. In my last PR 17348, I added makefiles that automatically download pico-SDK, compile elf2uf2 tool and copy it to the appropriate directory. Maybe such a solution could be useful. Look at RIOT/makefiles/tools/targets.inc.mk (end of file, section concerning elf2uf2) and |
After w few days working with this code, I have two questions/suggestions.
This code is similar to this micro-python code or a little more complicated from pico-examples blink. I purposely changed LOW and HIGH levels and added jmp instruction - because during my test, I suspected that my code is executed only once. My success is that the presented code switch LED on. However, even adding additional jmp instruction does not blink. When I used the most common idea - first set the pin to HIGH and later to LOW - I haven't noticed anything - maybe LED blink by a very short while - but I didn't notice this. Below is a list of used functions and structures; however, I used them without details. Is there missing some critical function? Any ideas why the PIO program is executed only once?
|
First of all thank you for testing!
I believe you set up the pin correctly but just to exclude the case that you didn´t, here is how it worked for me. static void pio_blink_init_pins(pio_t pio, pio_sm_t sm, gpio_t pin)
{
const gpio_io_ctrl_t io_ctrl = {
.function_select = pio ? FUNCTION_SELECT_PIO1 : FUNCTION_SELECT_PIO0
};
gpio_set_io_config(pin, io_ctrl); /* set alternate fuction of "pin" */
pio_sm_set_set_pins(pio, sm, pin, 1); /* set pin mapping starts at "pin" */
pio_sm_exec_block(pio, sm, pio_inst_set(PIO_INST_SET_DST_PINDIRS, 0x1)); /* make "pin" an output pin */
} |
Thank you for your detailed response.
|
Hey, running the testing procedure as you described I get the following error output: 2022-01-12 21:49:54,166 # main(): This is RIOT! (Version: 2019.10-devel-15051-gc89b5-rp2040_PIO)
2022-01-12 21:49:54,166 # Starting tests for module at24cxxx
2022-01-12 21:49:54,166 # EEPROM size: 32768 byte
2022-01-12 21:49:54,166 # Page size : 64 byte
2022-01-12 21:49:54,166 # [SUCCESS] at24cxxx_init
2022-01-12 21:49:54,167 # [FAILURE] at24cxxx_write_byte: -6
2022-01-12 21:50:00,400 # Exiting Pyterm Any idea whats going wrong ? |
You could get this if you for example have not specified: |
Ahh yes I mixed up some pins ... :S. Works now, thanks ! |
cpu/rpx0xx/pio/i2c/i2c.c
Outdated
gpio_set_pad_config(scl, pad_ctrl); | ||
gpio_set_pad_config(sda, pad_ctrl); | ||
|
||
pio_sm_exec_block(pio, sm, pio_inst_set(PIO_INST_SET_DST_PINS, 0x3)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this here needs some text to be understand able, thus why first writenig 3 then 0 again....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also works without set pins 3
and later set pins 0
. But the pico SDK does it like that too.
I guess that is what they mean with "avoid glitching". I now have copied their comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my problem has, i did not knew that I have to setup my pio pins as output manually (to just write to them with the "out" instruction), thus after hours in the end I ended up looking into mp and pico sdk what they do - thus some comment here would have helped me a lot. i guess the pio interface should have something like "init pin" as output.
When I have my code in a clean shape, I can drop it as an example, and maybe i also get a clue howto do a init pin function, or even getting this compile pio step bit cleaner... at the moment I believe its can be made more convenient.
I used pio in mp before and i was that clean and easy, some of that must be possible here too ;-)
Btw. I think I am going to squash. These |
bors merge |
Build failed: |
looks like a new issue this time 👍 It's getting closer |
yes ... 😅 I am thinking of two alternatives. |
I think option 2 would be good too. |
bors merge |
17425: cpu/rpx0xx: initial PIO support r=benpicco a=fabian18 19611: sys/net/rpl: fix possible NULL dereference r=benpicco a=maribu ### Contribution description As the title says 19640: core/thread: drop unused thread_arch_t r=benpicco a=maribu ### Contribution description No architecture makes use of thread_arch_t anymore, so let's drop it. Co-authored-by: Fabian Hüßler <fabian.huessler@st.ovgu.de> Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
Build failed (retrying...): |
Kconfig is unappy bors cancel |
Canceled. |
I forgot that there is a |
bors merge |
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
🚀 thx for the PR |
Thanks to all for your patience and good feedback! |
Congrats @fabian18 ! Thanks for your hard work ! |
Contribution description
This adds a new
periph
interface for Programmable IO(PIO)
and implements PIOfor the
rpi-pico
. To test basic functionality, there is a test application:tests/periph_pio/
. To test further, there is also aPIO
implementation forRIOTs
I2C
interface which should allow you to run tests forI2C
device drivers.We need the pioasm from the
pico-sdk
, to assemble PIO programs.I compiled the assembler and copied the binary to. It is downloaded from github and compiled during the build process if needed. The bash script should work with all PIO programs from pico-examples./usr/local/bin/pioasm
Testing procedure
See also logic analyzer output:
at24cxxx.zip
Issues/PRs references
#15822