From d77cff58dec1929ce96ba82fc2e660200c157917 Mon Sep 17 00:00:00 2001 From: Maximilian Gerhardt Date: Sun, 6 Oct 2024 16:51:05 +0200 Subject: [PATCH] Fix getStackPointer() to work in RISC-V and ARM mode --- cores/rp2040/RP2040Support.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cores/rp2040/RP2040Support.h b/cores/rp2040/RP2040Support.h index 42e732df0..a8ea99ffb 100644 --- a/cores/rp2040/RP2040Support.h +++ b/cores/rp2040/RP2040Support.h @@ -289,7 +289,11 @@ class RP2040 { inline uint32_t getStackPointer() { uint32_t *sp; +#if defined(__riscv) + asm volatile("mv %0, sp" : "=r"(sp)); +#else asm volatile("mov %0, sp" : "=r"(sp)); +#endif return (uint32_t)sp; }