Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_mpu_mgmt.h Source File

mbed_mpu_mgmt.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2019 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef MBED_MPU_MGMT_H
00017 #define MBED_MPU_MGMT_H
00018 
00019 #include "hal/mpu_api.h"
00020 
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024 
00025 /** \addtogroup platform-public-api */
00026 /** @{*/
00027 
00028 /**
00029  * \defgroup platform_mpu_mgmt MPU management functions
00030  * @{
00031  */
00032 
00033 #if (DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU) || defined(DOXYGEN_ONLY)
00034 
00035 #define mbed_mpu_manager_init() mbed_mpu_init()
00036 
00037 #define mbed_mpu_manager_deinit() mbed_mpu_free()
00038 
00039 /** Lock ram execute never mode off
00040  *
00041  * This disables the MPU's execute never ram protection and allows
00042  * functions to run from RAM. Execution directly from ram will be
00043  * allowed if this function is invoked at least once (the internal
00044  * counter is non-zero).
00045  *
00046  * Use this locking mechanism for code which needs to execute from
00047  * ram such as flash programming algorithms and ram thunks.
00048  *
00049  * The lock is a counter, can be locked up to USHRT_MAX
00050  * This function is IRQ and thread safe
00051  */
00052 void mbed_mpu_manager_lock_ram_execution(void);
00053 
00054 /** Unlock ram execute never mode
00055  *
00056  * Use unlocking in pair with mbed_mpu_manager_lock_ram_execution().
00057  *
00058  * The lock is a counter, should be equally unlocked as locked
00059  * This function is IRQ and thread safe
00060  */
00061 void mbed_mpu_manager_unlock_ram_execution(void);
00062 
00063 /** Lock rom write never mode off
00064  *
00065  * This disables the MPU's read only ROM protection and allows
00066  * ROM to be written to. Writing to ROM will not result in an MPU
00067  * fault if this function is invoked at least once (the internal
00068  * counter is non-zero).
00069  *
00070  * Use this locking mechanism for code which needs to write to
00071  * ROM such as flash programming algorithms.
00072  *
00073  * The lock is a counter, can be locked up to USHRT_MAX
00074  * This function is IRQ and thread safe
00075  */
00076 void mbed_mpu_manager_lock_rom_write(void);
00077 
00078 /** Unlock rom write never mode
00079  *
00080  * Use unlocking in pair with mbed_mpu_manager_lock_rom_write().
00081  *
00082  * The lock is a counter, should be equally unlocked as locked
00083  * This function is IRQ and thread safe
00084  */
00085 void mbed_mpu_manager_unlock_rom_write(void);
00086 
00087 #else
00088 
00089 #define mbed_mpu_manager_init() (void)0
00090 
00091 #define mbed_mpu_manager_deinit() (void)0
00092 
00093 #define mbed_mpu_manager_lock_ram_execution() (void)0
00094 
00095 #define mbed_mpu_manager_unlock_ram_execution() (void)0
00096 
00097 #define mbed_mpu_manager_lock_rom_write() (void)0
00098 
00099 #define mbed_mpu_manager_unlock_rom_write() (void)0
00100 
00101 #endif
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106 
00107 #endif
00108 
00109 /** @}*/
00110 /** @}*/