![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/targets/TARGET_NUVOTON/TARGET_M2351/device/system_M2351.c@0:8fdf9a60065b, 2018-10-10 (annotated)
- Committer:
- kadonotakashi
- Date:
- Wed Oct 10 00:33:53 2018 +0000
- Revision:
- 0:8fdf9a60065b
how to make mbed librry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | /**************************************************************************//** |
kadonotakashi | 0:8fdf9a60065b | 2 | * @file system_M2351.c |
kadonotakashi | 0:8fdf9a60065b | 3 | * @version V2.00 |
kadonotakashi | 0:8fdf9a60065b | 4 | * $Revision: 6 $ |
kadonotakashi | 0:8fdf9a60065b | 5 | * $Date: 16/12/02 2:01p $ |
kadonotakashi | 0:8fdf9a60065b | 6 | * @brief System Setting Source File |
kadonotakashi | 0:8fdf9a60065b | 7 | * |
kadonotakashi | 0:8fdf9a60065b | 8 | * @note |
kadonotakashi | 0:8fdf9a60065b | 9 | * Copyright (C) 2016 Nuvoton Technology Corp. All rights reserved. |
kadonotakashi | 0:8fdf9a60065b | 10 | * |
kadonotakashi | 0:8fdf9a60065b | 11 | ******************************************************************************/ |
kadonotakashi | 0:8fdf9a60065b | 12 | #include <arm_cmse.h> |
kadonotakashi | 0:8fdf9a60065b | 13 | #include <stdio.h> |
kadonotakashi | 0:8fdf9a60065b | 14 | #include <stdint.h> |
kadonotakashi | 0:8fdf9a60065b | 15 | #include "M2351.h" |
kadonotakashi | 0:8fdf9a60065b | 16 | |
kadonotakashi | 0:8fdf9a60065b | 17 | #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) |
kadonotakashi | 0:8fdf9a60065b | 18 | #include "partition_M2351.h" |
kadonotakashi | 0:8fdf9a60065b | 19 | #endif |
kadonotakashi | 0:8fdf9a60065b | 20 | |
kadonotakashi | 0:8fdf9a60065b | 21 | |
kadonotakashi | 0:8fdf9a60065b | 22 | #if defined(__ICCARM__) |
kadonotakashi | 0:8fdf9a60065b | 23 | extern void *__vector_table; /* see startup file */ |
kadonotakashi | 0:8fdf9a60065b | 24 | #else |
kadonotakashi | 0:8fdf9a60065b | 25 | extern void *__vector_handlers; /* see startup file */ |
kadonotakashi | 0:8fdf9a60065b | 26 | #endif |
kadonotakashi | 0:8fdf9a60065b | 27 | |
kadonotakashi | 0:8fdf9a60065b | 28 | |
kadonotakashi | 0:8fdf9a60065b | 29 | /*---------------------------------------------------------------------------- |
kadonotakashi | 0:8fdf9a60065b | 30 | Clock Variable definitions |
kadonotakashi | 0:8fdf9a60065b | 31 | *----------------------------------------------------------------------------*/ |
kadonotakashi | 0:8fdf9a60065b | 32 | uint32_t SystemCoreClock = __HSI; /*!< System Clock Frequency (Core Clock) */ |
kadonotakashi | 0:8fdf9a60065b | 33 | uint32_t CyclesPerUs = (__HSI / 1000000); /*!< Cycles per micro second */ |
kadonotakashi | 0:8fdf9a60065b | 34 | uint32_t PllClock = __HSI; /*!< PLL Output Clock Frequency */ |
kadonotakashi | 0:8fdf9a60065b | 35 | const uint32_t gau32ClkSrcTbl[] = {__HXT, __LXT, NULL, __LIRC, NULL, NULL, NULL, __HIRC}; |
kadonotakashi | 0:8fdf9a60065b | 36 | |
kadonotakashi | 0:8fdf9a60065b | 37 | |
kadonotakashi | 0:8fdf9a60065b | 38 | /** |
kadonotakashi | 0:8fdf9a60065b | 39 | * @brief Update the Variable SystemCoreClock |
kadonotakashi | 0:8fdf9a60065b | 40 | * |
kadonotakashi | 0:8fdf9a60065b | 41 | * @param None |
kadonotakashi | 0:8fdf9a60065b | 42 | * |
kadonotakashi | 0:8fdf9a60065b | 43 | * @return None |
kadonotakashi | 0:8fdf9a60065b | 44 | * |
kadonotakashi | 0:8fdf9a60065b | 45 | * @details This function is used to update the variable SystemCoreClock |
kadonotakashi | 0:8fdf9a60065b | 46 | * and must be called whenever the core clock is changed. |
kadonotakashi | 0:8fdf9a60065b | 47 | */ |
kadonotakashi | 0:8fdf9a60065b | 48 | void SystemCoreClockUpdate(void) |
kadonotakashi | 0:8fdf9a60065b | 49 | { |
kadonotakashi | 0:8fdf9a60065b | 50 | /* Update PLL Clock */ |
kadonotakashi | 0:8fdf9a60065b | 51 | PllClock = CLK_GetPLLClockFreq(); |
kadonotakashi | 0:8fdf9a60065b | 52 | |
kadonotakashi | 0:8fdf9a60065b | 53 | /* Update System Core Clock */ |
kadonotakashi | 0:8fdf9a60065b | 54 | SystemCoreClock = CLK_GetCPUFreq(); |
kadonotakashi | 0:8fdf9a60065b | 55 | |
kadonotakashi | 0:8fdf9a60065b | 56 | /* Update Cycles per micro second */ |
kadonotakashi | 0:8fdf9a60065b | 57 | CyclesPerUs = (SystemCoreClock + 500000) / 1000000; |
kadonotakashi | 0:8fdf9a60065b | 58 | } |
kadonotakashi | 0:8fdf9a60065b | 59 | |
kadonotakashi | 0:8fdf9a60065b | 60 | |
kadonotakashi | 0:8fdf9a60065b | 61 | |
kadonotakashi | 0:8fdf9a60065b | 62 | /** |
kadonotakashi | 0:8fdf9a60065b | 63 | * @brief System Initialization |
kadonotakashi | 0:8fdf9a60065b | 64 | * |
kadonotakashi | 0:8fdf9a60065b | 65 | * @param None |
kadonotakashi | 0:8fdf9a60065b | 66 | * |
kadonotakashi | 0:8fdf9a60065b | 67 | * @return None |
kadonotakashi | 0:8fdf9a60065b | 68 | * |
kadonotakashi | 0:8fdf9a60065b | 69 | * @details The necessary initialization of system. Global variables are forbidden here. |
kadonotakashi | 0:8fdf9a60065b | 70 | */ |
kadonotakashi | 0:8fdf9a60065b | 71 | void SystemInit(void) |
kadonotakashi | 0:8fdf9a60065b | 72 | { |
kadonotakashi | 0:8fdf9a60065b | 73 | |
kadonotakashi | 0:8fdf9a60065b | 74 | #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) |
kadonotakashi | 0:8fdf9a60065b | 75 | #if defined(__ICCARM__) |
kadonotakashi | 0:8fdf9a60065b | 76 | SCB->VTOR = (uint32_t) &__vector_table; |
kadonotakashi | 0:8fdf9a60065b | 77 | #else |
kadonotakashi | 0:8fdf9a60065b | 78 | SCB->VTOR = (uint32_t) &__vector_handlers; |
kadonotakashi | 0:8fdf9a60065b | 79 | #endif |
kadonotakashi | 0:8fdf9a60065b | 80 | #endif |
kadonotakashi | 0:8fdf9a60065b | 81 | |
kadonotakashi | 0:8fdf9a60065b | 82 | #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) |
kadonotakashi | 0:8fdf9a60065b | 83 | TZ_SAU_Setup(); |
kadonotakashi | 0:8fdf9a60065b | 84 | SCU_Setup(); |
kadonotakashi | 0:8fdf9a60065b | 85 | FMC_NSBA_Setup(); |
kadonotakashi | 0:8fdf9a60065b | 86 | #endif |
kadonotakashi | 0:8fdf9a60065b | 87 | |
kadonotakashi | 0:8fdf9a60065b | 88 | #ifdef INIT_SYSCLK_AT_BOOTING |
kadonotakashi | 0:8fdf9a60065b | 89 | |
kadonotakashi | 0:8fdf9a60065b | 90 | #endif |
kadonotakashi | 0:8fdf9a60065b | 91 | |
kadonotakashi | 0:8fdf9a60065b | 92 | } |
kadonotakashi | 0:8fdf9a60065b | 93 | |
kadonotakashi | 0:8fdf9a60065b | 94 | |
kadonotakashi | 0:8fdf9a60065b | 95 | #if USE_ASSERT |
kadonotakashi | 0:8fdf9a60065b | 96 | |
kadonotakashi | 0:8fdf9a60065b | 97 | /** |
kadonotakashi | 0:8fdf9a60065b | 98 | * @brief Assert Error Message |
kadonotakashi | 0:8fdf9a60065b | 99 | * |
kadonotakashi | 0:8fdf9a60065b | 100 | * @param[in] file the source file name |
kadonotakashi | 0:8fdf9a60065b | 101 | * @param[in] line line number |
kadonotakashi | 0:8fdf9a60065b | 102 | * |
kadonotakashi | 0:8fdf9a60065b | 103 | * @return None |
kadonotakashi | 0:8fdf9a60065b | 104 | * |
kadonotakashi | 0:8fdf9a60065b | 105 | * @details The function prints the source file name and line number where |
kadonotakashi | 0:8fdf9a60065b | 106 | * the ASSERT_PARAM() error occurs, and then stops in an infinite loop. |
kadonotakashi | 0:8fdf9a60065b | 107 | */ |
kadonotakashi | 0:8fdf9a60065b | 108 | void AssertError(uint8_t * file, uint32_t line) |
kadonotakashi | 0:8fdf9a60065b | 109 | { |
kadonotakashi | 0:8fdf9a60065b | 110 | |
kadonotakashi | 0:8fdf9a60065b | 111 | printf("[%s] line %d : wrong parameters.\r\n", file, line); |
kadonotakashi | 0:8fdf9a60065b | 112 | |
kadonotakashi | 0:8fdf9a60065b | 113 | /* Infinite loop */ |
kadonotakashi | 0:8fdf9a60065b | 114 | while(1) ; |
kadonotakashi | 0:8fdf9a60065b | 115 | } |
kadonotakashi | 0:8fdf9a60065b | 116 | #endif |
kadonotakashi | 0:8fdf9a60065b | 117 |