platform.h File Reference
#include "hardware/platform_defs.h"
#include "hardware/regs/addressmap.h"
#include "hardware/regs/sio.h"
#include <sys/cdefs.h>
#include "pico/types.h"
Include dependency graph for platform.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PICO_RP2040   1
 
#define PICO_STACK_SIZE   _u(0x800)
 
#define PICO_HEAP_SIZE   _u(0x800)
 
#define PICO_NO_RAM_VECTOR_TABLE   0
 
#define PICO_RP2040_B0_SUPPORTED   1
 
#define PICO_FLOAT_SUPPORT_ROM_V1   1
 
#define PICO_DOUBLE_SUPPORT_ROM_V1   1
 
#define PICO_RP2040_B1_SUPPORTED   1
 
#define PICO_RP2040_B2_SUPPORTED   1
 
#define __isr
 Marker for an interrupt handlerFor example an IRQ handler function called my_interrupt_handler: More...
 
#define __after_data(group)   __attribute__((section(".after_data." group)))
 Section attribute macro for placement in RAM after the .data sectionFor example a 400 element uint32_t array placed after the .data section. More...
 
#define __not_in_flash(group)   __attribute__((section(".time_critical." group)))
 Section attribute macro for placement not in flash (i.e in RAM)For example a 3 element uint32_t array placed in RAM (even though it is static const) More...
 
#define __scratch_x(group)   __attribute__((section(".scratch_x." group)))
 Section attribute macro for placement in the SRAM bank 4 (known as "scratch X")Scratch X is commonly used for critical data and functions accessed only by one core (when only one core is accessing the RAM bank, there is no opportunity for stalls) More...
 
#define __scratch_y(group)   __attribute__((section(".scratch_y." group)))
 Section attribute macro for placement in the SRAM bank 5 (known as "scratch Y")Scratch Y is commonly used for critical data and functions accessed only by one core (when only one core is accessing the RAM bank, there is no opportunity for stalls) More...
 
#define __uninitialized_ram(group)   __attribute__((section(".uninitialized_data." #group))) group
 Section attribute macro for data that is to be left uninitializedData marked this way will retain its value across a reset (normally uninitialized data - in the .bss section) is initialized to zero during runtime initialization. More...
 
#define __in_flash(group)   __attribute__((section(".flashdata." group)))
 Section attribute macro for placement in flash even in a COPY_TO_RAM binaryFor example a uint32_t variable explicitly placed in flash (it will hard fault if you attempt to write it!) More...
 
#define __not_in_flash_func(func_name)   __not_in_flash(__STRING(func_name)) func_name
 Indicates a function should not be stored in flashDecorates a function name, such that the function will execute from RAM (assuming it is not inlined into a flash function by the compiler) More...
 
#define __time_critical_func(func_name)   __not_in_flash_func(func_name)
 Indicates a function is time/latency critical and should not run from flashDecorates a function name, such that the function will execute from RAM (assuming it is not inlined into a flash function by the compiler) to avoid possible flash latency. Currently this macro is identical in implementation to __not_in_flash_func, however the semantics are distinct and a __time_critical_func may in the future be treated more specially to reduce the overhead when calling such function from a flash function. More...
 
#define __no_inline_not_in_flash_func(func_name)   __noinline __not_in_flash_func(func_name)
 Indicate a function should not be stored in flash and should not be inlinedDecorates a function name, such that the function will execute from RAM, explicitly marking it as noinline to prevent it being inlined into a flash function by the compiler. More...
 
#define __packed_aligned   __packed __aligned(4)
 
#define __force_inline   __always_inline
 Attribute to force inlining of a function regardless of optimization levelFor example my_function here will always be inlined: More...
 
#define count_of(a)   (sizeof(a)/sizeof((a)[0]))
 Macro to determine the number of elements in an array.
 
#define MAX(a, b)   ((a)>(b)?(a):(b))
 Macro to return the maximum of two comparable values.
 
#define MIN(a, b)   ((b)>(a)?(a):(b))
 Macro to return the minimum of two comparable values.
 
#define host_safe_hw_ptr(x)   ((uintptr_t)(x))
 Macro for converting memory addresses to 32 bit addresses suitable for DMAThis is just a cast to uintptr_t on the RP2040, however you may want to use this when developing code that also runs in "host" mode. If the host mode is 64 bit and you are embedding data pointers in other data (e.g. DMA chaining), then there is a need in "host" mode to convert a 64 bit native pointer to a 32 bit value for storage, which can be done using this macro.
 
#define native_safe_hw_ptr(x)   host_safe_hw_ptr(x)
 
#define panic_compact(...)   panic("")
 
#define PICO_NO_FPGA_CHECK   0
 
#define __fast_mul(a, b)
 multiply two integer values using the fastest method possibleEfficiently multiplies value a by possibly constant value b. More...
 
#define __check_type_compatible(type_a, type_b)   static_assert(__builtin_types_compatible_p(type_a, type_b), __STRING(type_a) " is not compatible with " __STRING(type_b));
 Utility macro to assert two types are equivalent.This macro can be useful in other macros along with typeof to assert that two parameters are of equivalent type (or that a single parameter is of an expected type)
 
#define WRAPPER_FUNC(x)   __wrap_ ## x
 
#define REAL_FUNC(x)   __real_ ## x
 

Functions

static void __breakpoint (void)
 Execute a breakpoint instruction.
 
static __always_inline void __compiler_memory_barrier (void)
 Ensure that the compiler does not move memory access across this method callFor example in the following code: More...
 
void panic_unsupported (void)
 Panics with the message "Unsupported". More...
 
void panic (const char *fmt,...)
 Displays a panic message and halts executionAn attempt is made to output the message to all registered STDOUT drivers after which this method executes a BKPT instruction. More...
 
bool running_on_fpga (void)
 
uint8_t rp2040_chip_version (void)
 Returns the RP2040 chip revision number. More...
 
static uint8_t rp2040_rom_version (void)
 Returns the RP2040 rom version number. More...
 
static __always_inline void tight_loop_contents (void)
 No-op function for the body of tight loopsNo-op function intended to be called by any tight hardware polling loop. Using this ubiquitously makes it much easier to find tight loops, but also in the future #ifdef-ed support for lockup debugging might be added.
 
static __always_inline int32_t __mul_instruction (int32_t a, int32_t b)
 Multiply two integers using an assembly MUL instructionThis multiplies a by b using multiply instruction using the ARM mul instruction regardless of values (the compiler might otherwise choose to perform shifts/adds), i.e. this is a 1 cycle operation. More...
 
static uint __get_current_exception (void)
 Get the current exception level on this core. More...
 
static void busy_wait_at_least_cycles (uint32_t minimum_cycles)
 Helper method to busy-wait for at least the given number of cyclesThis method is useful for introducing very short delays. More...
 
static __always_inline uint get_core_num (void)
 Get the current core number. More...