1 /**************************************************************************//**
\r
2 * @file system_M2351.h
\r
4 * @brief System Setting Header File
\r
7 * Copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.
\r
9 ******************************************************************************/
\r
10 #ifndef __SYSTEM_M2351_H__
\r
11 #define __SYSTEM_M2351_H__
\r
16 /*---------------------------------------------------------------------------------------------------------*/
\r
17 /* Macro Definition */
\r
18 /*---------------------------------------------------------------------------------------------------------*/
\r
20 # define DEBUG_PORT UART0 /*!< Select Debug Port which is used for retarget.c to output debug message to UART */
\r
24 /* Init ETM Interface Multi-function Pins */
\r
25 #define ETM_INIT() { \
\r
26 SYS->GPC_MFPL &= ~(SYS_GPC_MFPL_PC0MFP_ETM_TRACE_Msk | SYS_GPC_MFPL_PC1MFP_ETM_TRACE_Msk | \
\r
27 SYS_GPC_MFPL_PC2MFP_ETM_TRACE_Msk | SYS_GPC_MFPL_PC3MFP_ETM_TRACE_Msk | \
\r
28 SYS_GPC_MFPL_PC4MFP_ETM_TRACE_Msk); \
\r
29 SYS->GPC_MFPL |= SYS_GPC_MFPL_PC0MFP_ETM_TRACE_CLK | SYS_GPC_MFPL_PC1MFP_ETM_TRACE_DATA0 | \
\r
30 SYS_GPC_MFPL_PC2MFP_ETM_TRACE_DATA1 | SYS_GPC_MFPL_PC3MFP_ETM_TRACE_DATA2 | \
\r
31 SYS_GPC_MFPL_PC4MFP_ETM_TRACE_DATA3;}
\r
39 * @details This is used to enable PLL to speed up booting at startup. Remove it will cause system using
\r
40 * default clock source (External crystal or internal 22.1184MHz IRC).
\r
41 * Enable this option will cause system booting in 72MHz(By XTAL) or 71.8848MHz(By IRC22M) according to
\r
42 * user configuration setting in CONFIG0
\r
47 #define INIT_SYSCLK_AT_BOOTING
\r
50 /*----------------------------------------------------------------------------
\r
52 *----------------------------------------------------------------------------*/
\r
53 #define __HXT (12000000UL) /*!< External Crystal Clock Frequency */
\r
54 #define __LIRC (10000UL) /*!< Internal 10K RC Oscillator Frequency */
\r
55 #define __HIRC (12000000UL) /*!< Internal 12M RC Oscillator Frequency */
\r
56 #define __LXT (32768UL) /*!< External Crystal Clock Frequency 32.768KHz */
\r
57 #define __HSI (48000000UL) /*!< PLL Output Clock Frequency */
\r
58 #define __HIRC48 (48000000UL) /*!< Internal 48M RC Oscillator Frequency */
\r
59 #define __LIRC32 (32000UL) /*!< Internal 32K RC Oscillator Frequency */
\r
62 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3L)
\r
63 # if defined (__ICCARM__)
\r
64 # define __NONSECURE_ENTRY __cmse_nonsecure_entry
\r
65 # define __NONSECURE_ENTRY_WEAK __cmse_nonsecure_entry //__weak
\r
66 # define __NONSECURE_CALL __cmse_nonsecure_call
\r
68 # define __NONSECURE_ENTRY __attribute__((cmse_nonsecure_entry))
\r
69 # define __NONSECURE_ENTRY_WEAK __attribute__((cmse_nonsecure_entry,weak))
\r
70 # define __NONSECURE_CALL __attribute__((cmse_nonsecure_call))
\r
73 # define __NONSECURE_ENTRY
\r
74 # define __NONSECURE_ENTRY_WEAK
\r
75 # define __NONSECURE_CALL
\r
80 extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
\r
81 extern uint32_t CyclesPerUs; /*!< Cycles per micro second */
\r
82 extern uint32_t PllClock; /*!< PLL Output Clock Frequency */
\r
83 extern uint32_t __PC(void); /*!< Return the current program counter value */
\r
87 * @brief Assert Function
\r
89 * @param[in] expr Expression to be evaluated
\r
93 * @details If the expression is false, an error message will be printed out
\r
94 * from debug port (UART0 or UART1).
\r
96 #define ASSERT_PARAM(expr) { if (!(expr)) { AssertError((uint8_t*)__FILE__, __LINE__); } }
\r
98 void AssertError(uint8_t* file, uint32_t line);
\r
100 #define ASSERT_PARAM(expr)
\r
103 #define assert_param(expr) ASSERT_PARAM(expr)
\r
107 * @brief System Initialization
\r
113 * @details The necessary initialization of system.
\r
115 extern void SystemInit(void);
\r
119 * @brief Update the Variable SystemCoreClock
\r
125 * @details This function is used to update the variable SystemCoreClock
\r
126 * and must be called whenever the core clock is changed.
\r
128 extern void SystemCoreClockUpdate(void);
\r
133 #if (defined(__ICCARM__) && (__VER__ >= 7080000) && (__VER__ < 8020000))
\r
134 uint32_t __TZ_get_PSP_NS(void);
\r
135 void __TZ_set_PSP_NS(uint32_t topOfProcStack);
\r
136 int32_t __TZ_get_MSP_NS(void);
\r
137 void __TZ_set_MSP_NS(uint32_t topOfMainStack);
\r
138 uint32_t __TZ_get_PRIMASK_NS(void);
\r
139 void __TZ_set_PRIMASK_NS(uint32_t priMask);
\r
148 #endif /* __SYSTEM_M2351_H__ */
\r