Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cores/rp2040/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ extern "C" {
void interrupts();
void noInterrupts();

// Only implemented on some RP2350 boards, not the OG Pico 2
#ifdef RP2350_PSRAM_CS
void *pmalloc(size_t size);
void *pcalloc(size_t count, size_t size);
#else
[[deprecated("This chip does not have PSRAM, pmalloc will always fail")]] void *pmalloc(size_t size);
[[deprecated("This chip does not have PSRAM, pcalloc will always fail")]] void *pcalloc(size_t count, size_t size);
#endif


// AVR compatibility macros...naughty and accesses the HW directly
#define digitalPinToPort(pin) (0)
#define digitalPinToBitMask(pin) (1UL << (pin))
Expand Down
6 changes: 3 additions & 3 deletions cores/rp2040/RP2040Support.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class RP2040 {
}

inline int getUsedPSRAMHeap() {
#if defined(PICO_RP2350)
#if defined(RP2350_PSRAM_CS)
extern size_t __psram_total_used();
return __psram_total_used();
#else
Expand All @@ -262,7 +262,7 @@ class RP2040 {
}

inline int getTotalPSRAMHeap() {
#if defined(PICO_RP2350)
#if defined(RP2350_PSRAM_CS)
extern size_t __psram_total_space();
return __psram_total_space();
#else
Expand Down Expand Up @@ -290,7 +290,7 @@ class RP2040 {
}

inline size_t getPSRAMSize() {
#if defined(PICO_RP2350)
#if defined(RP2350_PSRAM_CS)
extern size_t __psram_size;
return __psram_size;
#else
Expand Down
9 changes: 9 additions & 0 deletions cores/rp2040/malloc-lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ extern "C" void *pcalloc(size_t count, size_t size) {
interrupts();
return rc;
}
#else
// No PSRAM, always fail
extern "C" void *pmalloc(size_t size) {
return nullptr;
}

extern "C" void *pcalloc(size_t count, size_t size) {
return nullptr;
}
#endif

extern "C" void *__wrap_realloc(void *mem, size_t size) {
Expand Down
2 changes: 1 addition & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ OUTPUT_12MA LITERAL1

ARDUINO_ARCH_RP2040 LITERAL1

PRAM LITERAL1
PSRAM LITERAL1