Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit efacd27

Browse files
committedOct 10, 2018
Use CMSIS function to get SP
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 43b636f commit efacd27

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎cores/arduino/syscalls.c

Lines changed: 2 additions & 3 deletions
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)
Please sign in to comment.