system_ARMCM4.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**************************************************************************//**
  2. * @file system_ARMCM4.c
  3. * @brief CMSIS Device System Source File for
  4. * ARMCM4 Device Series
  5. * @version V5.00
  6. * @date 10. January 2018
  7. ******************************************************************************/
  8. /*
  9. * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
  10. *
  11. * SPDX-License-Identifier: Apache-2.0
  12. *
  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
  16. *
  17. * www.apache.org/licenses/LICENSE-2.0
  18. *
  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.
  24. */
  25. #if defined (ARMCM4)
  26. #include "ARMCM4.h"
  27. #elif defined (ARMCM4_FP)
  28. #include "ARMCM4_FP.h"
  29. #else
  30. #error device not specified!
  31. #endif
  32. /*----------------------------------------------------------------------------
  33. Define clocks
  34. *----------------------------------------------------------------------------*/
  35. #define XTAL ( 5000000UL) /* Oscillator frequency */
  36. #define SYSTEM_CLOCK (5U * XTAL)
  37. /*----------------------------------------------------------------------------
  38. Externals
  39. *----------------------------------------------------------------------------*/
  40. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  41. extern uint32_t __Vectors;
  42. #endif
  43. /*----------------------------------------------------------------------------
  44. System Core Clock Variable
  45. *----------------------------------------------------------------------------*/
  46. uint32_t SystemCoreClock = SYSTEM_CLOCK;
  47. /*----------------------------------------------------------------------------
  48. System Core Clock update function
  49. *----------------------------------------------------------------------------*/
  50. void SystemCoreClockUpdate (void)
  51. {
  52. SystemCoreClock = SYSTEM_CLOCK;
  53. }
  54. /*----------------------------------------------------------------------------
  55. System initialization function
  56. *----------------------------------------------------------------------------*/
  57. void SystemInit (void)
  58. {
  59. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  60. SCB->VTOR = (uint32_t) &__Vectors;
  61. #endif
  62. #if defined (__FPU_USED) && (__FPU_USED == 1U)
  63. SCB->CPACR |= ((3U << 10U*2U) | /* set CP10 Full Access */
  64. (3U << 11U*2U) ); /* set CP11 Full Access */
  65. #endif
  66. #ifdef UNALIGNED_SUPPORT_DISABLE
  67. SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk;
  68. #endif
  69. SystemCoreClock = SYSTEM_CLOCK;
  70. }