I’m relatively new to the embedded systems domain and I’m trying to enable low power mode on my RPi Pico. I’ve found resources indicating that this can be achieved using the Pico-SDK (source1, source2). As such, I’ve decided to use this branch https://github.com/maxgerhardt/platform-raspberrypi.git which integrates both the Arduino framework and the Pico-SDK. I plan to include the <pico/sleep.h> and <hardware/rosc.h> headers and implement a solution similar to this one: https://github.com/earlephilhower/arduino-pico/issues/345#issuecomment-1465131731. Apologies, as a new user, I’m limited to including only two links in a post.
Is my approach to using the SDK functionalities correct or is there a better alternative that I might have missed?
If this is the right approach, I need to add the hardware_rosc and pico_sleep libraries. How can I do this? I understand they are part of pico-extras, but how can I incorporate them into my PlatformIO project?
If you want to keep using the Arduino framework in general, yes that’s right. The other way to use it by creating a Pico-SDK only project, using e.g. https://github.com/maxgerhardt/wizio-pico. This is however not updated anymore so you’d better use the native Pico-SDK CMake tooling instead.
You should be able to just copy-paste the source code files in the lib folder of the project, that is hardware_rosc as lib/hardware_rosc and pico_sleep to lib/pico_sleep.
FYI, if it was something in the Pico-SDK that you needed but Arduino-Pico didn’t include, the way to go would have been to modify the build files that generate libpico.a. Since this is in Pico-Extras however, this does not apply.
This works well and my Pico is now consuming very low power. However, I had to remove this line from pico_sleep.c because the setup_default_uart() function was not declared. This modification has caused my Serial communication to stop working after waking up. I’m still a bit unclear about the roles of Arduino-pico and Pico-SDK
After switching to your platform-raspberrypi fork, my arduino::UART disappeared. Without giving it much thought, I decided to use SerialUART. It usually works well, but due to the absence of function I mentioned before, it doesn’t work after waking up.
What is the optimal method to restart SerialUART and any other required components without having to reset the entire microcontroller?