/**************************************************************************//** * @file SYS.h * @brief SYS Driver Header File * * SPDX-License-Identifier: Apache-2.0 * @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved. ******************************************************************************/ #ifndef __NU_SYS_H__ #define __NU_SYS_H__ #ifdef __cplusplus extern "C" { #endif /** @addtogroup Standard_Driver Standard Driver @{ */ /** @addtogroup SYS_Driver SYS Driver @{ */ /** @addtogroup SYS_EXPORTED_CONSTANTS SYS Exported Constants @{ */ /*---------------------------------------------------------------------------------------------------------*/ /* Module Reset Control Resister constant definitions. */ /*---------------------------------------------------------------------------------------------------------*/ #define PDMA0_RST ((0UL<<24) | SYS_IPRST0_PDMA0RST_Pos) /*!< Reset PDMA0 \hideinitializer */ #define PDMA1_RST ((0UL<<24) | SYS_IPRST0_PDMA1RST_Pos) /*!< Reset PDMA1 \hideinitializer */ #define PDMA2_RST ((0UL<<24) | SYS_IPRST0_PDMA2RST_Pos) /*!< Reset PDMA2 \hideinitializer */ #define PDMA3_RST ((0UL<<24) | SYS_IPRST0_PDMA3RST_Pos) /*!< Reset PDMA3 \hideinitializer */ #define DISPC_RST ((0UL<<24) | SYS_IPRST0_DISPCRST_Pos) /*!< Reset DISPC \hideinitializer */ #define CCAP0_RST ((0UL<<24) | SYS_IPRST0_CCAP0RST_Pos) /*!< Reset CCAP0 \hideinitializer */ #define CCAP1_RST ((0UL<<24) | SYS_IPRST0_CCAP1RST_Pos) /*!< Reset CCAP1 \hideinitializer */ #define GFX_RST ((0UL<<24) | SYS_IPRST0_GFXRST_Pos) /*!< Reset GFX \hideinitializer */ #define VDEC_RST ((0UL<<24) | SYS_IPRST0_VDECRST_Pos) /*!< Reset VDEC \hideinitializer */ #define WHC0_RST ((0UL<<24) | SYS_IPRST0_WRHO0RST_Pos) /*!< Reset WRHO0 \hideinitializer */ #define WHC1_RST ((0UL<<24) | SYS_IPRST0_WRHO1RST_Pos) /*!< Reset WRHO1 \hideinitializer */ #define GMAC0_RST ((0UL<<24) | SYS_IPRST0_GMAC0RST_Pos) /*!< Reset GMAC0 \hideinitializer */ #define GMAC1_RST ((0UL<<24) | SYS_IPRST0_GMAC1RST_Pos) /*!< Reset GMAC1 \hideinitializer */ #define HWSEM0_RST ((0UL<<24) | SYS_IPRST0_HWSEMRST_Pos) /*!< Reset HWSEM \hideinitializer */ #define EBI_RST ((0UL<<24) | SYS_IPRST0_EBIRST_Pos) /*!< Reset EBI \hideinitializer */ #define HSUSBH0_RST ((0UL<<24) | SYS_IPRST0_HSUSBH0RST_Pos) /*!< Reset HSUSBH0 \hideinitializer */ #define HSUSBH1_RST ((0UL<<24) | SYS_IPRST0_HSUSBH1RST_Pos) /*!< Reset HSUSBH1 \hideinitializer */ #define HSUSBD_RST ((0UL<<24) | SYS_IPRST0_HSUSBDRST_Pos) /*!< Reset HSUSBD \hideinitializer */ #define USBHL_RST ((0UL<<24) | SYS_IPRST0_USBHLRST_Pos) /*!< Reset USBHL \hideinitializer */ #define SDH0_RST ((0UL<<24) | SYS_IPRST0_SDH0RST_Pos) /*!< Reset SDH0 \hideinitializer */ #define SDH1_RST ((0UL<<24) | SYS_IPRST0_SDH1RST_Pos) /*!< Reset SDH1 \hideinitializer */ #define NAND_RST ((0UL<<24) | SYS_IPRST0_NANDRST_Pos) /*!< Reset NAND \hideinitializer */ #define GPIO_RST ((0UL<<24) | SYS_IPRST0_GPIORST_Pos) /*!< Reset GPIO \hideinitializer */ #define MCTLP_RST ((0UL<<24) | SYS_IPRST0_MCTLPRST_Pos) /*!< Reset MCTLP \hideinitializer */ #define MCTLC_RST ((0UL<<24) | SYS_IPRST0_MCTLCRST_Pos) /*!< Reset MCTLC \hideinitializer */ #define DDRPUB_RST ((0UL<<24) | SYS_IPRST0_DDRPUBRST_Pos) /*!< Reset DDRPUB \hideinitializer */ #define TMR0_RST ((4UL<<24) | SYS_IPRST1_TMR0RST_Pos) /*!< Reset TMR0 \hideinitializer */ #define TMR1_RST ((4UL<<24) | SYS_IPRST1_TMR1RST_Pos) /*!< Reset TMR1 \hideinitializer */ #define TMR2_RST ((4UL<<24) | SYS_IPRST1_TMR2RST_Pos) /*!< Reset TMR2 \hideinitializer */ #define TMR3_RST ((4UL<<24) | SYS_IPRST1_TMR3RST_Pos) /*!< Reset TMR3 \hideinitializer */ #define I2C0_RST ((4UL<<24) | SYS_IPRST1_I2C0RST_Pos) /*!< Reset I2C0 \hideinitializer */ #define I2C1_RST ((4UL<<24) | SYS_IPRST1_I2C1RST_Pos) /*!< Reset I2C1 \hideinitializer */ #define I2C2_RST ((4UL<<24) | SYS_IPRST1_I2C2RST_Pos) /*!< Reset I2C2 \hideinitializer */ #define I2C3_RST ((4UL<<24) | SYS_IPRST1_I2C3RST_Pos) /*!< Reset I2C3 \hideinitializer */ #define QSPI0_RST ((4UL<<24) | SYS_IPRST1_QSPI0RST_Pos) /*!< Reset QSPI0 \hideinitializer */ #define SPI0_RST ((4UL<<24) | SYS_IPRST1_SPI0RST_Pos) /*!< Reset SPI0 \hideinitializer */ #define SPI1_RST ((4UL<<24) | SYS_IPRST1_SPI1RST_Pos) /*!< Reset SPI1 \hideinitializer */ #define SPI2_RST ((4UL<<24) | SYS_IPRST1_SPI2RST_Pos) /*!< Reset SPI2 \hideinitializer */ #define UART0_RST ((4UL<<24) | SYS_IPRST1_UART0RST_Pos) /*!< Reset UART0 \hideinitializer */ #define UART1_RST ((4UL<<24) | SYS_IPRST1_UART1RST_Pos) /*!< Reset UART1 \hideinitializer */ #define UART2_RST ((4UL<<24) | SYS_IPRST1_UART2RST_Pos) /*!< Reset UART2 \hideinitializer */ #define UART3_RST ((4UL<<24) | SYS_IPRST1_UART3RST_Pos) /*!< Reset UART3 \hideinitializer */ #define UART4_RST ((4UL<<24) | SYS_IPRST1_UART4RST_Pos) /*!< Reset UART4 \hideinitializer */ #define UART5_RST ((4UL<<24) | SYS_IPRST1_UART5RST_Pos) /*!< Reset UART5 \hideinitializer */ #define UART6_RST ((4UL<<24) | SYS_IPRST1_UART6RST_Pos) /*!< Reset UART6 \hideinitializer */ #define UART7_RST ((4UL<<24) | SYS_IPRST1_UART7RST_Pos) /*!< Reset UART7 \hideinitializer */ #define CANFD0_RST ((4UL<<24) | SYS_IPRST1_CANFD0RST_Pos) /*!< Reset MCAN0 \hideinitializer */ #define CANFD1_RST ((4UL<<24) | SYS_IPRST1_CANFD1RST_Pos) /*!< Reset MCAN1 \hideinitializer */ #define EADC0_RST ((4UL<<24) | SYS_IPRST1_EADC0RST_Pos) /*!< Reset EADC0 \hideinitializer */ #define I2S0_RST ((4UL<<24) | SYS_IPRST1_I2S0RST_Pos) /*!< Reset I2S0 \hideinitializer */ #define SC0_RST ((8UL<<24) | SYS_IPRST2_SC0RST_Pos) /*!< Reset SC0 \hideinitializer */ #define SC1_RST ((8UL<<24) | SYS_IPRST2_SC1RST_Pos) /*!< Reset SC1 \hideinitializer */ #define QSPI1_RST ((8UL<<24) | SYS_IPRST2_QSPI1RST_Pos) /*!< Reset QSPI1 \hideinitializer */ #define SPI3_RST ((8UL<<24) | SYS_IPRST2_SPI3RST_Pos) /*!< Reset SPI3 \hideinitializer */ #define EPWM0_RST ((8UL<<24) | SYS_IPRST2_EPWM0RST_Pos) /*!< Reset EPWM0 \hideinitializer */ #define EPWM1_RST ((8UL<<24) | SYS_IPRST2_EPWM1RST_Pos) /*!< Reset EPWM1 \hideinitializer */ #define QEI0_RST ((8UL<<24) | SYS_IPRST2_QEI0RST_Pos) /*!< Reset QEI0 \hideinitializer */ #define QEI1_RST ((8UL<<24) | SYS_IPRST2_QEI1RST_Pos) /*!< Reset QEI1 \hideinitializer */ #define ECAP0_RST ((8UL<<24) | SYS_IPRST2_ECAP0RST_Pos) /*!< Reset ECAP0 \hideinitializer */ #define ECAP1_RST ((8UL<<24) | SYS_IPRST2_ECAP1RST_Pos) /*!< Reset ECAP1 \hideinitializer */ #define CANFD2_RST ((8UL<<24) | SYS_IPRST2_CANFD2RST_Pos) /*!< Reset CANFD2 \hideinitializer */ #define ADC0_RST ((8UL<<24) | SYS_IPRST2_ADC0RST_Pos) /*!< Reset ADC0 \hideinitializer */ #define TMR4_RST ((12UL<<24) | SYS_IPRST3_TMR4RST_Pos) /*!< Reset TMR4 \hideinitializer */ #define TMR5_RST ((12UL<<24) | SYS_IPRST3_TMR5RST_Pos) /*!< Reset TMR5 \hideinitializer */ #define TMR6_RST ((12UL<<24) | SYS_IPRST3_TMR6RST_Pos) /*!< Reset TMR6 \hideinitializer */ #define TMR7_RST ((12UL<<24) | SYS_IPRST3_TMR7RST_Pos) /*!< Reset TMR7 \hideinitializer */ #define TMR8_RST ((12UL<<24) | SYS_IPRST3_TMR8RST_Pos) /*!< Reset TMR8 \hideinitializer */ #define TMR9_RST ((12UL<<24) | SYS_IPRST3_TMR9RST_Pos) /*!< Reset TMR9 \hideinitializer */ #define TMR10_RST ((12UL<<24) | SYS_IPRST3_TMR10RST_Pos) /*!< Reset TMR10 \hideinitializer */ #define TMR11_RST ((12UL<<24) | SYS_IPRST3_TMR11RST_Pos) /*!< Reset TMR11 \hideinitializer */ #define UART8_RST ((12UL<<24) | SYS_IPRST3_UART8RST_Pos) /*!< Reset UART8 \hideinitializer */ #define UART9_RST ((12UL<<24) | SYS_IPRST3_UART9RST_Pos) /*!< Reset UART9 \hideinitializer */ #define UART10_RST ((12UL<<24) | SYS_IPRST3_UART10RST_Pos) /*!< Reset UART10 \hideinitializer */ #define UART11_RST ((12UL<<24) | SYS_IPRST3_UART11RST_Pos) /*!< Reset UART11 \hideinitializer */ #define UART12_RST ((12UL<<24) | SYS_IPRST3_UART12RST_Pos) /*!< Reset UART12 \hideinitializer */ #define UART13_RST ((12UL<<24) | SYS_IPRST3_UART13RST_Pos) /*!< Reset UART13 \hideinitializer */ #define UART14_RST ((12UL<<24) | SYS_IPRST3_UART14RST_Pos) /*!< Reset UART14 \hideinitializer */ #define UART15_RST ((12UL<<24) | SYS_IPRST3_UART15RST_Pos) /*!< Reset UART15 \hideinitializer */ #define UART16_RST ((12UL<<24) | SYS_IPRST3_UART16RST_Pos) /*!< Reset UART16 \hideinitializer */ #define I2S1_RST ((12UL<<24) | SYS_IPRST3_I2S1RST_Pos) /*!< Reset I2S1 \hideinitializer */ #define I2C4_RST ((12UL<<24) | SYS_IPRST3_I2C4RST_Pos) /*!< Reset I2C4 \hideinitializer */ #define I2C5_RST ((12UL<<24) | SYS_IPRST3_I2C5RST_Pos) /*!< Reset I2C5 \hideinitializer */ #define EPWM2_RST ((12UL<<24) | SYS_IPRST3_EPWM2RST_Pos) /*!< Reset EPWM2 \hideinitializer */ #define ECAP2_RST ((12UL<<24) | SYS_IPRST3_ECAP2RST_Pos) /*!< Reset ECAP2 \hideinitializer */ #define QEI2_RST ((12UL<<24) | SYS_IPRST3_QEI2RST_Pos) /*!< Reset QEI2 \hideinitializer */ #define CANFD3_RST ((12UL<<24) | SYS_IPRST3_CANFD3RST_Pos) /*!< Reset MCAN3 \hideinitializer */ #define KPI_RST ((12UL<<24) | SYS_IPRST3_KPIRST_Pos) /*!< Reset KPI \hideinitializer */ #define GIC_RST ((12UL<<24) | SYS_IPRST3_GICRST_Pos) /*!< Reset GIC \hideinitializer */ #define SSMCC_RST ((12UL<<24) | SYS_IPRST3_SSMCCRST_Pos) /*!< Reset SSMCC \hideinitializer */ #define SSPCC_RST ((12UL<<24) | SYS_IPRST3_SSPCCRST_Pos) /*!< Reset SSPCC \hideinitializer */ /*---------------------------------------------------------------------------------------------------------*/ /* Multi-Function constant definitions. */ /*---------------------------------------------------------------------------------------------------------*/ /* How to use below #define? Example 1: If user want to set PA.0 as SC0_CLK in initial function, user can issue following command to achieve it. SYS->GPA_MFPL = (SYS->GPA_MFPL & (~SYS_GPA_MFPL_PA0MFP_Msk) ) | SYS_GPA_MFPL_PA0_MFP_SC0_CLK ; */ /********************* Bit definition of GPA_MFPL register **********************/ #define SYS_GPA_MFPL_PA0MFP_GPIO (0x00UL<RLKSUBM = 0x59UL; SYS->RLKSUBM = 0x16UL; SYS->RLKSUBM = 0x88UL; } while (SYS->RLKSUBM == 0UL); #else do { SYS->RLKTZS = 0x59UL; SYS->RLKTZS = 0x16UL; SYS->RLKTZS = 0x88UL; } while (SYS->RLKTZS == 0UL); #endif } /** * @brief Enable register write-protection function * @param None * @return None * @details This function is used to enable register write-protection function. * To lock the protected register to forbid write access. */ __STATIC_INLINE void SYS_LockReg(void) { #if defined(USE_MA35D1_SUBM) SYS->RLKSUBM = 0UL; #else SYS->RLKTZS = 0UL; #endif } /** * @brief Query write-protection is locked or not * @param None * @return true or false * @details */ __STATIC_INLINE uint32_t SYS_IsRegLocked(void) { #if defined(USE_MA35D1_SUBM) return (SYS->RLKSUBM == 0) ? 1 : 0; #else return (SYS->RLKTZS == 0) ? 1 : 0; #endif } void SYS_ResetModule(uint32_t u32ModuleIndex); /*@}*/ /* end of group SYS_EXPORTED_FUNCTIONS */ /*@}*/ /* end of group SYS_Driver */ /*@}*/ /* end of group Standard_Driver */ #ifdef __cplusplus } #endif #endif /* __NU_SYS_H__ */