mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 1:9db0e321a9f4 1 /* mbed Microcontroller Library
kenjiArai 1:9db0e321a9f4 2 * Copyright (c) 2017 ARM Limited
kenjiArai 1:9db0e321a9f4 3 * SPDX-License-Identifier: Apache-2.0
kenjiArai 1:9db0e321a9f4 4 *
kenjiArai 1:9db0e321a9f4 5 * Licensed under the Apache License, Version 2.0 (the "License");
kenjiArai 1:9db0e321a9f4 6 * you may not use this file except in compliance with the License.
kenjiArai 1:9db0e321a9f4 7 * You may obtain a copy of the License at
kenjiArai 1:9db0e321a9f4 8 *
kenjiArai 1:9db0e321a9f4 9 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 1:9db0e321a9f4 10 *
kenjiArai 1:9db0e321a9f4 11 * Unless required by applicable law or agreed to in writing, software
kenjiArai 1:9db0e321a9f4 12 * distributed under the License is distributed on an "AS IS" BASIS,
kenjiArai 1:9db0e321a9f4 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 1:9db0e321a9f4 14 * See the License for the specific language governing permissions and
kenjiArai 1:9db0e321a9f4 15 * limitations under the License.
kenjiArai 1:9db0e321a9f4 16 */
kenjiArai 1:9db0e321a9f4 17
kenjiArai 1:9db0e321a9f4 18 #include "mbed_toolchain.h"
kenjiArai 1:9db0e321a9f4 19 #include <stdlib.h>
kenjiArai 1:9db0e321a9f4 20 #include <stdint.h>
kenjiArai 1:9db0e321a9f4 21 #include "cmsis.h"
kenjiArai 1:9db0e321a9f4 22 #include "hal/us_ticker_api.h"
kenjiArai 1:9db0e321a9f4 23
kenjiArai 1:9db0e321a9f4 24 /* This startup is for mbed 2 baremetal. There is no config for RTOS for mbed 2,
kenjiArai 1:9db0e321a9f4 25 * therefore we protect this file with MBED_CONF_RTOS_PRESENT
kenjiArai 1:9db0e321a9f4 26 * Note: The new consolidated started for mbed OS is in rtos/mbed_boot code file.
kenjiArai 1:9db0e321a9f4 27 */
kenjiArai 1:9db0e321a9f4 28 #if !defined(MBED_CONF_RTOS_PRESENT)
kenjiArai 1:9db0e321a9f4 29
kenjiArai 1:9db0e321a9f4 30 /* mbed_main is a function that is called before main()
kenjiArai 1:9db0e321a9f4 31 * mbed_sdk_init() is also a function that is called before main(), but unlike
kenjiArai 1:9db0e321a9f4 32 * mbed_main(), it is not meant for user code, but for the SDK itself to perform
kenjiArai 1:9db0e321a9f4 33 * initializations before main() is called.
kenjiArai 1:9db0e321a9f4 34 */
kenjiArai 1:9db0e321a9f4 35 MBED_WEAK void mbed_main(void)
kenjiArai 1:9db0e321a9f4 36 {
kenjiArai 1:9db0e321a9f4 37
kenjiArai 1:9db0e321a9f4 38 }
kenjiArai 1:9db0e321a9f4 39
kenjiArai 1:9db0e321a9f4 40 /* This function can be implemented by the target to perform higher level target initialization
kenjiArai 1:9db0e321a9f4 41 */
kenjiArai 1:9db0e321a9f4 42 MBED_WEAK void mbed_sdk_init(void)
kenjiArai 1:9db0e321a9f4 43 {
kenjiArai 1:9db0e321a9f4 44
kenjiArai 1:9db0e321a9f4 45 }
kenjiArai 1:9db0e321a9f4 46
kenjiArai 1:9db0e321a9f4 47 MBED_WEAK void software_init_hook_rtos()
kenjiArai 1:9db0e321a9f4 48 {
kenjiArai 1:9db0e321a9f4 49 // Nothing by default
kenjiArai 1:9db0e321a9f4 50 }
kenjiArai 1:9db0e321a9f4 51
kenjiArai 1:9db0e321a9f4 52 void mbed_copy_nvic(void)
kenjiArai 1:9db0e321a9f4 53 {
kenjiArai 1:9db0e321a9f4 54 /* If vector address in RAM is defined, copy and switch to dynamic vectors. Exceptions for M0 which doesn't have
kenjiArai 1:9db0e321a9f4 55 VTOR register and for A9 for which CMSIS doesn't define NVIC_SetVector; in both cases target code is
kenjiArai 1:9db0e321a9f4 56 responsible for correctly handling the vectors.
kenjiArai 1:9db0e321a9f4 57 */
kenjiArai 1:9db0e321a9f4 58 #if !defined(__CORTEX_M0) && !defined(__CORTEX_A9)
kenjiArai 1:9db0e321a9f4 59 #ifdef NVIC_RAM_VECTOR_ADDRESS
kenjiArai 1:9db0e321a9f4 60 uint32_t *old_vectors = (uint32_t *)SCB->VTOR;
kenjiArai 1:9db0e321a9f4 61 uint32_t *vectors = (uint32_t *)NVIC_RAM_VECTOR_ADDRESS;
kenjiArai 1:9db0e321a9f4 62 for (int i = 0; i < NVIC_NUM_VECTORS; i++) {
kenjiArai 1:9db0e321a9f4 63 vectors[i] = old_vectors[i];
kenjiArai 1:9db0e321a9f4 64 }
kenjiArai 1:9db0e321a9f4 65 SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
kenjiArai 1:9db0e321a9f4 66 #endif /* NVIC_RAM_VECTOR_ADDRESS */
kenjiArai 1:9db0e321a9f4 67 #endif /* !defined(__CORTEX_M0) && !defined(__CORTEX_A9) */
kenjiArai 1:9db0e321a9f4 68 }
kenjiArai 1:9db0e321a9f4 69
kenjiArai 1:9db0e321a9f4 70 /* Toolchain specific main code */
kenjiArai 1:9db0e321a9f4 71
kenjiArai 1:9db0e321a9f4 72 #if defined (__ARMCC_VERSION)
kenjiArai 1:9db0e321a9f4 73
kenjiArai 1:9db0e321a9f4 74 int $Super$$main(void);
kenjiArai 1:9db0e321a9f4 75
kenjiArai 1:9db0e321a9f4 76 int $Sub$$main(void)
kenjiArai 1:9db0e321a9f4 77 {
kenjiArai 1:9db0e321a9f4 78 mbed_main();
kenjiArai 1:9db0e321a9f4 79 mbed_error_initialize();
kenjiArai 1:9db0e321a9f4 80 return $Super$$main();
kenjiArai 1:9db0e321a9f4 81 }
kenjiArai 1:9db0e321a9f4 82
kenjiArai 1:9db0e321a9f4 83 void _platform_post_stackheap_init(void)
kenjiArai 1:9db0e321a9f4 84 {
kenjiArai 1:9db0e321a9f4 85 mbed_copy_nvic();
kenjiArai 1:9db0e321a9f4 86 mbed_sdk_init();
kenjiArai 1:9db0e321a9f4 87 #if DEVICE_USTICKER && MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT
kenjiArai 1:9db0e321a9f4 88 us_ticker_init();
kenjiArai 1:9db0e321a9f4 89 #endif
kenjiArai 1:9db0e321a9f4 90 }
kenjiArai 1:9db0e321a9f4 91 //Define an empty os_cb_sections to remove a RTX warning when building with no RTOS due
kenjiArai 1:9db0e321a9f4 92 //to the --keep=os_cb_sections linker option
kenjiArai 1:9db0e321a9f4 93 const uint32_t os_cb_sections[] __attribute__((section(".rodata"))) = {};
kenjiArai 1:9db0e321a9f4 94
kenjiArai 1:9db0e321a9f4 95 #elif defined (__GNUC__)
kenjiArai 1:9db0e321a9f4 96
kenjiArai 1:9db0e321a9f4 97 extern int __real_main(void);
kenjiArai 1:9db0e321a9f4 98
kenjiArai 1:9db0e321a9f4 99 void software_init_hook(void)
kenjiArai 1:9db0e321a9f4 100 {
kenjiArai 1:9db0e321a9f4 101 mbed_copy_nvic();
kenjiArai 1:9db0e321a9f4 102 mbed_sdk_init();
kenjiArai 1:9db0e321a9f4 103 #if DEVICE_USTICKER && MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT
kenjiArai 1:9db0e321a9f4 104 us_ticker_init();
kenjiArai 1:9db0e321a9f4 105 #endif
kenjiArai 1:9db0e321a9f4 106 software_init_hook_rtos();
kenjiArai 1:9db0e321a9f4 107 }
kenjiArai 1:9db0e321a9f4 108
kenjiArai 1:9db0e321a9f4 109
kenjiArai 1:9db0e321a9f4 110 int __wrap_main(void)
kenjiArai 1:9db0e321a9f4 111 {
kenjiArai 1:9db0e321a9f4 112 mbed_main();
kenjiArai 1:9db0e321a9f4 113 mbed_error_initialize();
kenjiArai 1:9db0e321a9f4 114 return __real_main();
kenjiArai 1:9db0e321a9f4 115 }
kenjiArai 1:9db0e321a9f4 116
kenjiArai 1:9db0e321a9f4 117 #elif defined (__ICCARM__)
kenjiArai 1:9db0e321a9f4 118
kenjiArai 1:9db0e321a9f4 119 int __low_level_init(void)
kenjiArai 1:9db0e321a9f4 120 {
kenjiArai 1:9db0e321a9f4 121 mbed_copy_nvic();
kenjiArai 1:9db0e321a9f4 122 #if DEVICE_USTICKER && MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT
kenjiArai 1:9db0e321a9f4 123 us_ticker_init();
kenjiArai 1:9db0e321a9f4 124 #endif
kenjiArai 1:9db0e321a9f4 125 return 1;
kenjiArai 1:9db0e321a9f4 126 }
kenjiArai 1:9db0e321a9f4 127
kenjiArai 1:9db0e321a9f4 128 #endif
kenjiArai 1:9db0e321a9f4 129
kenjiArai 1:9db0e321a9f4 130 #endif