Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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