1 /*************************************************************************//**
2  * @file     system_RP2040.c
3  * @brief    CMSIS-Core(M) Device Peripheral Access Layer Header File for
4  *           Device RP2040
5  * @version  V1.0.0
6  * @date     5. May 2021
7  *****************************************************************************/
8 /*
9  * Copyright (c) 2009-2021 Arm Limited. All rights reserved.
10  * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
11  *
12  * SPDX-License-Identifier: Apache-2.0
13  *
14  * Licensed under the Apache License, Version 2.0 (the License); you may
15  * not use this file except in compliance with the License.
16  * You may obtain a copy of the License at
17  *
18  * www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
22  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  *
26  * SPDX-License-Identifier: BSD-3-Clause
27  */
28 
29 #include <stdint.h>
30 #include "RP2040.h"
31 #include "hardware/clocks.h"
32 
33 /*---------------------------------------------------------------------------
34   System Core Clock Variable
35  *---------------------------------------------------------------------------*/
36 uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock)*/
37 
38 /*---------------------------------------------------------------------------
39   System Core Clock function
40  *---------------------------------------------------------------------------*/
SystemCoreClockUpdate(void)41 void SystemCoreClockUpdate (void)
42 {
43     SystemCoreClock = clock_get_hz(clk_sys);
44 }
45 
46 /*---------------------------------------------------------------------------
47   System initialization function
48  *---------------------------------------------------------------------------*/
SystemInit(void)49 void __attribute__((constructor)) SystemInit (void)
50 {
51     SystemCoreClockUpdate();
52 }