Skip to content

Add rp2040 workarounds to avoid register warnings - #1395

Merged
kriegsman merged 5 commits into
FastLED:masterfrom
Zitt:rp2040
Nov 25, 2022
Merged

kriegsman merged 5 commits into
FastLED:masterfrom
Zitt:rp2040

Conversation

@Zitt

@Zitt Zitt commented Jun 4, 2022

Copy link
Copy Markdown
Contributor
  • add rp2040 platform
  • rp2040: fix some issues with fastpin/spi bitbanging (thread safety and accidental use of wrong reg for hival,loval)
  • rp2040: support using m0clockless output implementation for >8 strips
  • rp2040: switch to custom PIO program that doesn't use sideset avoiding sideset means that we double the max instruction delay, which should increase our timing resolution it also means that there's no longer a separately-licensed block of code included

somewhatlurker and others added 5 commits July 22, 2021 09:15
…d accidental use of wrong reg for hival,loval)
PIO-based/M0 generic implementation is controlled by FASTLED_RP2040_CLOCKLESS_PIO
it *should* be able to automatically fall back to m0clockless from PIO automatically,
but for some reason I'm having trouble getting that to work (requires more investigation, but at least this isn't a regression)

CPU frequency should be set in F_CPU or VARIANT_MCK before including FastLED if overclocking (for m0clockless only)
(becuase we need to know frequency at compile time, but pico sets it at runtime -- it might make sense to write a custom bitbang output to work around this)

PIO timing and clock divider is now automatically scaled from input CLOCKLESS_FREQUENCY to the fastest rate possible with the PIO program's delay slots
(this simplifies timing of m0clockless by having it use CPU frequency directly)
avoiding sideset means that we double the max instruction delay, which should increase our timing resolution
it also means that there's no longer a separately-licensed block of code included
@Zitt Zitt changed the title rp2040 Add rp2040 workarounds to avoid register warnings Jun 4, 2022
@Zitt

Zitt commented Jun 4, 2022

Copy link
Copy Markdown
Contributor Author

workarounds to suppress
warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
with https://github.com/earlephilhower/arduino-pico under Arduino 2.0.0-rc6.

@connornishijima

Copy link
Copy Markdown

Sure would love to use RP2040 on FastLED some time in the next century, lol.

@kriegsman
kriegsman merged commit 58f9c15 into FastLED:master Nov 25, 2022
@kriegsman

Copy link
Copy Markdown
Member

This is a great contribution -- thank you for the new platform support, and all the assistance getting it up and running! Thank you again for your help with FastLED!

@connornishijima

Copy link
Copy Markdown

FastLED is on a merging ROLL today, woohoo!

Any ETA for an official 3.6.x release with the new docs and RP2040 support?

@1988xd

1988xd commented Dec 4, 2022

Copy link
Copy Markdown

In file included from d:\Arduino\libraries\FastLED\src/FastLED.h:58,
from D:\Arduino\Raspberry Pi Pico\OneButtonTest\OneButtonTest.ino:4:
d:\Arduino\libraries\FastLED\src/fastpin.h:293:71: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
293 | inline static void fastset(REGISTER port_ptr_t port, register port_t val) attribute ((always_inline)) { }
| ^~~
In file included from d:\Arduino\libraries\FastLED\src/FastLED.h:59,
from D:\Arduino\Raspberry Pi Pico\OneButtonTest\OneButtonTest.ino:4:
d:\Arduino\libraries\FastLED\src/fastspi_types.h:44:105: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
44 | static attribute((always_inline)) inline uint8_t adjust(REGISTER uint8_t data, register uint8_t scale) { return scale8(data, scale); }
| ^~~~~
In file included from d:\Arduino\libraries\FastLED\src/platforms/arm/rp2040/fastled_arm_rp2040.h:5,
from d:\Arduino\libraries\FastLED\src/platforms.h:38,
from d:\Arduino\libraries\FastLED\src/FastLED.h:62,
from D:\Arduino\Raspberry Pi Pico\OneButtonTest\OneButtonTest.ino:4:
d:\Arduino\libraries\FastLED\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:28:42: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
28 | inline static void set(register port_t val) attribute ((always_inline)) { sio_hw->gpio_out = val; }
| ^~~
d:\Arduino\libraries\FastLED\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:34:45: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
34 | inline static void hi(register port_ptr_t port) attribute ((always_inline)) { hi(); }
| ^~~~
d:\Arduino\libraries\FastLED\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:35:45: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
35 | inline static void lo(register port_ptr_t port) attribute ((always_inline)) { lo(); }
| ^~~~
d:\Arduino\libraries\FastLED\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:36:50: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
36 | inline static void fastset(register port_ptr_t port, register port_t val) attribute ((always_inline)) { *port = val; }
| ^~~~
d:\Arduino\libraries\FastLED\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:36:72: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
36 | inline static void fastset(register port_ptr_t port, register port_t val) attribute ((always_inline)) { *port = val; }
| ^~~
In file included from d:\Arduino\libraries\FastLED\src/FastLED.h:75,
from D:\Arduino\Raspberry Pi Pico\OneButtonTest\OneButtonTest.ino:4:
d:\Arduino\libraries\FastLED\src/fastspi.h:172:23: note: '#pragma message: Forcing software SPI - no hardware SPI for you!'
172 | # pragma message "Forcing software SPI - no hardware SPI for you!"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@Dantali0n

Copy link
Copy Markdown

Looking forward to the new version release so I can try this out! Many thanks for your contribution and thank you maintainers for putting it all together.

@Dantali0n

Copy link
Copy Markdown

Is there any way in platformio to be able to already test this, I will get two arduino nano rp2040 connects in about 3 days.

@Kinue72

Kinue72 commented Dec 23, 2022 •

Copy link
Copy Markdown

Sorry but I can't compile with FASTLED_ALLOW_INTERRUPTS = 1

C:\Users\username\AppData\Local\Temp\cc8mt6TA.s: Assembler messages:
C:\Users\username\AppData\Local\Temp\cc8mt6TA.s:1299: Error: invalid offset, value too big (0x000004B0)
C:\Users\username\AppData\Local\Temp\cc8mt6TA.s:1305: Error: invalid offset, value too big (0x000004A8)
*** [.pio\build\pico\src\main.cpp.o] Error 1

But with FASTLED_ALLOW_INTERRUPTS = 0 it compiles just fine.

@Papa-DMan Papa-DMan mentioned this pull request Feb 6, 2023
5 of 11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants