diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-09-02 14:45:40 -0400 |
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-09-02 14:45:40 -0400 |
| commit | e3a880051ccf1ba9a16fd9cf031b7386b2533bf1 (patch) | |
| tree | 96a096b2a668bf7b7929385ebb54c1a3cbd1b9d2 /project/Core/Src/sysmem.c | |
| parent | 0ff718e7cd7159c30636aa323a666ac1af684f63 (diff) | |
| download | 340-repo-Sowgro-e3a880051ccf1ba9a16fd9cf031b7386b2533bf1.tar.gz 340-repo-Sowgro-e3a880051ccf1ba9a16fd9cf031b7386b2533bf1.tar.bz2 340-repo-Sowgro-e3a880051ccf1ba9a16fd9cf031b7386b2533bf1.zip | |
Organized project
Diffstat (limited to 'project/Core/Src/sysmem.c')
| -rw-r--r-- | project/Core/Src/sysmem.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/project/Core/Src/sysmem.c b/project/Core/Src/sysmem.c deleted file mode 100644 index d7cc52c..0000000 --- a/project/Core/Src/sysmem.c +++ /dev/null @@ -1,80 +0,0 @@ -/** - ****************************************************************************** - * @file sysmem.c - * @author Generated by STM32CubeIDE - * @brief STM32CubeIDE System Memory calls file - * - * For more information about which C functions - * need which of these lowlevel functions - * please consult the newlib libc manual - ****************************************************************************** - * @attention - * - * <h2><center>© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.</center></h2> - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Includes */ -#include <errno.h> -#include <stdint.h> - -/** - * Pointer to the current high watermark of the heap usage - */ -static uint8_t *__sbrk_heap_end = NULL; - -/** - * @brief _sbrk() allocates memory to the newlib heap and is used by malloc - * and others from the C library - * - * @verbatim - * ############################################################################ - * # .data # .bss # newlib heap # MSP stack # - * # # # # Reserved by _Min_Stack_Size # - * ############################################################################ - * ^-- RAM start ^-- _end _estack, RAM end --^ - * @endverbatim - * - * This implementation starts allocating at the '_end' linker symbol - * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack - * The implementation considers '_estack' linker symbol to be RAM end - * NOTE: If the MSP stack, at any point during execution, grows larger than the - * reserved size, please increase the '_Min_Stack_Size'. - * - * @param incr Memory size - * @return Pointer to allocated memory - */ -void *_sbrk(ptrdiff_t incr) -{ - extern uint8_t _end; /* Symbol defined in the linker script */ - extern uint8_t _estack; /* Symbol defined in the linker script */ - extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ - const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; - const uint8_t *max_heap = (uint8_t *)stack_limit; - uint8_t *prev_heap_end; - - /* Initialize heap end at first call */ - if (NULL == __sbrk_heap_end) - { - __sbrk_heap_end = &_end; - } - - /* Protect heap from growing into the reserved MSP stack */ - if (__sbrk_heap_end + incr > max_heap) - { - errno = ENOMEM; - return (void *)-1; - } - - prev_heap_end = __sbrk_heap_end; - __sbrk_heap_end += incr; - - return (void *)prev_heap_end; -} |
