pico-extras icon indicating copy to clipboard operation
pico-extras copied to clipboard

Missing import in sleep.h?

Open a-mueller opened this issue 8 months ago • 2 comments

I am pretty new to C so this might be stupid.

I am using a RP2040 and I am trying to go dormant. When using sleep_run_from_xosc it complains that hardware_alarm_callback_t is not defined in this scope. Adding #include "hardware/timer.h" to pico-extras/src/rp2_common/pico_sleep/include/pico/sleep.h will fix it but I am pretty sure some kind of test would have caught that the whole thing doesn't compile. Anything I am doing wrong here?

Thanks

a-mueller avatar Mar 03 '25 20:03 a-mueller

ping @peterharperuk as he was the last person to edit the pico_sleep code 😴 (in #79 ).

I am pretty sure some kind of test would have caught that the whole thing doesn't compile.

The code in pico-extras (and pico-playground) is unsupported / experimental, and so it gets much less testing than the code in pico-sdk and pico-examples.

lurch avatar Mar 04 '25 01:03 lurch

Yes, good catch. The test code builds fine but it has #include "pico/stdlib.h" before #include "pico/sleep.h" which includes "hardware/timer.h" for us. As a workaround just include it before including sleep.h and I'll push a fix.

peterharperuk avatar Mar 05 '25 16:03 peterharperuk