RP2040 Helper Class
Some of the core functionality of the RP2040 chip powering the Raspberry Pi
Pico is exposed in the RP2040 class variable
Returns the current frequency of the core clock. This is read at runtime,
versus the constant
F_CPU macro that is also available. This is useful
in cases where your code changes the core clock (i.e. low power modes, etc.)
Returns the current core ID (0 or 1) of the executing task.
Returns a 32-bit cycle count from then the core started running. Because it is only 32-bits, and the Pico runs at 133MHz, this value can loop around in a matter of seconds.
Returns a 64-bit cycle count from then the core started running. This value should never loop around in normal mode (at 133MHz it would take over 4,000 years to overflow).
Returns a 32-bit value derived from the CPU cycle counter and the ROSC oscillator. Because the ROSC bit is not a true random number generator, the values returned may not meet the most stringent random tests. If your application needs absolute bulletproof random numbers, consider using dedicated external hardware.
Forces a hardware reboot of the Pico.
void rp2040.wdt_begin(uint32_t delay_ms)
Enables the hardware watchdog timer with a delay value of delay_ms milliseconds. Note that on the RP2040, once this function has called, the hardware watchdog can _not_ be disabled.
delay_ms allowed in this call is
to 8.3 seconds. Any higher values will be truncated by the hardware.
Reloads the watchdog’s counter with the amount of time set by wdt_begin.
Returns the number of bytes free for heap allocation (i.e. malloc, new). Note that because there is some overhead, and there may be heap fragmentation, this number is an upper bound and you generally will only be able to allocate less than this returned number.
Returns the number of bytes allocated out of the heap.
Returns the total heap that was available to this program at compile time (i.e.
the Pico RAM size minus things like the
.bss sections and other
Returns the core’s best guess if this code is running on a Raspberry Pi Pico W. This would let you, possibly, use the same UF2 for Pico and PicoW by simply not doing any WiFi calls.
Add a call anywhere in the sketch to
the core will check for a double-tap on reset, and if found will start the USB
Will reboot the RP2040 into USB UF2 upload mode.