Mouse code for the MacroRat
mbed-dev/targets/TARGET_NUVOTON/TARGET_M451/device/TOOLCHAIN_GCC_ARM/m451_retarget.c@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 2 | * @file startup_NUC472_442.c |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @version V0.10 |
sahilmgandhi | 18:6a4db94011d3 | 4 | * $Revision: 11 $ |
sahilmgandhi | 18:6a4db94011d3 | 5 | * $Date: 15/09/02 10:02a $ |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Source File for NUC472/442 MCU |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * @note |
sahilmgandhi | 18:6a4db94011d3 | 9 | * Copyright (C) 2013~2015 Nuvoton Technology Corp. All rights reserved. |
sahilmgandhi | 18:6a4db94011d3 | 10 | *****************************************************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 11 | |
sahilmgandhi | 18:6a4db94011d3 | 12 | #include "M451Series.h" |
sahilmgandhi | 18:6a4db94011d3 | 13 | #include <errno.h> |
sahilmgandhi | 18:6a4db94011d3 | 14 | #include "nu_miscutil.h" |
sahilmgandhi | 18:6a4db94011d3 | 15 | |
sahilmgandhi | 18:6a4db94011d3 | 16 | extern uint32_t __mbed_sbrk_start; |
sahilmgandhi | 18:6a4db94011d3 | 17 | extern uint32_t __mbed_krbs_start; |
sahilmgandhi | 18:6a4db94011d3 | 18 | |
sahilmgandhi | 18:6a4db94011d3 | 19 | #define NU_HEAP_ALIGN 32 |
sahilmgandhi | 18:6a4db94011d3 | 20 | |
sahilmgandhi | 18:6a4db94011d3 | 21 | /** |
sahilmgandhi | 18:6a4db94011d3 | 22 | * The default implementation of _sbrk() (in common/retarget.cpp) for GCC_ARM requires one-region model (heap and stack share one region), which doesn't |
sahilmgandhi | 18:6a4db94011d3 | 23 | * fit two-region model (heap and stack are two distinct regions), for example, NUMAKER-PFM-NUC472 locates heap on external SRAM. Define __wrap__sbrk() to |
sahilmgandhi | 18:6a4db94011d3 | 24 | * override the default _sbrk(). It is expected to get called through gcc hooking mechanism ('-Wl,--wrap,_sbrk') or in _sbrk(). |
sahilmgandhi | 18:6a4db94011d3 | 25 | */ |
sahilmgandhi | 18:6a4db94011d3 | 26 | void *__wrap__sbrk(int incr) |
sahilmgandhi | 18:6a4db94011d3 | 27 | { |
sahilmgandhi | 18:6a4db94011d3 | 28 | static uint32_t heap_ind = (uint32_t) &__mbed_sbrk_start; |
sahilmgandhi | 18:6a4db94011d3 | 29 | uint32_t heap_ind_old = NU_ALIGN_UP(heap_ind, NU_HEAP_ALIGN); |
sahilmgandhi | 18:6a4db94011d3 | 30 | uint32_t heap_ind_new = NU_ALIGN_UP(heap_ind_old + incr, NU_HEAP_ALIGN); |
sahilmgandhi | 18:6a4db94011d3 | 31 | |
sahilmgandhi | 18:6a4db94011d3 | 32 | if (heap_ind_new > &__mbed_krbs_start) { |
sahilmgandhi | 18:6a4db94011d3 | 33 | errno = ENOMEM; |
sahilmgandhi | 18:6a4db94011d3 | 34 | return (void *) -1; |
sahilmgandhi | 18:6a4db94011d3 | 35 | } |
sahilmgandhi | 18:6a4db94011d3 | 36 | |
sahilmgandhi | 18:6a4db94011d3 | 37 | heap_ind = heap_ind_new; |
sahilmgandhi | 18:6a4db94011d3 | 38 | |
sahilmgandhi | 18:6a4db94011d3 | 39 | return (void *) heap_ind_old; |
sahilmgandhi | 18:6a4db94011d3 | 40 | } |