system_ARMCM85.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**************************************************************************//**
  2. * @file system_ARMCM85.c
  3. * @brief CMSIS Device System Source File for ARMCM85 Device
  4. * @version V1.0.0
  5. * @date 30. March 2022
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2022 Arm Limited. All rights reserved.
  9. *
  10. * SPDX-License-Identifier: Apache-2.0
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the License); you may
  13. * not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  20. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #if defined (ARMCM85)
  25. #include "ARMCM85.h"
  26. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  27. #include "partition_ARMCM85.h"
  28. #endif
  29. #else
  30. #error device not specified!
  31. #endif
  32. /*----------------------------------------------------------------------------
  33. Define clocks
  34. *----------------------------------------------------------------------------*/
  35. #define XTAL (50000000UL) /* Oscillator frequency */
  36. #define SYSTEM_CLOCK (XTAL / 2U)
  37. /*----------------------------------------------------------------------------
  38. Exception / Interrupt Vector table
  39. *----------------------------------------------------------------------------*/
  40. extern const VECTOR_TABLE_Type __VECTOR_TABLE[496];
  41. /*----------------------------------------------------------------------------
  42. System Core Clock Variable
  43. *----------------------------------------------------------------------------*/
  44. uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */
  45. /*----------------------------------------------------------------------------
  46. System Core Clock update function
  47. *----------------------------------------------------------------------------*/
  48. void SystemCoreClockUpdate (void)
  49. {
  50. SystemCoreClock = SYSTEM_CLOCK;
  51. }
  52. /*----------------------------------------------------------------------------
  53. System initialization function
  54. *----------------------------------------------------------------------------*/
  55. void SystemInit (void)
  56. {
  57. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  58. SCB->VTOR = (uint32_t)(&__VECTOR_TABLE[0]);
  59. #endif
  60. /* Set CPDLPSTATE.RLPSTATE to 0
  61. Set CPDLPSTATE.ELPSTATE to 0, to stop the processor from trying to switch the EPU into retention state.
  62. Set CPDLPSTATE.CLPSTATE to 0, so PDCORE will not enter low-power state. */
  63. PWRMODCTL->CPDLPSTATE &= ~(PWRMODCTL_CPDLPSTATE_RLPSTATE_Msk |
  64. PWRMODCTL_CPDLPSTATE_ELPSTATE_Msk |
  65. PWRMODCTL_CPDLPSTATE_CLPSTATE_Msk );
  66. #if (defined (__FPU_USED) && (__FPU_USED == 1U)) || \
  67. (defined (__ARM_FEATURE_MVE) && (__ARM_FEATURE_MVE > 0U))
  68. SCB->CPACR |= ((3U << 10U*2U) | /* enable CP10 Full Access */
  69. (3U << 11U*2U) ); /* enable CP11 Full Access */
  70. /* Favor best FP/MVE performance by default, avoid EPU switch-ON delays */
  71. /* PDEPU ON, Clock OFF */
  72. PWRMODCTL->CPDLPSTATE |= 0x1 << PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos;
  73. #endif
  74. #ifdef UNALIGNED_SUPPORT_DISABLE
  75. SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk;
  76. #endif
  77. /* Enable Loop and branch info cache */
  78. SCB->CCR |= SCB_CCR_LOB_Msk;
  79. /* Enable Branch Prediction */
  80. SCB->CCR |= SCB_CCR_BP_Msk;
  81. __DSB();
  82. __ISB();
  83. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  84. TZ_SAU_Setup();
  85. #endif
  86. SystemCoreClock = SYSTEM_CLOCK;
  87. }