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