#line 1 "..\\..\\..\\Library\\StdDriver\\src\\sys.c" #line 1 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" typedef enum IRQn { NonMaskableInt_IRQn = -14, HardFault_IRQn = -13, SVCall_IRQn = -5, PendSV_IRQn = -2, SysTick_IRQn = -1, BOD_IRQn = 0, WDT_IRQn = 1, EINT0_IRQn = 2, EINT1_IRQn = 3, GPIO01_IRQn = 4, GPIO234_IRQn = 5, PWM_IRQn = 6, FB_IRQn = 7, TMR0_IRQn = 8, TMR1_IRQn = 9, UART0_IRQn = 12, UART1_IRQn = 13, SPI_IRQn = 14, GPIO5_IRQn = 16, HIRC_IRQn = 17, I2C0_IRQn = 18, I2C1_IRQn = 19, ACMP_IRQn = 25, PDWU_IRQn = 28, ADC_IRQn = 29 } IRQn_Type; #line 1 "..\\..\\..\\Library\\CMSIS\\Include\\core_cm0.h" #line 1 "D:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h" #line 27 "D:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h" #line 46 "D:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h" typedef signed char int8_t; typedef signed short int int16_t; typedef signed int int32_t; typedef signed __int64 int64_t; typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedef unsigned __int64 uint64_t; typedef signed char int_least8_t; typedef signed short int int_least16_t; typedef signed int int_least32_t; typedef signed __int64 int_least64_t; typedef unsigned char uint_least8_t; typedef unsigned short int uint_least16_t; typedef unsigned int uint_least32_t; typedef unsigned __int64 uint_least64_t; typedef signed int int_fast8_t; typedef signed int int_fast16_t; typedef signed int int_fast32_t; typedef signed __int64 int_fast64_t; typedef unsigned int uint_fast8_t; typedef unsigned int uint_fast16_t; typedef unsigned int uint_fast32_t; typedef unsigned __int64 uint_fast64_t; typedef signed int intptr_t; typedef unsigned int uintptr_t; typedef signed long long intmax_t; typedef unsigned long long uintmax_t; #line 216 "D:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h" #line 241 "D:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h" #line 305 "D:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h" #line 45 "..\\..\\..\\Library\\CMSIS\\Include\\core_cm0.h" #line 120 "..\\..\\..\\Library\\CMSIS\\Include\\core_cm0.h" #line 162 "..\\..\\..\\Library\\CMSIS\\Include\\core_cm0.h" #line 1 "..\\..\\..\\Library\\CMSIS\\Include\\core_cmInstr.h" #line 1 "..\\..\\..\\Library\\CMSIS\\Include\\cmsis_armcc.h" static __inline uint32_t __get_CONTROL(void) { register uint32_t __regControl __asm("control"); return(__regControl); } static __inline void __set_CONTROL(uint32_t control) { register uint32_t __regControl __asm("control"); __regControl = control; } static __inline uint32_t __get_IPSR(void) { register uint32_t __regIPSR __asm("ipsr"); return(__regIPSR); } static __inline uint32_t __get_APSR(void) { register uint32_t __regAPSR __asm("apsr"); return(__regAPSR); } static __inline uint32_t __get_xPSR(void) { register uint32_t __regXPSR __asm("xpsr"); return(__regXPSR); } static __inline uint32_t __get_PSP(void) { register uint32_t __regProcessStackPointer __asm("psp"); return(__regProcessStackPointer); } static __inline void __set_PSP(uint32_t topOfProcStack) { register uint32_t __regProcessStackPointer __asm("psp"); __regProcessStackPointer = topOfProcStack; } static __inline uint32_t __get_MSP(void) { register uint32_t __regMainStackPointer __asm("msp"); return(__regMainStackPointer); } static __inline void __set_MSP(uint32_t topOfMainStack) { register uint32_t __regMainStackPointer __asm("msp"); __regMainStackPointer = topOfMainStack; } static __inline uint32_t __get_PRIMASK(void) { register uint32_t __regPriMask __asm("primask"); return(__regPriMask); } static __inline void __set_PRIMASK(uint32_t priMask) { register uint32_t __regPriMask __asm("primask"); __regPriMask = (priMask); } #line 263 "..\\..\\..\\Library\\CMSIS\\Include\\cmsis_armcc.h" #line 297 "..\\..\\..\\Library\\CMSIS\\Include\\cmsis_armcc.h" __attribute__((section(".rev16_text"))) static __inline __asm uint32_t __REV16(uint32_t value) { rev16 r0, r0 bx lr } __attribute__((section(".revsh_text"))) static __inline __asm int32_t __REVSH(int32_t value) { revsh r0, r0 bx lr } __attribute__((always_inline)) static __inline uint32_t __RBIT(uint32_t value) { uint32_t result; int32_t s = 4 * 8 - 1; result = value; for (value >>= 1U; value; value >>= 1U) { result <<= 1U; result |= value & 1U; s--; } result <<= s; return(result); } #line 649 "..\\..\\..\\Library\\CMSIS\\Include\\cmsis_armcc.h" #line 731 "..\\..\\..\\Library\\CMSIS\\Include\\cmsis_armcc.h" #line 54 "..\\..\\..\\Library\\CMSIS\\Include\\core_cmInstr.h" #line 84 "..\\..\\..\\Library\\CMSIS\\Include\\core_cmInstr.h" #line 164 "..\\..\\..\\Library\\CMSIS\\Include\\core_cm0.h" #line 1 "..\\..\\..\\Library\\CMSIS\\Include\\core_cmFunc.h" #line 54 "..\\..\\..\\Library\\CMSIS\\Include\\core_cmFunc.h" #line 84 "..\\..\\..\\Library\\CMSIS\\Include\\core_cmFunc.h" #line 165 "..\\..\\..\\Library\\CMSIS\\Include\\core_cm0.h" #line 198 "..\\..\\..\\Library\\CMSIS\\Include\\core_cm0.h" #line 214 "..\\..\\..\\Library\\CMSIS\\Include\\core_cm0.h" typedef union { struct { uint32_t _reserved0:28; uint32_t V:1; uint32_t C:1; uint32_t Z:1; uint32_t N:1; } b; uint32_t w; } APSR_Type; typedef union { struct { uint32_t ISR:9; uint32_t _reserved0:23; } b; uint32_t w; } IPSR_Type; typedef union { struct { uint32_t ISR:9; uint32_t _reserved0:15; uint32_t T:1; uint32_t _reserved1:3; uint32_t V:1; uint32_t C:1; uint32_t Z:1; uint32_t N:1; } b; uint32_t w; } xPSR_Type; typedef union { struct { uint32_t _reserved0:1; uint32_t SPSEL:1; uint32_t _reserved1:30; } b; uint32_t w; } CONTROL_Type; typedef struct { volatile uint32_t ISER[1U]; uint32_t RESERVED0[31U]; volatile uint32_t ICER[1U]; uint32_t RSERVED1[31U]; volatile uint32_t ISPR[1U]; uint32_t RESERVED2[31U]; volatile uint32_t ICPR[1U]; uint32_t RESERVED3[31U]; uint32_t RESERVED4[64U]; volatile uint32_t IP[8U]; } NVIC_Type; typedef struct { volatile const uint32_t CPUID; volatile uint32_t ICSR; uint32_t RESERVED0; volatile uint32_t AIRCR; volatile uint32_t SCR; volatile uint32_t CCR; uint32_t RESERVED1; volatile uint32_t SHP[2U]; volatile uint32_t SHCSR; } SCB_Type; typedef struct { volatile uint32_t CTRL; volatile uint32_t LOAD; volatile uint32_t VAL; volatile const uint32_t CALIB; } SysTick_Type; static __inline void NVIC_EnableIRQ(IRQn_Type IRQn) { ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); } static __inline void NVIC_DisableIRQ(IRQn_Type IRQn) { ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); } static __inline uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) { return((uint32_t)(((((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } static __inline void NVIC_SetPendingIRQ(IRQn_Type IRQn) { ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); } static __inline void NVIC_ClearPendingIRQ(IRQn_Type IRQn) { ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); } static __inline void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) { if ((int32_t)(IRQn) < 0) { ((SCB_Type *) ((0xE000E000UL) + 0x0D00UL) )->SHP[( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )] = ((uint32_t)(((SCB_Type *) ((0xE000E000UL) + 0x0D00UL) )->SHP[( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )] & ~(0xFFUL << ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL))) | (((priority << (8U - 2)) & (uint32_t)0xFFUL) << ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL))); } else { ((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->IP[( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )] = ((uint32_t)(((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->IP[( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )] & ~(0xFFUL << ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL))) | (((priority << (8U - 2)) & (uint32_t)0xFFUL) << ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL))); } } static __inline uint32_t NVIC_GetPriority(IRQn_Type IRQn) { if ((int32_t)(IRQn) < 0) { return((uint32_t)(((((SCB_Type *) ((0xE000E000UL) + 0x0D00UL) )->SHP[( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )] >> ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) ) & (uint32_t)0xFFUL) >> (8U - 2))); } else { return((uint32_t)(((((NVIC_Type *) ((0xE000E000UL) + 0x0100UL) )->IP[ ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )] >> ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) ) & (uint32_t)0xFFUL) >> (8U - 2))); } } static __inline void NVIC_SystemReset(void) { do { __schedule_barrier(); __dsb(0xF); __schedule_barrier(); } while (0U); ((SCB_Type *) ((0xE000E000UL) + 0x0D00UL) )->AIRCR = ((0x5FAUL << 16U) | (1UL << 2U)); do { __schedule_barrier(); __dsb(0xF); __schedule_barrier(); } while (0U); for(;;) { __nop(); } } static __inline uint32_t SysTick_Config(uint32_t ticks) { if ((ticks - 1UL) > (0xFFFFFFUL )) { return (1UL); } ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->LOAD = (uint32_t)(ticks - 1UL); NVIC_SetPriority (SysTick_IRQn, (1UL << 2) - 1UL); ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->VAL = 0UL; ((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )->CTRL = (1UL << 2U) | (1UL << 1U) | (1UL ); return (0UL); } #line 134 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\system_Mini58Series.h" #line 33 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\system_Mini58Series.h" extern uint32_t __HSI; extern uint32_t SystemCoreClock; extern uint32_t CyclesPerUs; extern uint32_t PllClock; extern void SystemCoreClockUpdate (void); extern void SystemInit (void); #line 135 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 136 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #pragma anon_unions typedef struct { volatile uint32_t CTL[2]; volatile uint32_t STATUS; volatile uint32_t VREF; } ACMP_T; typedef struct { volatile const uint32_t DAT; volatile const uint32_t RESERVED0[7]; volatile uint32_t CTL; volatile uint32_t CHEN; volatile uint32_t CMP0; volatile uint32_t CMP1; volatile uint32_t STATUS; volatile const uint32_t RESERVED1[4]; volatile uint32_t TRGDLY; volatile uint32_t EXTSMPT; volatile uint32_t SEQCTL; volatile const uint32_t SEQDAT1; volatile const uint32_t SEQDAT2; } ADC_T; typedef struct { volatile uint32_t PWRCTL; volatile uint32_t AHBCLK; volatile uint32_t APBCLK; volatile uint32_t STATUS; volatile uint32_t CLKSEL0; volatile uint32_t CLKSEL1; volatile uint32_t CLKDIV; volatile uint32_t CLKSEL2; volatile uint32_t PLLCTL; volatile uint32_t CLKOCTL; } CLK_T; typedef struct { volatile uint32_t ISPCTL; volatile uint32_t ISPADDR; volatile uint32_t ISPDAT; volatile uint32_t ISPCMD; volatile uint32_t ISPTRG; volatile const uint32_t DFBA; volatile uint32_t FATCTL; volatile const uint32_t RESERVED0[9]; volatile const uint32_t ISPSTS; } FMC_T; typedef struct { volatile uint32_t MODE; volatile uint32_t DINOFF; volatile uint32_t DOUT; volatile uint32_t DATMSK; volatile const uint32_t PIN; volatile uint32_t DBEN; volatile uint32_t INTTYPE; volatile uint32_t INTEN; volatile uint32_t INTSRC; } GPIO_T; typedef struct { volatile uint32_t DBCTL; } GPIO_DB_T; typedef struct { volatile uint32_t CTL; volatile uint32_t ADDR0; volatile uint32_t DAT; volatile const uint32_t STATUS; volatile uint32_t CLKDIV; volatile uint32_t TOCTL; volatile uint32_t ADDR1; volatile uint32_t ADDR2; volatile uint32_t ADDR3; volatile uint32_t ADDRMSK0; volatile uint32_t ADDRMSK1; volatile uint32_t ADDRMSK2; volatile uint32_t ADDRMSK3; volatile const uint32_t RESERVED0[2]; volatile uint32_t CTL1; volatile uint32_t STATUS1; } I2C_T; typedef struct { volatile const uint32_t IRQ0_SRC; volatile const uint32_t IRQ1_SRC; volatile const uint32_t IRQ2_SRC; volatile const uint32_t IRQ3_SRC; volatile const uint32_t IRQ4_SRC; volatile const uint32_t IRQ5_SRC; volatile const uint32_t IRQ6_SRC; volatile const uint32_t IRQ7_SRC; volatile const uint32_t IRQ8_SRC; volatile const uint32_t IRQ9_SRC; uint32_t RESERVE0[2]; volatile const uint32_t IRQ12_SRC; volatile const uint32_t IRQ13_SRC; volatile const uint32_t IRQ14_SRC; uint32_t RESERVE1[1]; volatile const uint32_t IRQ16_SRC; volatile const uint32_t IRQ17_SRC; volatile const uint32_t IRQ18_SRC; volatile const uint32_t IRQ19_SRC; uint32_t RESERVE2[5]; volatile const uint32_t IRQ25_SRC; uint32_t RESERVE3[2]; volatile const uint32_t IRQ28_SRC; volatile const uint32_t IRQ29_SRC; volatile uint32_t CON; volatile uint32_t IRQ; } INTR_T; typedef struct { volatile uint32_t CLKPSC; volatile uint32_t CLKDIV; volatile uint32_t CTL; volatile uint32_t PERIOD0; volatile uint32_t PERIOD1; volatile uint32_t PERIOD2; volatile uint32_t PERIOD3; volatile uint32_t PERIOD4; volatile uint32_t PERIOD5; volatile uint32_t CMPDAT0; volatile uint32_t CMPDAT1; volatile uint32_t CMPDAT2; volatile uint32_t CMPDAT3; volatile uint32_t CMPDAT4; volatile uint32_t CMPDAT5; volatile const uint32_t RESERVED0[6]; volatile uint32_t INTEN; volatile uint32_t INTSTS; volatile uint32_t POEN; volatile uint32_t BRKCTL; volatile uint32_t DTCTL; volatile uint32_t ADCTCTL0; volatile uint32_t ADCTCTL1; volatile uint32_t ADCTSTS0; volatile uint32_t ADCTSTS1; volatile uint32_t PHCHG; volatile uint32_t PHCHGNXT; volatile uint32_t PHCHGMSK; volatile uint32_t IFA; volatile uint32_t PCACTL; volatile uint32_t MSKALIGN; } PWM_T; typedef struct { volatile uint32_t CTL; volatile uint32_t CLKDIV; volatile uint32_t SSCTL; volatile const uint32_t RESERVED0[1]; volatile const uint32_t RX; volatile const uint32_t RESERVED1[3]; volatile uint32_t TX; volatile const uint32_t RESERVED2[6]; volatile uint32_t SLVCTL; volatile uint32_t FIFOCTL; volatile uint32_t STATUS; } SPI_T; typedef struct { volatile const uint32_t PDID; volatile uint32_t RSTSTS; volatile uint32_t IPRST0; volatile uint32_t IPRST1; volatile const uint32_t RESERVED0[2]; volatile uint32_t BODCTL; volatile const uint32_t RESERVED1[5]; volatile uint32_t P0_MFP; volatile uint32_t P1_MFP; volatile uint32_t P2_MFP; volatile uint32_t P3_MFP; volatile uint32_t P4_MFP; volatile uint32_t P5_MFP; volatile const uint32_t RESERVED2[14]; volatile uint32_t IRCTCTL; volatile uint32_t IRCTIEN; volatile uint32_t IRCTISTS; volatile const uint32_t RESERVED3[29]; volatile uint32_t REGLCTL; } SYS_T; typedef struct { volatile uint32_t CTL; volatile uint32_t CMP; volatile uint32_t INTSTS; volatile const uint32_t CNT; volatile const uint32_t CAP; volatile uint32_t EXTCTL; volatile uint32_t EINTSTS; } TIMER_T; typedef struct { volatile uint32_t DAT; volatile uint32_t INTEN; volatile uint32_t FIFO; volatile uint32_t LINE; volatile uint32_t MODEM; volatile uint32_t MODEMSTS; volatile uint32_t FIFOSTS; volatile uint32_t INTSTS; volatile uint32_t TOUT; volatile uint32_t BAUD; volatile uint32_t IRDA; volatile uint32_t ALTCTL; volatile uint32_t FUNSEL; } UART_T; typedef struct { volatile uint32_t CTL; volatile uint32_t ALTCTL; } WDT_T; typedef struct { volatile uint32_t RLDCNT; volatile uint32_t CTL; volatile uint32_t STATUS; volatile const uint32_t CNT; } WWDT_T; #pragma no_anon_unions #line 11669 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 11688 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 11712 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 11724 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" typedef volatile unsigned char vu8; typedef volatile unsigned short vu16; typedef volatile unsigned long vu32; #line 11912 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\sys.h" #line 44 "..\\..\\..\\Library\\StdDriver\\inc\\sys.h" #line 55 "..\\..\\..\\Library\\StdDriver\\inc\\sys.h" #line 106 "..\\..\\..\\Library\\StdDriver\\inc\\sys.h" #line 113 "..\\..\\..\\Library\\StdDriver\\inc\\sys.h" #line 120 "..\\..\\..\\Library\\StdDriver\\inc\\sys.h" #line 168 "..\\..\\..\\Library\\StdDriver\\inc\\sys.h" static __inline void SYS_UnlockReg(void) { do { ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->REGLCTL = 0x59; ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->REGLCTL = 0x16; ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->REGLCTL = 0x88; } while(((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->REGLCTL == 0); } static __inline void SYS_LockReg(void) { ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->REGLCTL = 0; } void SYS_ClearResetSrc(uint32_t u32Src); uint32_t SYS_GetBODStatus(void); uint32_t SYS_GetResetSrc(void); uint32_t SYS_IsRegLocked(void); uint32_t SYS_ReadPDID(void); void SYS_ResetChip(void); void SYS_ResetCPU(void); void SYS_ResetModule(uint32_t u32ModuleIndex); void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel); void SYS_DisableBOD(void); #line 11937 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\clk.h" #line 41 "..\\..\\..\\Library\\StdDriver\\inc\\clk.h" #line 65 "..\\..\\..\\Library\\StdDriver\\inc\\clk.h" #line 95 "..\\..\\..\\Library\\StdDriver\\inc\\clk.h" #line 109 "..\\..\\..\\Library\\StdDriver\\inc\\clk.h" #line 152 "..\\..\\..\\Library\\StdDriver\\inc\\clk.h" #line 161 "..\\..\\..\\Library\\StdDriver\\inc\\clk.h" #line 180 "..\\..\\..\\Library\\StdDriver\\inc\\clk.h" static __inline uint32_t CLK_GetPLLClockFreq(void) { uint32_t u32PllFreq = 0, u32PllReg; uint32_t u32FIN, u32NF, u32NR, u32NO; uint8_t au8NoTbl[4] = {1, 2, 2, 4}; u32PllReg = ((CLK_T *) (((uint32_t)0x50000000) + 0x00200))->PLLCTL; if(u32PllReg & ((0x1ul << (16)) | (0x1ul << (18)))) return 0; if(u32PllReg & 0x00080000UL) u32FIN = (22118400UL); else u32FIN = (12000000UL); if(u32PllReg & (0x1ul << (17))) return u32FIN; u32NO = au8NoTbl[((u32PllReg & (0x3ul << (14))) >> (14))]; u32NF = ((u32PllReg & (0x1fful << (0))) >> (0)) + 2; u32NR = ((u32PllReg & (0x1ful << (9))) >> (9)) + 2; u32PllFreq = (((u32FIN >> 2) * u32NF) / (u32NR * u32NO) << 2); return u32PllFreq; } void CLK_DisableCKO(void); void CLK_EnableCKO(uint32_t u32ClkSrc, uint32_t u32ClkDiv, uint32_t u32ClkDivBy1En); void CLK_PowerDown(void); void CLK_Idle(void); uint32_t CLK_GetHXTFreq(void); uint32_t CLK_GetLXTFreq(void); uint32_t CLK_GetHCLKFreq(void); uint32_t CLK_GetCPUFreq(void); uint32_t CLK_SetCoreClock(uint32_t u32Hclk); void CLK_SetHCLK(uint32_t u32ClkSrc, uint32_t u32ClkDiv); void CLK_SetModuleClock(uint32_t u32ModuleIdx, uint32_t u32ClkSrc, uint32_t u32ClkDiv); void CLK_SetSysTickClockSrc(uint32_t u32ClkSrc); void CLK_EnableSysTick(uint32_t u32ClkSrc, uint32_t u32Count); void CLK_DisableSysTick(void); void CLK_EnableXtalRC(uint32_t u32ClkMask); void CLK_DisableXtalRC(uint32_t u32ClkMask); void CLK_EnableModuleClock(uint32_t u32ModuleIdx); void CLK_DisableModuleClock(uint32_t u32ModuleIdx); void CLK_SysTickDelay(uint32_t us); uint32_t CLK_EnablePLL(uint32_t u32PllClkSrc, uint32_t u32PllFreq); void CLK_DisablePLL(void); uint32_t CLK_WaitClockReady(uint32_t u32ClkMask); #line 11938 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\acmp.h" #line 72 "..\\..\\..\\Library\\StdDriver\\inc\\acmp.h" #line 116 "..\\..\\..\\Library\\StdDriver\\inc\\acmp.h" void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn); void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum); #line 11939 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\adc.h" #line 74 "..\\..\\..\\Library\\StdDriver\\inc\\adc.h" #line 202 "..\\..\\..\\Library\\StdDriver\\inc\\adc.h" #line 234 "..\\..\\..\\Library\\StdDriver\\inc\\adc.h" void ADC_Open(ADC_T *adc, uint32_t u32InputMode, uint32_t u32OpMode, uint32_t u32ChMask); void ADC_Close(ADC_T *adc); void ADC_EnableHWTrigger(ADC_T *adc, uint32_t u32Source, uint32_t u32Param); void ADC_DisableHWTrigger(ADC_T *adc); void ADC_SetExtraSampleTime(ADC_T *adc, uint32_t u32ChNum, uint32_t u32SampleTime); void ADC_EnableInt(ADC_T *adc, uint32_t u32Mask); void ADC_DisableInt(ADC_T *adc, uint32_t u32Mask); void ADC_SeqModeEnable(ADC_T *adc, uint32_t u32SeqTYPE, uint32_t u32ModeSel); void ADC_SeqModeTriggerSrc(ADC_T *adc, uint32_t u32SeqModeTriSrc1, uint32_t u32SeqModeTriSrc2); #line 11940 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\fmc.h" #line 40 "..\\..\\..\\Library\\StdDriver\\inc\\fmc.h" #line 58 "..\\..\\..\\Library\\StdDriver\\inc\\fmc.h" #line 79 "..\\..\\..\\Library\\StdDriver\\inc\\fmc.h" extern void FMC_Close(void); extern int32_t FMC_Erase(uint32_t u32PageAddr); extern int32_t FMC_GetBootSource(void); extern void FMC_Open(void); extern uint32_t FMC_Read (uint32_t u32Addr); extern uint32_t FMC_ReadCID(void); extern uint32_t FMC_ReadPID(void); extern uint32_t FMC_ReadUCID(uint32_t u32Index); extern uint32_t FMC_ReadUID(uint32_t u32Index); extern uint32_t FMC_ReadDataFlashBaseAddr(void); extern void FMC_SetVectorPageAddr(uint32_t u32PageAddr); extern uint32_t FMC_GetVectorPageAddr(void); extern void FMC_Write(uint32_t u32Addr, uint32_t u32Data); extern int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count); extern int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count); extern int32_t FMC_GetCRC32Sum(uint32_t addr, uint32_t count, uint32_t *chksum); #line 11941 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\gpio.h" #line 81 "..\\..\\..\\Library\\StdDriver\\inc\\gpio.h" #line 143 "..\\..\\..\\Library\\StdDriver\\inc\\gpio.h" void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode); void GPIO_EnableInt(GPIO_T *gpio, uint32_t u32Pin, uint32_t u32IntAttribs); void GPIO_DisableInt(GPIO_T *gpio, uint32_t u32Pin); #line 11942 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\i2c.h" uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock); void I2C_Close(I2C_T *i2c); void I2C_ClearTimeoutFlag(I2C_T *i2c); void I2C_Trigger(I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack); void I2C_DisableInt(I2C_T *i2c); void I2C_EnableInt(I2C_T *i2c); uint32_t I2C_GetBusClockFreq(I2C_T *i2c); uint32_t I2C_SetBusClockFreq(I2C_T *i2c, uint32_t u32BusClock); uint32_t I2C_GetIntFlag(I2C_T *i2c); uint32_t I2C_GetStatus(I2C_T *i2c); uint32_t I2C_GetData(I2C_T *i2c); void I2C_SetData(I2C_T *i2c, uint8_t u8Data); void I2C_SetSlaveAddr(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddr, uint8_t u8GCMode); void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask); void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout); void I2C_DisableTimeout(I2C_T *i2c); void I2C_EnableWakeup(I2C_T *i2c); void I2C_DisableWakeup(I2C_T *i2c); #line 11943 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\pwm.h" #line 49 "..\\..\\..\\Library\\StdDriver\\inc\\pwm.h" #line 58 "..\\..\\..\\Library\\StdDriver\\inc\\pwm.h" #line 131 "..\\..\\..\\Library\\StdDriver\\inc\\pwm.h" uint32_t PWM_ConfigOutputChannel(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle); void PWM_Start(PWM_T *pwm, uint32_t u32ChannelMask); void PWM_Stop(PWM_T *pwm, uint32_t u32ChannelMask); void PWM_ForceStop(PWM_T *pwm, uint32_t u32ChannelMask); void PWM_EnableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition); void PWM_DisableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_ClearADCTriggerFlag(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition); uint32_t PWM_GetADCTriggerFlag (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition); void PWM_EnableFaultBrake(PWM_T *pwm, uint32_t u32ChannelMask, uint32_t u32LevelMask, uint32_t u32BrakeSource); void PWM_ClearFaultBrakeFlag(PWM_T *pwm, uint32_t u32BrakeSource); void PWM_EnableOutput(PWM_T *pwm, uint32_t u32ChannelMask); void PWM_DisableOutput(PWM_T *pwm, uint32_t u32ChannelMask); void PWM_EnableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration); void PWM_DisableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_EnableDutyInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType); void PWM_DisableDutyInt(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_ClearDutyIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); uint32_t PWM_GetDutyIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_EnableFaultBrakeInt(PWM_T *pwm, uint32_t u32BrakeSource); void PWM_DisableFaultBrakeInt(PWM_T *pwm, uint32_t u32BrakeSource); void PWM_ClearFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource); uint32_t PWM_GetFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource); void PWM_EnablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_DisablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_ClearPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); uint32_t PWM_GetPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_EnableCenterInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType); void PWM_DisableCenterInt(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_ClearCenterIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); uint32_t PWM_GetCenterIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_EnableRiseInt(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_DisableRiseInt(PWM_T *pwm, uint32_t u32ChannelNum); void PWM_ClearRiseIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); uint32_t PWM_GetRiseIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); #line 11944 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\spi.h" #line 50 "..\\..\\..\\Library\\StdDriver\\inc\\spi.h" static __inline void SPI_SET_SS_HIGH(SPI_T *spi) { spi->SSCTL &= ~(0x1ul << (3)); spi->SSCTL |= ((0x1ul << (5)) | (0x1ul << (2)) | (0x1ul << (0))); } static __inline void SPI_SET_SS_LOW(SPI_T *spi) { spi->SSCTL &= ~(0x1ul << (3)); spi->SSCTL |= (0x1ul << (5)); spi->SSCTL &= ~(0x1ul << (2)); spi->SSCTL |= (0x1ul << (0)); } static __inline void SPI_SET_DATA_WIDTH(SPI_T *spi, uint32_t u32Width) { if(u32Width == 32) u32Width = 0; spi->CTL = (spi->CTL & ~(0x1ful << (3))) | (u32Width << (3)); } uint32_t SPI_Open(SPI_T *spi, uint32_t u32MasterSlave, uint32_t u32SPIMode, uint32_t u32DataWidth, uint32_t u32BusClock); void SPI_Close(SPI_T *spi); void SPI_ClearRxFIFO(SPI_T *spi); void SPI_ClearTxFIFO(SPI_T *spi); void SPI_DisableAutoSS(SPI_T *spi); void SPI_EnableAutoSS(SPI_T *spi, uint32_t u32SSPinMask, uint32_t u32ActiveLevel); uint32_t SPI_SetBusClock(SPI_T *spi, uint32_t u32BusClock); void SPI_EnableFIFO(SPI_T *spi, uint32_t u32TxThreshold, uint32_t u32RxThreshold); void SPI_DisableFIFO(SPI_T *spi); uint32_t SPI_GetBusClock(SPI_T *spi); void SPI_EnableInt(SPI_T *spi, uint32_t u32Mask); void SPI_DisableInt(SPI_T *spi, uint32_t u32Mask); #line 11945 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\timer.h" #line 47 "..\\..\\..\\Library\\StdDriver\\inc\\timer.h" static __inline void TIMER_Start(TIMER_T *timer) { timer->CTL |= (0x1ul << (30)); } static __inline void TIMER_Stop(TIMER_T *timer) { timer->CTL &= ~(0x1ul << (30)); } static __inline void TIMER_EnableWakeup(TIMER_T *timer) { timer->CTL |= (0x1ul << (23)); } static __inline void TIMER_DisableWakeup(TIMER_T *timer) { timer->CTL &= ~(0x1ul << (23)); } static __inline void TIMER_EnableCaptureDebounce(TIMER_T *timer) { timer->EXTCTL |= (0x1ul << (6)); } static __inline void TIMER_DisableCaptureDebounce(TIMER_T *timer) { timer->EXTCTL &= ~(0x1ul << (6)); } static __inline void TIMER_EnableEventCounterDebounce(TIMER_T *timer) { timer->EXTCTL |= (0x1ul << (7)); } static __inline void TIMER_DisableEventCounterDebounce(TIMER_T *timer) { timer->EXTCTL &= ~(0x1ul << (7)); } static __inline void TIMER_EnableInt(TIMER_T *timer) { timer->CTL |= (0x1ul << (29)); } static __inline void TIMER_DisableInt(TIMER_T *timer) { timer->CTL &= ~(0x1ul << (29)); } static __inline void TIMER_EnableCaptureInt(TIMER_T *timer) { timer->EXTCTL |= (0x1ul << (5)); } static __inline void TIMER_DisableCaptureInt(TIMER_T *timer) { timer->EXTCTL &= ~(0x1ul << (5)); } static __inline uint32_t TIMER_GetIntFlag(TIMER_T *timer) { return(timer->INTSTS & (0x1ul << (0)) ? 1 : 0); } static __inline void TIMER_ClearIntFlag(TIMER_T *timer) { timer->INTSTS = (0x1ul << (0)); } static __inline uint32_t TIMER_GetCaptureIntFlag(TIMER_T *timer) { return timer->EINTSTS; } static __inline void TIMER_ClearCaptureIntFlag(TIMER_T *timer) { timer->EINTSTS = (0x1ul << (0)); } static __inline uint32_t TIMER_GetWakeupFlag(TIMER_T *timer) { return (timer->INTSTS & (0x1ul << (1)) ? 1 : 0); } static __inline void TIMER_ClearWakeupFlag(TIMER_T *timer) { timer->INTSTS = (0x1ul << (1)); } static __inline uint32_t TIMER_GetCaptureData(TIMER_T *timer) { return timer->CAP; } static __inline uint32_t TIMER_GetCounter(TIMER_T *timer) { return timer->CNT; } uint32_t TIMER_Open(TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq); void TIMER_Close(TIMER_T *timer); void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec); void TIMER_EnableCapture(TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge); void TIMER_DisableCapture(TIMER_T *timer); void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge); void TIMER_DisableEventCounter(TIMER_T *timer); uint32_t TIMER_GetModuleClock(TIMER_T *timer); #line 11946 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\uart.h" __inline void UART_CLEAR_RTS(UART_T* uart) { uart->MODEM |= (0x1ul << (9)); uart->MODEM &= ~(0x1ul << (1)); } __inline void UART_SET_RTS(UART_T* uart) { uart->MODEM |= (0x1ul << (9)) | (0x1ul << (1)); } void UART_ClearIntFlag(UART_T* uart , uint32_t u32InterruptFlag); void UART_Close(UART_T* uart ); void UART_DisableFlowCtrl(UART_T* uart ); void UART_DisableInt(UART_T* uart, uint32_t u32InterruptFlag ); void UART_EnableFlowCtrl(UART_T* uart ); void UART_EnableInt(UART_T* uart, uint32_t u32InterruptFlag ); void UART_Open(UART_T* uart, uint32_t u32baudrate); uint32_t UART_Read(UART_T* uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes); void UART_SetLine_Config(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits); void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC); void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction); void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr); uint32_t UART_Write(UART_T* uart,uint8_t *pu8TxBuf, uint32_t u32WriteBytes); #line 11947 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\wdt.h" #line 39 "..\\..\\..\\Library\\StdDriver\\inc\\wdt.h" void WDT_Open(uint32_t u32TimeoutInterval, uint32_t u32ResetDelay, uint32_t u32EnableReset, uint32_t u32EnableWakeup); void WDT_Close(void); void WDT_EnableInt(void); void WDT_DisableInt(void); #line 11948 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 1 "..\\..\\..\\Library\\StdDriver\\inc\\wwdt.h" #line 47 "..\\..\\..\\Library\\StdDriver\\inc\\wwdt.h" void WWDT_Open(uint32_t u32PreScale, uint32_t u32CmpValue, uint32_t u32EnableInt); #line 11949 "..\\..\\..\\Library\\Device\\Nuvoton\\Mini58Series\\Include\\Mini58Series.h" #line 12 "..\\..\\..\\Library\\StdDriver\\src\\sys.c" void SYS_ClearResetSrc(uint32_t u32Src) { ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->RSTSTS |= u32Src; } uint32_t SYS_GetBODStatus(void) { return (((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL & (0x1ul << (6)))?1:0; } uint32_t SYS_GetResetSrc(void) { return (((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->RSTSTS); } uint32_t SYS_IsRegLocked(void) { return !(((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->REGLCTL & (0xfful << (0))); } uint32_t SYS_ReadPDID(void) { return ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->PDID; } void SYS_ResetChip(void) { ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->IPRST0 |= (0x1ul << (0)); } void SYS_ResetCPU(void) { ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->IPRST0 |= (0x1ul << (1)); } void SYS_ResetModule(uint32_t u32ModuleIndex) { *(volatile uint32_t *)(&(((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->IPRST0) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff); *(volatile uint32_t *)(&(((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->IPRST0) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff)); } void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel) { ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL |= (0x1ul << (0)); ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL = (((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL & ~(0x1ul << (3))) | i32Mode; ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL = (((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL & ~(0x3ul << (1))) | u32BODLevel; } void SYS_DisableBOD(void) { ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL &= ~(0x1ul << (0)); ((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL = (((SYS_T *) (((uint32_t)0x50000000) + 0x00000))->BODCTL & ~(0x3ul << (1))) | (0x3ul << (1)) ; }