Beispiel #1
0
/*FUNCTION**********************************************************************
 *
 * Function Name : MPU_DRV_Init
 * Description   : MPU module init.
 * This function is used to initialize MPU regions.
 *
 *END**************************************************************************/
mpu_status_t MPU_DRV_Init(uint32_t instance, mpu_user_config_t *userConfigPtr, mpu_state_t *userStatePtr)
{
    assert(instance < HW_MPU_INSTANCE_COUNT);
    
    uint32_t baseAddr = g_mpuBaseAddr[instance];
    
    CLOCK_SYS_EnableMpuClock(instance);
    
    if(!userConfigPtr)
    {
        return kStatus_MPU_NullArgument;
    }
        
    MPU_HAL_Init(baseAddr);
    
    while(userConfigPtr)
    {
        MPU_DRV_RegionInit(instance, &(userConfigPtr->regionConfig));
        userConfigPtr = userConfigPtr->next;
    }
    
    mpu_state_ptrs[instance] = userStatePtr;
    
    MPU_HAL_Enable(baseAddr);
    
    return kStatus_MPU_Success;
}
/*FUNCTION**********************************************************************
 *
 * Function Name : MPU_DRV_Init
 * Description   : MPU module init.
 * This function is used to initialize MPU regions.
 *
 *END**************************************************************************/
mpu_status_t MPU_DRV_Init(uint32_t instance, const mpu_user_config_t *userConfigPtr)
{
    assert(instance < MPU_INSTANCE_COUNT);
    MPU_Type * base = g_mpuBase[instance];
    if(!userConfigPtr)
    {
        return kStatus_MPU_NullArgument;
    }
    CLOCK_SYS_EnableMpuClock(instance); 
    MPU_HAL_Init(base);
    while(userConfigPtr)
    {
        MPU_DRV_SetRegionConfig(instance, &(userConfigPtr->regionConfig));
        userConfigPtr = userConfigPtr->next;
    }
    MPU_HAL_Enable(base);
    return kStatus_MPU_Success;
}