Some of the core functionality of the RP2040 chip powering the Raspberry Pi
Pico is exposed in the RP2040 class variable rp2040
.
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.
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.
The maximum delay_ms
allowed in this call is 8300
, corresponding
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 reason for the last reset, defined in enum RP2040::resetReason_t
.
See example `ResetReason`
for some details.
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 .data
and .bss
sections and other
overhead).
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 rp2040.enableDoubleResetBootloader()
and
the core will check for a double-tap on reset, and if found will start the USB
bootloader.
Will reboot the RP2040 into USB UF2 upload mode.
The onboard DMA engines can copy 4-byte aligned quantities faster than the CPU.
Uses a DMA engine to transfer data from src to dest in 4-byte chunks without CPU intervention. If any arguments are not 4-byte aligned, or if the count is not a multiple of 4, then it will fall back to CPU-managed memcpy.