7 #ifndef _PICO_PLATFORM_H
8 #define _PICO_PLATFORM_H
19 #include "hardware/platform_defs.h"
20 #include "hardware/regs/addressmap.h"
21 #include "hardware/regs/sio.h"
27 #ifndef PICO_STACK_SIZE
28 #define PICO_STACK_SIZE _u(0x800)
32 #ifndef PICO_HEAP_SIZE
33 #define PICO_HEAP_SIZE _u(0x800)
37 #ifndef PICO_NO_RAM_VECTOR_TABLE
38 #define PICO_NO_RAM_VECTOR_TABLE 0
42 #ifndef PICO_RP2040_B0_SUPPORTED
43 #define PICO_RP2040_B0_SUPPORTED 1
47 #ifndef PICO_FLOAT_SUPPORT_ROM_V1
48 #define PICO_FLOAT_SUPPORT_ROM_V1 1
52 #ifndef PICO_DOUBLE_SUPPORT_ROM_V1
53 #define PICO_DOUBLE_SUPPORT_ROM_V1 1
58 #ifndef PICO_RP2040_B1_SUPPORTED
59 #define PICO_RP2040_B1_SUPPORTED 1
63 #ifndef PICO_RP2040_B2_SUPPORTED
64 #define PICO_RP2040_B2_SUPPORTED 1
72 #include <sys/cdefs.h>
75 #define PICO_C_COMPILER_IS_CLANG 1
77 #define PICO_C_COMPILER_IS_GNU 1
79 #elif defined __ICCARM__
81 #define __aligned(x) __attribute__((__aligned__(x)))
83 #ifndef __always_inline
84 #define __always_inline __attribute__((__always_inline__))
87 #define __noinline __attribute__((__noinline__))
90 #define __packed __attribute__((__packed__))
93 #define __printflike(a, b)
96 #define __unused __attribute__((__unused__))
99 #define __used __attribute__((__used__))
102 #define __CONCAT1(a, b) a ## b
105 #define __CONCAT(a, b) __CONCAT1(a, b)
108 #define __STRING(a) #a
112 static inline uint __builtin_ctz(uint x) {
113 extern uint32_t __ctzsi2(uint32_t);
116 #define __builtin_expect(x, y) (x)
117 #define __builtin_isnan(x) __iar_isnan(x)
119 #error Unsupported toolchain
122 #include "pico/types.h"
126 #define GCC_Like_Pragma _Pragma
128 #define GCC_Like_Pragma(x)
133 #define Clang_Pragma _Pragma
135 #define Clang_Pragma(x)
139 #if PICO_C_COMPILER_IS_GNU
140 #define GCC_Pragma _Pragma
142 #define GCC_Pragma(x)
170 #define __after_data(group) __attribute__((section(".after_data." group)))
184 #define __not_in_flash(group) __attribute__((section(".time_critical." group)))
201 #define __scratch_x(group) __attribute__((section(".scratch_x." group)))
218 #define __scratch_y(group) __attribute__((section(".scratch_y." group)))
235 #define __uninitialized_ram(group) __attribute__((section(".uninitialized_data." #group))) group
249 #define __in_flash(group) __attribute__((section(".flashdata." group)))
265 #define __not_in_flash_func(func_name) __not_in_flash(__STRING(func_name)) func_name
284 #define __time_critical_func(func_name) __not_in_flash_func(func_name)
298 #define __no_inline_not_in_flash_func(func_name) __noinline __not_in_flash_func(func_name)
300 #define __packed_aligned __packed __aligned(4)
311 #if PICO_C_COMPILER_IS_GNU && (__GNUC__ <= 6 || (__GNUC__ == 7 && (__GNUC_MINOR__ < 3 || !defined(__cplusplus))))
312 #define __force_inline inline __always_inline
314 #define __force_inline __always_inline
321 #define count_of(a) (sizeof(a)/sizeof((a)[0]))
328 #define MAX(a, b) ((a)>(b)?(a):(b))
335 #define MIN(a, b) ((b)>(a)?(a):(b))
338 #define pico_default_asm(...) __asm (".syntax unified\n" __VA_ARGS__)
339 #define pico_default_asm_volatile(...) __asm volatile (".syntax unified\n" __VA_ARGS__)
345 pico_default_asm (
"bkpt #0");
361 pico_default_asm_volatile (
"" : : :
"memory");
372 #define host_safe_hw_ptr(x) ((uintptr_t)(x))
373 #define native_safe_hw_ptr(x) host_safe_hw_ptr(x)
391 void __attribute__((noreturn))
panic(
const char *fmt, ...);
394 #define panic_compact(...) panic(__VA_ARGS__)
396 #define panic_compact(...) panic("")
400 #ifndef PICO_NO_FPGA_CHECK
401 #define PICO_NO_FPGA_CHECK 0
404 #if PICO_NO_FPGA_CHECK
405 static inline bool running_on_fpga(
void) {
return false;}
407 bool running_on_fpga(
void);
421 GCC_Pragma(
"GCC diagnostic push")
422 GCC_Pragma(
"GCC diagnostic ignored \"-Warray-bounds\"")
423 return *(uint8_t*)0x13;
424 GCC_Pragma(
"GCC diagnostic pop")
447 pico_default_asm (
"muls %0, %1" :
"+l" (a) :
"l" (b) : );
464 #define __fast_mul(a, b) __builtin_choose_expr(__builtin_constant_p(b) && !__builtin_constant_p(a), \
465 (__builtin_popcount(b) >= 2 ? __mul_instruction(a,b) : (a)*(b)), \
474 #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));
483 pico_default_asm(
"mrs %0, ipsr" :
"=l" (exception));
487 #define WRAPPER_FUNC(x) __wrap_ ## x
488 #define REAL_FUNC(x) __real_ ## x
505 pico_default_asm_volatile(
508 :
"+l" (minimum_cycles) : :
"memory"
518 return (*(uint32_t *) (SIO_BASE + SIO_CPUID_OFFSET));
530 #define PICO_ASSEMBLER_IS_CLANG 1
532 #define PICO_ASSEMBLER_IS_GNU 1
534 #elif defined __ICCARM__
536 #error Unsupported toolchain
539 #define WRAPPER_FUNC_NAME(x) __wrap_##x
540 #define SECTION_NAME(x) .text.##x
541 #define RAM_SECTION_NAME(x) .time_critical.##x