/** * @file HwA_mpu.h * @author Flagchip085 * @brief FC7xxx MPU hardware access layer * @version 0.1.0 * @date 2024-01-12 * * @copyright Copyright (c) 2024 Flagchip Semiconductors Co., Ltd. * */ /* ******************************************************************************** * Revision History: * * Version Date Initials CR# Descriptions * --------- ---------- ------------ ---------- --------------- * 0.1.0 2024-01-12 Flagchip085 N/A First version for FC7240 ******************************************************************************** */ #ifndef _HWA_MPU_H_ #define _HWA_MPU_H_ #include "device_header.h" /** * @brief The MPU registers struct * */ typedef struct { __I uint32_t MPU_TYPE; /* TYPE, offset: 0x0 */ __IO uint32_t MPU_CTRL; /* CTRL, offset: 0x4 */ __IO uint32_t MPU_RNR; /* RNR, offset: 0x8 */ __IO uint32_t MPU_RBAR; /* RBAR, offset: 0xC */ __IO uint32_t MPU_RASR; /* RASR, offset: 0x10 */ } CORTEX_MPU_Type, *PCORTEX_MPU_Type; /** mpu base Address */ #define CORTEX_MPU_BASE (0xE000ED90U) #define CORTEX_MPU ((CORTEX_MPU_Type *)CORTEX_MPU_BASE) /** TYPE Bit Fields **/ #define CORTEX_MPU_TYPE_IREGION_MASK 0xFF0000U #define CORTEX_MPU_TYPE_IREGION_SHIFT 16U #define CORTEX_MPU_TYPE_IREGION_WIDTH 8U #define CORTEX_MPU_TYPE_IREGION(x) (((uint32_t)(((uint32_t)(x))<MPU_TYPE; } /** * @brief disable fault exceptions * * */ LOCAL_INLINE void MPU_HWA_Fault_Disable(void) { SCB->SHCSR &= ~((uint32_t)SCB_SHCSR_MEMFAULTENA_Msk); } /** * @brief enable fault exceptions * * */ LOCAL_INLINE void MPU_HWA_Fault_Enable(void) { SCB->SHCSR |= (uint32_t)SCB_SHCSR_MEMFAULTENA_Msk; } /** * @brief set mpu control register * * @param u32RegValue the value write to register * @return LOCAL_INLINE */ LOCAL_INLINE void MPU_HWA_Set_CR(uint32_t u32RegValue) { CORTEX_MPU->MPU_CTRL = u32RegValue; } /** * @brief set mpu number register * * @param u32RegValue the value write to register * @return LOCAL_INLINE */ LOCAL_INLINE void MPU_HWA_Set_NR(uint8_t u32RegValue) { CORTEX_MPU->MPU_RNR = (MPU_REGION_MASK_U32 & u32RegValue); } /** * @brief set mpu base address register * * @param u32RegValue the value write to register * @return LOCAL_INLINE */ LOCAL_INLINE void MPU_HWA_Set_BAR(uint32_t u32RegValue) { CORTEX_MPU->MPU_RBAR = u32RegValue; } /** * @brief set mpu attribute and size register * * @param u32RegValue the value write to registe * @return LOCAL_INLINE */ LOCAL_INLINE void MPU_HWA_Set_ASR(uint32_t u32RegValue) { CORTEX_MPU->MPU_RASR = u32RegValue; } #endif /* _HWA_MPU_H_ */