1 /**************************************************************************//** 2 * @file dpm.h 3 * @version V3.00 4 * @brief Debug Protection Mechanism (DPM) driver header file 5 * 6 * @copyright SPDX-License-Identifier: Apache-2.0 7 * @copyright Copyright (C) 2020 Nuvoton Technology Corp. All rights reserved. 8 *****************************************************************************/ 9 #ifndef __DPM_H__ 10 #define __DPM_H__ 11 12 #ifdef __cplusplus 13 extern "C" 14 { 15 #endif 16 17 18 /** @addtogroup Standard_Driver Standard Driver 19 @{ 20 */ 21 22 /** @addtogroup DPM_Driver DPM Driver 23 @{ 24 */ 25 26 /** @addtogroup DPM_EXPORTED_CONSTANTS DPM Exported Constants 27 @{ 28 */ 29 30 31 /*---------------------------------------------------------------------------------------------------------*/ 32 /* DPM Control Register Constant Definitions */ 33 /*---------------------------------------------------------------------------------------------------------*/ 34 #define SECURE_DPM 0 /*!< Secure DPM module */ 35 #define NONSECURE_DPM 1 /*!< Non-secure DPM module */ 36 37 38 #define DPM_CTL_WVCODE (0x5AUL<<DPM_CTL_WVCODE_Pos) /*!< Secure DPM control register write verify code */ 39 #define DPM_CTL_RVCODE (0xA5UL<<DPM_CTL_RVCODE_Pos) /*!< Secure DPM control register read verify code */ 40 #define DPM_NSCTL_WVCODE (0x5AUL<<DPM_CTL_WVCODE_Pos) /*!< Non-secure DPM control register write verify code */ 41 #define DPM_NSCTL_RVCODE (0xA5UL<<DPM_CTL_RVCODE_Pos) /*!< Non-secure DPM control register read verify code */ 42 43 44 45 /**@}*/ /* end of group WDT_EXPORTED_CONSTANTS */ 46 47 48 /** @addtogroup DPM_EXPORTED_FUNCTIONS DPM Exported Functions 49 @{ 50 */ 51 52 53 /** 54 * @brief Enable DPM Interrupt 55 * @param None 56 * @return None 57 * @details This macro enables DPM interrupt. 58 * This macro is for Secure DPM and Secure region only. 59 */ 60 #define DPM_ENABLE_INT() \ 61 do{ \ 62 while(DPM->STS & DPM_STS_BUSY_Msk); \ 63 DPM->CTL = (DPM->CTL & (~DPM_CTL_WVCODE_Msk)) | (DPM_CTL_WVCODE|DPM_CTL_INTEN_Msk); \ 64 }while(0) 65 66 /** 67 * @brief Disable DPM Interrupt 68 * @param None 69 * @return None 70 * @details This macro disables DPM interrupt. 71 * This macro is for Secure DPM and Secure region only. 72 */ 73 #define DPM_DISABLE_INT() \ 74 do{ \ 75 while(DPM->STS & DPM_STS_BUSY_Msk); \ 76 DPM->CTL = (DPM->CTL & (~(DPM_CTL_WVCODE_Msk|DPM_CTL_INTEN_Msk))) | (DPM_CTL_WVCODE); \ 77 }while(0) 78 79 /** 80 * @brief Enable Debugger to Access DPM Registers 81 * @param None 82 * @return None 83 * @details This macro enables debugger to access Secure and Non-secure DPM registers. 84 * This macro is for Secure DPM and Secure region only. 85 */ 86 #define DPM_ENABLE_DBG_ACCESS() \ 87 do{ \ 88 while(DPM->STS & DPM_STS_BUSY_Msk); \ 89 DPM->CTL = (DPM->CTL & (~(DPM_CTL_WVCODE_Msk|DPM_CTL_DACCDIS_Msk))) | (DPM_CTL_WVCODE); \ 90 }while(0) 91 92 /** 93 * @brief Disable Debugger to Access DPM Registers 94 * @param None 95 * @return None 96 * @details This macro disables debugger to access Secure and Non-secure DPM registers. 97 * This macro is for Secure DPM and Secure region only. 98 */ 99 #define DPM_DISABLE_DBG_ACCESS() \ 100 do{ \ 101 while(DPM->STS & DPM_STS_BUSY_Msk); \ 102 DPM->CTL = (DPM->CTL & (~DPM_CTL_WVCODE_Msk)) | (DPM_CTL_WVCODE|DPM_CTL_DACCDIS_Msk); \ 103 }while(0) 104 105 106 void DPM_SetDebugDisable(uint32_t u32dpm); 107 void DPM_SetDebugLock(uint32_t u32dpm); 108 uint32_t DPM_GetDebugDisable(uint32_t u32dpm); 109 uint32_t DPM_GetDebugLock(uint32_t u32dpm); 110 uint32_t DPM_SetPasswordUpdate(uint32_t u32dpm, uint32_t au32Pwd[]); 111 uint32_t DPM_SetPasswordCompare(uint32_t u32dpm, uint32_t au32Pwd[]); 112 uint32_t DPM_GetPasswordErrorFlag(uint32_t u32dpm); 113 uint32_t DPM_GetIntFlag(void); 114 void DPM_ClearPasswordErrorFlag(uint32_t u32dpm); 115 void DPM_EnableDebuggerWriteAccess(uint32_t u32dpm); 116 void DPM_DisableDebuggerWriteAccess(uint32_t u32dpm); 117 118 119 120 /**@}*/ /* end of group DPM_EXPORTED_FUNCTIONS */ 121 122 /**@}*/ /* end of group DPM_Driver */ 123 124 /**@}*/ /* end of group Standard_Driver */ 125 126 #ifdef __cplusplus 127 } 128 #endif 129 130 #endif /* __DPM_H__ */ 131