mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32L4/l4_retarget.c@189:f392fc9709a3, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 22:31:08 2019 +0000
- Revision:
- 189:f392fc9709a3
- Parent:
- 188:bcfe06ba3d64
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 182:a56a73fd2a6f | 1 | /** |
AnnaBridge | 182:a56a73fd2a6f | 2 | ****************************************************************************** |
AnnaBridge | 182:a56a73fd2a6f | 3 | * @file l4_retarget.c |
AnnaBridge | 182:a56a73fd2a6f | 4 | * @author MCD Application Team |
AnnaBridge | 182:a56a73fd2a6f | 5 | * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Source File for STM32L475xG |
AnnaBridge | 187:0387e8f68319 | 6 | ****************************************************************************** |
AnnaBridge | 182:a56a73fd2a6f | 7 | * @attention |
AnnaBridge | 182:a56a73fd2a6f | 8 | * |
AnnaBridge | 182:a56a73fd2a6f | 9 | * <h2><center>© COPYRIGHT(c) 2018 STMicroelectronics</center></h2> |
AnnaBridge | 182:a56a73fd2a6f | 10 | * |
AnnaBridge | 182:a56a73fd2a6f | 11 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 182:a56a73fd2a6f | 12 | * are permitted provided that the following conditions are met: |
AnnaBridge | 182:a56a73fd2a6f | 13 | * 1. Redistributions of source code must retain the above copyright notice, |
AnnaBridge | 182:a56a73fd2a6f | 14 | * this list of conditions and the following disclaimer. |
AnnaBridge | 182:a56a73fd2a6f | 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
AnnaBridge | 182:a56a73fd2a6f | 16 | * this list of conditions and the following disclaimer in the documentation |
AnnaBridge | 182:a56a73fd2a6f | 17 | * and/or other materials provided with the distribution. |
AnnaBridge | 182:a56a73fd2a6f | 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
AnnaBridge | 182:a56a73fd2a6f | 19 | * may be used to endorse or promote products derived from this software |
AnnaBridge | 182:a56a73fd2a6f | 20 | * without specific prior written permission. |
AnnaBridge | 182:a56a73fd2a6f | 21 | * |
AnnaBridge | 182:a56a73fd2a6f | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AnnaBridge | 182:a56a73fd2a6f | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
AnnaBridge | 182:a56a73fd2a6f | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 182:a56a73fd2a6f | 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
AnnaBridge | 182:a56a73fd2a6f | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
AnnaBridge | 182:a56a73fd2a6f | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
AnnaBridge | 182:a56a73fd2a6f | 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
AnnaBridge | 182:a56a73fd2a6f | 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
AnnaBridge | 182:a56a73fd2a6f | 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
AnnaBridge | 182:a56a73fd2a6f | 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 182:a56a73fd2a6f | 32 | * |
AnnaBridge | 187:0387e8f68319 | 33 | ****************************************************************************** |
AnnaBridge | 187:0387e8f68319 | 34 | */ |
Anna Bridge |
186:707f6e361f3e | 35 | #if (defined(TWO_RAM_REGIONS) && defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC_VERSION)) |
AnnaBridge | 182:a56a73fd2a6f | 36 | #include <errno.h> |
AnnaBridge | 182:a56a73fd2a6f | 37 | #include "stm32l4xx.h" |
AnnaBridge | 182:a56a73fd2a6f | 38 | extern uint32_t __mbed_sbrk_start; |
AnnaBridge | 182:a56a73fd2a6f | 39 | extern uint32_t __mbed_krbs_start; |
AnnaBridge | 182:a56a73fd2a6f | 40 | |
AnnaBridge | 182:a56a73fd2a6f | 41 | /** |
AnnaBridge | 187:0387e8f68319 | 42 | * The default implementation of _sbrk() (in platform/mbed_retarget.cpp) for GCC_ARM requires one-region model (heap and |
AnnaBridge | 187:0387e8f68319 | 43 | * stack share one region), which doesn't fit two-region model (heap and stack are two distinct regions), for example, |
AnnaBridge | 187:0387e8f68319 | 44 | * STM32L475xG locates heap on SRAM1 and stack on SRAM2. |
AnnaBridge | 187:0387e8f68319 | 45 | * Define __wrap__sbrk() to override the default _sbrk(). It is expected to get called through gcc |
AnnaBridge | 182:a56a73fd2a6f | 46 | * hooking mechanism ('-Wl,--wrap,_sbrk') or in _sbrk(). |
AnnaBridge | 182:a56a73fd2a6f | 47 | */ |
AnnaBridge | 182:a56a73fd2a6f | 48 | void *__wrap__sbrk(int incr) |
AnnaBridge | 182:a56a73fd2a6f | 49 | { |
AnnaBridge | 182:a56a73fd2a6f | 50 | static uint32_t heap_ind = (uint32_t) &__mbed_sbrk_start; |
AnnaBridge | 188:bcfe06ba3d64 | 51 | uint32_t heap_ind_old = heap_ind; |
AnnaBridge | 188:bcfe06ba3d64 | 52 | uint32_t heap_ind_new = heap_ind_old + incr; |
AnnaBridge | 187:0387e8f68319 | 53 | |
AnnaBridge | 188:bcfe06ba3d64 | 54 | if (heap_ind_new > (uint32_t)&__mbed_krbs_start) { |
AnnaBridge | 182:a56a73fd2a6f | 55 | errno = ENOMEM; |
AnnaBridge | 187:0387e8f68319 | 56 | return (void *) - 1; |
AnnaBridge | 187:0387e8f68319 | 57 | } |
AnnaBridge | 187:0387e8f68319 | 58 | |
AnnaBridge | 182:a56a73fd2a6f | 59 | heap_ind = heap_ind_new; |
AnnaBridge | 187:0387e8f68319 | 60 | |
AnnaBridge | 182:a56a73fd2a6f | 61 | return (void *) heap_ind_old; |
AnnaBridge | 182:a56a73fd2a6f | 62 | } |
AnnaBridge | 182:a56a73fd2a6f | 63 | #endif /* GCC_ARM toolchain && TWO_RAM_REGIONS*/ |
AnnaBridge | 182:a56a73fd2a6f | 64 |