Skip to content

Commit 14b4dd8

Browse files
committed
Use CMSIS function to get SP
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent c3e2de6 commit 14b4dd8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

cores/arduino/syscalls.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#include "stm32_def.h"
89
#if defined ( __GNUC__ ) /* GCC CS3 */
910
#include <sys/stat.h>
1011
#endif
@@ -25,8 +26,6 @@ extern size_t uart_debug_write(uint8_t *data, uint32_t size);
2526
#define UNUSED(x) x ## _UNUSED
2627
#endif
2728

28-
register char * stack_ptr asm("sp");
29-
3029
__attribute__((weak))
3130
caddr_t _sbrk( int incr ) {
3231
extern char _estack; /* Defined in the linker script */
@@ -35,7 +34,7 @@ caddr_t _sbrk( int incr ) {
3534
static char *heap_end = &_end ;
3635
char *prev_heap_end = heap_end;
3736

38-
if (heap_end + incr > stack_ptr) {
37+
if (heap_end + incr > (char *)__get_MSP()) {
3938
/* Heap and stack collision */
4039
errno = ENOMEM;
4140
return (caddr_t) -1;

0 commit comments

Comments
 (0)