[DEV] RP2040 support

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
pbrena
Posts: 3
Joined: Wed Jun 07, 2023 5:09 am

Re: [DEV] RP2040 support

Postby pbrena » Wed Jun 07, 2023 5:24 am

Hello, is there a HAL I2S Driver? I’m having problems testing it:

./lib/chibios/os/hal/include/hal_i2s.h:84:10: fatal error: hal_i2s_lld.h: No such file or directory

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: [DEV] RP2040 support

Postby Giovanni » Wed Jun 07, 2023 10:57 am

Hi,

There is no I2S driver for RP2040 this is why you get that error.

Giovanni

electronic_eel
Posts: 77
Joined: Sat Mar 19, 2016 8:07 pm
Been thanked: 17 times

Re: [DEV] RP2040 support

Postby electronic_eel » Wed Jun 07, 2023 6:29 pm

Be aware that the RP2040 doesn't have I2S support in hardware. To implement I2S the most common way is to use a PIO unit and program it to implement I2S the way you need it.

As far as I'm aware this would be the first subsystem in ChibiOS HAL that utilizes the PIO units. So I think you'd need some HAL LLD layer first that configures the PIO units. On top of that you could then add a I2S PIO implementation that implements the regular HAL LLD for I2S. Also the toolchain to compile PIO assembler would have to be integrated.

Also be aware that using the PIO for I2S will result in a less flexible solution regarding clocking than the I2S hardware for example in a modern STM32. Meaning the RP2040 system clock will always have to provide the I2S master clock and this will lead to more jitter than using a dedicated low-jitter clock.

pbrena
Posts: 3
Joined: Wed Jun 07, 2023 5:09 am

Re: [DEV] RP2040 support

Postby pbrena » Wed Jun 07, 2023 10:41 pm

Thx a lot for your pointers.

Actually, I’m using QMK firmware for keyboard (which runs on ChibiOS) and I try to play low fidelity sounds in small mono speakers, so a limited clocking solution should be enough.

I’ve been said that a number of PIO code is around, I will try to adapt one of them...

About...
this would be the first subsystem in ChibiOS HAL that utilizes the PIO units
...causes me a doubt... could I use a “non chibios driver” ??? I thought I was restricted to use/modify chibios code.

...because QMK uses PIO for controlling RGB leds so (see https://docs.qmk.fm/#/ws2812_driver?id=pio) this must be non chibios code, right?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: [DEV] RP2040 support

Postby Giovanni » Thu Jun 08, 2023 9:00 am

Hi,

Of course you can use non-ChibiOS driver alongside ChibiOS ones, there are no restrictions.

Giovanni

electronic_eel
Posts: 77
Joined: Sat Mar 19, 2016 8:07 pm
Been thanked: 17 times

Re: [DEV] RP2040 support

Postby electronic_eel » Thu Jun 08, 2023 11:44 am

pbrena wrote:About...
this would be the first subsystem in ChibiOS HAL that utilizes the PIO units
...causes me a doubt... could I use a “non chibios driver” ??? I thought I was restricted to use/modify chibios code.

...because QMK uses PIO for controlling RGB leds so (see https://docs.qmk.fm/#/ws2812_driver?id=pio) this must be non chibios code, right?

My comment was regarding implementing this within ChibiOS HAL, in a way that would eventually allow it to be included in ChibiOS-Contrib(*). This would allow you to use the HAL I2S interface, making it easy to port this to another MCU.

You can of course always directly interface the hardware without using HAL. Porting this code to another MCU would be more work then, but a first implementation just for RP2040 is probably easier. I haven't investigated how the WS2812 driver in QMK you linked works.

*) Regarding ChibiOS-Contrib: be aware that I'm not member of the ChibiOS-Contrib team, don't have commit rights there and don't make any decisions regarding what is appropriate to commit there or not. So this is just my personal opinion.

pbrena
Posts: 3
Joined: Wed Jun 07, 2023 5:09 am

Re: [DEV] RP2040 support

Postby pbrena » Thu Jun 08, 2023 10:13 pm

I see... I’ll take a look and do my best


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 22 guests