µOS++ IIIe / CMSIS++ / POSIX++ Reference  v6.3.11
“Perfekt ist nicht gut genug”
The third edition of µOS++ and CMSIS++, a proposal for the next generation CMSIS, written in C++.
initialize-hardware.c
Go to the documentation of this file.
1 /*
2  * This file is part of the µOS++ distribution.
3  * (https://github.com/micro-os-plus)
4  * Copyright (c) 2015 Liviu Ionescu.
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use,
10  * copy, modify, merge, publish, distribute, sublicense, and/or
11  * sell copies of the Software, and to permit persons to whom
12  * the Software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 #if defined(__ARM_EABI__)
29 
30 // ----------------------------------------------------------------------------
31 
33 #include <cmsis_device.h>
34 
35 // ----------------------------------------------------------------------------
36 
37 #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
38 extern unsigned int __vectors_start;
39 #endif
40 
41 // ----------------------------------------------------------------------------
42 
59 void __attribute__((weak))
61 {
62  // Call the CSMSIS system initialisation routine.
63  SystemInit ();
64 
65 #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
66 
67  // Set VTOR to the actual address, provided by the linker script.
68  // Override the manual, possibly wrong, SystemInit() setting.
69  SCB->VTOR = (uint32_t) (&__vectors_start);
70  // Ensure all subsequence instructions use the new configuration.
71  __DSB ();
72 
73 #endif /* defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) */
74 
75  // The current version of SystemInit() leaves the value of the clock
76  // in a RAM variable (SystemCoreClock), which will be cleared shortly,
77  // so it needs to be recomputed after the RAM initialisations
78  // are completed.
79 
80 #if defined(OS_INCLUDE_STARTUP_INIT_FP) || defined (__ARM_FP)
81 
82  // Normally FP init is done by SystemInit(). In case this is not done
83  // there, it is possible to force its inclusion by defining
84  // OS_INCLUDE_STARTUP_INIT_FP.
85 
86  // Enable the Cortex-M4 FPU only when -mfloat-abi=hard or -mfloat-abi=softfp.
87  // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
88 
89  // Set bits 20-23 to enable CP10 and CP11 coprocessor.
90  SCB->CPACR |= (0xF << 20);
91 
92  // Lazy save.
93  FPU->FPCCR |= FPU_FPCCR_ASPEN_Msk | FPU_FPCCR_LSPEN_Msk;
94 
95 #endif /* defined(OS_INCLUDE_STARTUP_INIT_FP) || defined (__ARM_FP) */
96 
97 #if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
98 
99  SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk;
100 
101 #endif
102 }
103 
104 // Temporarily disabled, to help identify missing application inits.
105 #if 0 || defined(__DOXYGEN__)
106 
119 void __attribute__((weak))
121 {
122  // Call the CSMSIS system clock routine to store the clock frequency
123  // in the SystemCoreClock global RAM location.
124  SystemCoreClockUpdate ();
125 }
126 #endif /* 0 || defined(__DOXYGEN__) */
127 
128 // ----------------------------------------------------------------------------
129 
130 #endif /* defined(__ARM_EABI__) */
131 
void os_startup_initialize_hardware(void)
Initialise hardware.
void os_startup_initialize_hardware_early(void)
Initialise hardware early.