1 /*************************************************************************//**
2 * @file system_<Device>.c
3 * @brief CMSIS-Core(M) Device Peripheral Access Layer Source File for
6 * @date 20. January 2021
7 *****************************************************************************/
9 * Copyright (c) 2009-2021 Arm Limited. All rights reserved.
11 * SPDX-License-Identifier: Apache-2.0
13 * Licensed under the Apache License, Version 2.0 (the License); you may
14 * not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
17 * www.apache.org/licenses/LICENSE-2.0
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
26 /* ToDo: rename this file from 'system_Device.c' to 'system_<Device>.c according to your device naming */
31 /* ToDo: Include partition header file if TZ is used */
32 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
33 #include "partition_<Device>.h"
37 /*---------------------------------------------------------------------------
39 *---------------------------------------------------------------------------*/
40 /* ToDo: Add here your necessary defines for device initialization
41 following is an example for different system frequencies */
42 #define XTAL (12000000U) /* Oscillator frequency */
44 #define SYSTEM_CLOCK (5 * XTAL)
47 /*---------------------------------------------------------------------------
48 Exception / Interrupt Vector table
49 *---------------------------------------------------------------------------*/
50 extern const VECTOR_TABLE_Type __VECTOR_TABLE[496];
53 /*---------------------------------------------------------------------------
54 System Core Clock Variable
55 *---------------------------------------------------------------------------*/
56 /* ToDo: Initialize SystemCoreClock with the system core clock frequency value
57 achieved after system intitialization.
58 This means system core clock frequency after call to SystemInit() */
59 uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Clock Frequency (Core Clock)*/
62 /*---------------------------------------------------------------------------
63 System Core Clock function
64 *---------------------------------------------------------------------------*/
65 void SystemCoreClockUpdate (void)
67 /* ToDo: Add code to calculate the system frequency based upon the current
69 This function can be used to retrieve the system core clock frequeny
70 after user changed register sittings. */
71 SystemCoreClock = SYSTEM_CLOCK;
75 /*---------------------------------------------------------------------------
76 System initialization function
77 *---------------------------------------------------------------------------*/
78 void SystemInit (void)
80 /* ToDo: Add code to initialize the system.
81 Do not use global variables because this function is called before
82 reaching pre-main. RW section maybe overwritten afterwards. */
84 /* ToDo: Initialize VTOR if available */
85 #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
86 SCB->VTOR = (uint32_t)(&__VECTOR_TABLE[0]);
89 /* ToDo: Enable co-processor if it is used */
90 #if (defined (__FPU_USED) && (__FPU_USED == 1U)) || \
91 (defined (__ARM_FEATURE_MVE) && (__ARM_FEATURE_MVE > 0U))
92 SCB->CPACR |= ((3U << 10U*2U) | /* enable CP10 Full Access */
93 (3U << 11U*2U) ); /* enable CP11 Full Access */
96 /* ToDo: Initialize SAU if TZ is used */
97 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
101 SystemCoreClock = SYSTEM_CLOCK;