µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
initialize-hardware.c
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2015-2025 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can
9 * be obtained from https://opensource.org/licenses/mit.
10 */
11
12#if defined(__clang__)
13#pragma clang diagnostic ignored "-Wempty-translation-unit"
14#endif
15
16// ----------------------------------------------------------------------------
17
18#if defined(__ARM_EABI__)
19
20// ----------------------------------------------------------------------------
21
22#if defined(OS_USE_OS_APP_CONFIG_H)
23#include <cmsis-plus/os-app-config.h>
24#endif
25
27#include <cmsis_device.h>
28
29// ----------------------------------------------------------------------------
30
31#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
32extern unsigned int __vectors_start;
33#endif
34
35// ----------------------------------------------------------------------------
36
53void __attribute__ ((weak))
55{
56 // Call the CSMSIS system initialisation routine.
57 SystemInit ();
58
59#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
60
61 // Set VTOR to the actual address, provided by the linker script.
62 // Override the manual, possibly wrong, SystemInit() setting.
63 SCB->VTOR = (uint32_t)(&__vectors_start);
64 // Ensure all subsequence instructions use the new configuration.
65 __DSB ();
66
67#endif /* defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) */
68
69 // The current version of SystemInit() leaves the value of the clock
70 // in a RAM variable (SystemCoreClock), which will be cleared shortly,
71 // so it needs to be recomputed after the RAM initialisations
72 // are completed.
73
74#if defined(OS_INCLUDE_STARTUP_INIT_FP) || defined(__ARM_FP)
75
76 // Normally FP init is done by SystemInit(). In case this is not done
77 // there, it is possible to force its inclusion by defining
78 // OS_INCLUDE_STARTUP_INIT_FP.
79
80 // Enable the Cortex-M4 FPU only when -mfloat-abi=hard or -mfloat-abi=softfp.
81 // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
82
83 // Set bits 20-23 to enable CP10 and CP11 coprocessor.
84 SCB->CPACR |= (0xF << 20);
85
86 // Lazy save.
87 FPU->FPCCR |= FPU_FPCCR_ASPEN_Msk | FPU_FPCCR_LSPEN_Msk;
88
89#endif /* defined(OS_INCLUDE_STARTUP_INIT_FP) || defined (__ARM_FP) */
90
91#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
92
93 SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk;
94
95#endif
96}
97
98// Temporarily disabled, to help identify missing application inits.
99#if 0 || defined(__DOXYGEN__)
113void __attribute__((weak))
115{
116 // Call the CSMSIS system clock routine to store the clock frequency
117 // in the SystemCoreClock global RAM location.
118 SystemCoreClockUpdate ();
119}
120#endif /* 0 || defined(__DOXYGEN__) */
121
122// ----------------------------------------------------------------------------
123
124#endif /* defined(__ARM_EABI__) */
void os_startup_initialize_hardware_early(void)
Initialise hardware early.
void os_startup_initialize_hardware(void)
Initialise hardware.