mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/device/TOOLCHAIN_GCC_ARM/STM32F0xxx_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 | 188:bcfe06ba3d64 | 1 | /* mbed Microcontroller Library |
AnnaBridge | 188:bcfe06ba3d64 | 2 | * Copyright (c) 2018, STMicroelectronics |
AnnaBridge | 188:bcfe06ba3d64 | 3 | * All rights reserved. |
AnnaBridge | 188:bcfe06ba3d64 | 4 | * |
AnnaBridge | 188:bcfe06ba3d64 | 5 | * Redistribution and use in source and binary forms, with or without |
AnnaBridge | 188:bcfe06ba3d64 | 6 | * modification, are permitted provided that the following conditions are met: |
AnnaBridge | 188:bcfe06ba3d64 | 7 | * |
AnnaBridge | 188:bcfe06ba3d64 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
AnnaBridge | 188:bcfe06ba3d64 | 9 | * this list of conditions and the following disclaimer. |
AnnaBridge | 188:bcfe06ba3d64 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
AnnaBridge | 188:bcfe06ba3d64 | 11 | * this list of conditions and the following disclaimer in the documentation |
AnnaBridge | 188:bcfe06ba3d64 | 12 | * and/or other materials provided with the distribution. |
AnnaBridge | 188:bcfe06ba3d64 | 13 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
AnnaBridge | 188:bcfe06ba3d64 | 14 | * may be used to endorse or promote products derived from this software |
AnnaBridge | 188:bcfe06ba3d64 | 15 | * without specific prior written permission. |
AnnaBridge | 188:bcfe06ba3d64 | 16 | * |
AnnaBridge | 188:bcfe06ba3d64 | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AnnaBridge | 188:bcfe06ba3d64 | 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
AnnaBridge | 188:bcfe06ba3d64 | 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 188:bcfe06ba3d64 | 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
AnnaBridge | 188:bcfe06ba3d64 | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
AnnaBridge | 188:bcfe06ba3d64 | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
AnnaBridge | 188:bcfe06ba3d64 | 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
AnnaBridge | 188:bcfe06ba3d64 | 24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
AnnaBridge | 188:bcfe06ba3d64 | 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
AnnaBridge | 188:bcfe06ba3d64 | 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 188:bcfe06ba3d64 | 27 | */ |
AnnaBridge | 188:bcfe06ba3d64 | 28 | #include <errno.h> |
AnnaBridge | 188:bcfe06ba3d64 | 29 | #include "stm32f0xx.h" |
AnnaBridge | 188:bcfe06ba3d64 | 30 | extern uint32_t __mbed_sbrk_start; |
AnnaBridge | 188:bcfe06ba3d64 | 31 | extern uint32_t __mbed_krbs_start; |
AnnaBridge | 188:bcfe06ba3d64 | 32 | |
AnnaBridge | 188:bcfe06ba3d64 | 33 | /* Support heap with two-region model |
AnnaBridge | 188:bcfe06ba3d64 | 34 | * |
AnnaBridge | 188:bcfe06ba3d64 | 35 | * The default implementation of _sbrk() (in mbed_retarget.cpp) for GCC_ARM requires one-region |
AnnaBridge | 188:bcfe06ba3d64 | 36 | * model (heap and stack share one region), which doesn't fit two-region model (heap and stack |
AnnaBridge | 188:bcfe06ba3d64 | 37 | * are two distinct regions) |
AnnaBridge | 188:bcfe06ba3d64 | 38 | * Hence, override _sbrk() here to support heap with two-region model. |
AnnaBridge | 188:bcfe06ba3d64 | 39 | */ |
AnnaBridge | 188:bcfe06ba3d64 | 40 | void *_sbrk(int incr) |
AnnaBridge | 188:bcfe06ba3d64 | 41 | { |
AnnaBridge | 188:bcfe06ba3d64 | 42 | static uint32_t heap_ind = (uint32_t) &__mbed_sbrk_start; |
AnnaBridge | 188:bcfe06ba3d64 | 43 | uint32_t heap_ind_old = heap_ind; |
AnnaBridge | 188:bcfe06ba3d64 | 44 | uint32_t heap_ind_new = heap_ind_old + incr; |
AnnaBridge | 188:bcfe06ba3d64 | 45 | |
AnnaBridge | 188:bcfe06ba3d64 | 46 | if (heap_ind_new > (uint32_t) &__mbed_krbs_start) { |
AnnaBridge | 188:bcfe06ba3d64 | 47 | errno = ENOMEM; |
AnnaBridge | 188:bcfe06ba3d64 | 48 | return (void *) -1; |
AnnaBridge | 188:bcfe06ba3d64 | 49 | } |
AnnaBridge | 188:bcfe06ba3d64 | 50 | |
AnnaBridge | 188:bcfe06ba3d64 | 51 | heap_ind = heap_ind_new; |
AnnaBridge | 188:bcfe06ba3d64 | 52 | |
AnnaBridge | 188:bcfe06ba3d64 | 53 | return (void *) heap_ind_old; |
AnnaBridge | 188:bcfe06ba3d64 | 54 | } |