/**************************************************************************//** * @file SYS.h * @version V1.0 * $Revision 1 $ * $Date: 15/10/21 1:35p $ * @brief NUC472/NUC442 SYS Header File * * @note * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. ******************************************************************************/ #ifndef __SYS_H__ #define __SYS_H__ #ifdef __cplusplus extern "C" { #endif /** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver @{ */ /** @addtogroup NUC472_442_SYS_Driver SYS Driver @{ */ /** @addtogroup NUC472_442_SYS_EXPORTED_CONSTANTS SYS Exported Constants @{ */ /*---------------------------------------------------------------------------------------------------------*/ /* Module Reset Control Resister constant definitions. */ /*---------------------------------------------------------------------------------------------------------*/ #define PDMA_RST ((0x0<<24)|SYS_IPRST0_PDMARST_Pos) /*!GPA_MFPL = (SYS->GPA_MFPL & (~SYS_GPA_MFPL_PA0MFP_Msk) ) | SYS_GPA_MFPL_PA0MFP_SC0_CD ; */ //GPA_MFPL_PA0MFP #define SYS_GPA_MFPL_PA0MFP_GPIO (0x0UL<BODCTL |= SYS_BODCTL_BODINTF_Msk) /** * @brief Set Brown-out detector function to normal mode * @param None * @return None * @details This macro set Brown-out detector to normal mode. */ #define SYS_CLEAR_BOD_LPM() (SYS->BODCTL &= ~SYS_BODCTL_BODLPM_Msk) /** * @brief Disable Brown-out detector function * @param None * @return None * @details This macro disable Brown-out detector function. */ #define SYS_DISABLE_BOD() (SYS->BODCTL &= ~SYS_BODCTL_BODEN_Msk) /** * @brief Enable Brown-out detector function * @param None * @return None * @details This macro enable Brown-out detector function. */ #define SYS_ENABLE_BOD() (SYS->BODCTL |= SYS_BODCTL_BODEN_Msk) /** * @brief Get Brown-out detector interrupt flag * @param None * @retval 0 Brown-out detect interrupt flag is not set. * @retval >=1 Brown-out detect interrupt flag is set. * @details This macro get Brown-out detector interrupt flag. */ #define SYS_GET_BOD_INT_FLAG() (SYS->BODCTL & SYS_BODCTL_BODINTF_Msk) /** * @brief Get Brown-out detector status * @param None * @retval 0 System voltage is higher than BOD_VL setting or BOD_EN is 0. * @retval >=1 System voltage is lower than BOD_VL setting. * @details This macro get Brown-out detector output status. * If the BOD_EN is 0, this function always return 0. */ #define SYS_GET_BOD_OUTPUT() (SYS->BODCTL & SYS_BODCTL_BODOUT_Msk) /** * @brief Disable Brown-out detector interrupt function * @param None * @return None * @details This macro enable Brown-out detector interrupt function. */ #define SYS_DISABLE_BOD_RST() (SYS->BODCTL &= ~SYS_BODCTL_BODRSTEN_Msk) /** * @brief Enable Brown-out detector reset function * @param None * @return None * @details This macro enable Brown-out detect reset function. */ #define SYS_ENABLE_BOD_RST() (SYS->BODCTL |= SYS_BODCTL_BODRSTEN_Msk) /** * @brief Set Brown-out detector function low power mode * @param None * @return None * @details This macro set Brown-out detector to low power mode. */ #define SYS_SET_BOD_LPM() (SYS->BODCTL |= SYS_BODCTL_BODLPM_Msk) /** * @brief Set Brown-out detector voltage level * @param[in] u32Level is Brown-out voltage level. Including : * - \ref SYS_BODCTL_BODVL_4_5V * - \ref SYS_BODCTL_BODVL_3_8V * - \ref SYS_BODCTL_BODVL_2_7V * - \ref SYS_BODCTL_BODVL_2_2V * @return None * @details This macro set Brown-out detector voltage level. */ #define SYS_SET_BOD_LEVEL(u32Level) (SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODVL_Msk) | u32Level) /** * @brief Get reset source is from Brown-out detector reset * @param None * @retval 0 Previous reset source is not from Brown-out detector reset * @retval >=1 Previous reset source is from Brown-out detector reset * @details This macro get previous reset source is from Brown-out detect reset or not. */ #define SYS_IS_BOD_RST() (SYS->RSTSTS & SYS_RSTSTS_BODRF_Msk) /** * @brief Get reset source is from CPU reset * @param None * @retval 0 Previous reset source is not from CPU reset * @retval >=1 Previous reset source is from CPU reset * @details This macro get previous reset source is from CPU reset. */ #define SYS_IS_CPU_RST() (SYS->RSTSTS & SYS_RSTSTS_CPURF_Msk) /** * @brief Get reset source is from LVR Reset * @param None * @retval 0 Previous reset source is not from LVR Reset * @retval >=1 Previous reset source is from LVR Reset * @details This macro get previous reset source is from Power-on Reset. */ #define SYS_IS_LVR_RST() (SYS->RSTSTS & SYS_RSTSTS_LVRF_Msk) /** * @brief Get reset source is from Power-on Reset * @param None * @retval 0 Previous reset source is not from Power-on Reset * @retval >=1 Previous reset source is from Power-on Reset * @details This macro get previous reset source is from Power-on Reset. */ #define SYS_IS_POR_RST() (SYS->RSTSTS & SYS_RSTSTS_PORF_Msk) /** * @brief Get reset source is from reset pin reset * @param None * @retval 0 Previous reset source is not from reset pin reset * @retval >=1 Previous reset source is from reset pin reset * @details This macro get previous reset source is from reset pin reset. */ #define SYS_IS_RSTPIN_RST() (SYS->RSTSTS & SYS_RSTSTS_PINRF_Msk) /** * @brief Get reset source is from system reset * @param None * @retval 0 Previous reset source is not from system reset * @retval >=1 Previous reset source is from system reset * @details This macro get previous reset source is from system reset. */ #define SYS_IS_SYSTEM_RST() (SYS->RSTSTS & SYS_RSTSTS_SYSRF_Msk) /** * @brief Get reset source is from window watch dog reset * @param None * @retval 0 Previous reset source is not from window watch dog reset * @retval >=1 Previous reset source is from window watch dog reset * @details This macro get previous reset source is from window watch dog reset. */ #define SYS_IS_WDT_RST() (SYS->RSTSTS & SYS_RSTSTS_WDTRF_Msk) /** * @brief Disable Low-Voltage-Reset function * @param None * @return None * @details This macro disable Low-Voltage-Reset function. */ #define SYS_DISABLE_LVR() (SYS->BODCTL &= ~SYS_BODCTL_LVREN_Msk) /** * @brief Enable Low-Voltage-Reset function * @param None * @return None * @details This macro enable Low-Voltage-Reset function. */ #define SYS_ENABLE_LVR() (SYS->BODCTL |= SYS_BODCTL_LVREN_Msk) /** * @brief Disable Power-on Reset function * @param None * @return None * @details This macro disable Power-on Reset function. */ #define SYS_DISABLE_POR() (SYS->PORCTL = 0x5AA5) /** * @brief Enable Power-on Reset function * @param None * @return None * @details This macro enable Power-on Reset function. */ #define SYS_ENABLE_POR() (SYS->PORCTL = 0) /** * @brief Clear reset source flag * @param[in] u32RstSrc is reset source. Including: * - \ref SYS_RSTSTS_PORF_Msk * - \ref SYS_RSTSTS_PINRF_Msk * - \ref SYS_RSTSTS_WDTRF_Msk * - \ref SYS_RSTSTS_LVRF_Msk * - \ref SYS_RSTSTS_BODRF_Msk * - \ref SYS_RSTSTS_SYSRF_Msk * - \ref SYS_RSTSTS_CPURF_Msk * @return None * @details This macro clear reset source flag. */ #define SYS_CLEAR_RST_SOURCE(u32RstSrc) (SYS->RSTSTS = u32RstSrc ) void SYS_ClearResetSrc(uint32_t u32Src); uint32_t SYS_GetBODStatus(void); uint32_t SYS_GetResetSrc(void); uint32_t SYS_IsRegLocked(void); void SYS_LockReg(void); void SYS_UnlockReg(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); /*@}*/ /* end of group NUC472_442_SYS_EXPORTED_FUNCTIONS */ /*@}*/ /* end of group NUC472_442_SYS_Driver */ /*@}*/ /* end of group NUC472_442_Device_Driver */ #ifdef __cplusplus } #endif #endif //__SYS_H__ /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/