mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 1:9db0e321a9f4 1 /* mbed Microcontroller Library
kenjiArai 1:9db0e321a9f4 2 * Copyright (c) 2018-2019 ARM Limited
kenjiArai 1:9db0e321a9f4 3 *
kenjiArai 1:9db0e321a9f4 4 * Licensed under the Apache License, Version 2.0 (the "License");
kenjiArai 1:9db0e321a9f4 5 * you may not use this file except in compliance with the License.
kenjiArai 1:9db0e321a9f4 6 * You may obtain a copy of the License at
kenjiArai 1:9db0e321a9f4 7 *
kenjiArai 1:9db0e321a9f4 8 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 1:9db0e321a9f4 9 *
kenjiArai 1:9db0e321a9f4 10 * Unless required by applicable law or agreed to in writing, software
kenjiArai 1:9db0e321a9f4 11 * distributed under the License is distributed on an "AS IS" BASIS,
kenjiArai 1:9db0e321a9f4 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 1:9db0e321a9f4 13 * See the License for the specific language governing permissions and
kenjiArai 1:9db0e321a9f4 14 * limitations under the License.
kenjiArai 1:9db0e321a9f4 15 */
kenjiArai 1:9db0e321a9f4 16
kenjiArai 1:9db0e321a9f4 17 #include "platform/mbed_mpu_mgmt.h"
kenjiArai 1:9db0e321a9f4 18 #include "platform/mbed_critical.h"
kenjiArai 1:9db0e321a9f4 19 #include "platform/mbed_assert.h"
kenjiArai 1:9db0e321a9f4 20 #include <limits.h>
kenjiArai 1:9db0e321a9f4 21 #include <stdbool.h>
kenjiArai 1:9db0e321a9f4 22
kenjiArai 1:9db0e321a9f4 23 #if DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU
kenjiArai 1:9db0e321a9f4 24
kenjiArai 1:9db0e321a9f4 25 static uint16_t mem_xn_lock;
kenjiArai 1:9db0e321a9f4 26 static uint16_t mem_wn_lock;
kenjiArai 1:9db0e321a9f4 27
kenjiArai 1:9db0e321a9f4 28 void mbed_mpu_manager_lock_ram_execution()
kenjiArai 1:9db0e321a9f4 29 {
kenjiArai 1:9db0e321a9f4 30 core_util_critical_section_enter();
kenjiArai 1:9db0e321a9f4 31 MBED_ASSERT(mem_xn_lock != USHRT_MAX);
kenjiArai 1:9db0e321a9f4 32 if (mem_xn_lock == 0) {
kenjiArai 1:9db0e321a9f4 33 mbed_mpu_enable_ram_xn(false);
kenjiArai 1:9db0e321a9f4 34 }
kenjiArai 1:9db0e321a9f4 35 mem_xn_lock++;
kenjiArai 1:9db0e321a9f4 36 core_util_critical_section_exit();
kenjiArai 1:9db0e321a9f4 37 }
kenjiArai 1:9db0e321a9f4 38
kenjiArai 1:9db0e321a9f4 39 void mbed_mpu_manager_unlock_ram_execution()
kenjiArai 1:9db0e321a9f4 40 {
kenjiArai 1:9db0e321a9f4 41 core_util_critical_section_enter();
kenjiArai 1:9db0e321a9f4 42 MBED_ASSERT(mem_xn_lock != 0);
kenjiArai 1:9db0e321a9f4 43 mem_xn_lock--;
kenjiArai 1:9db0e321a9f4 44 if (mem_xn_lock == 0) {
kenjiArai 1:9db0e321a9f4 45 mbed_mpu_enable_ram_xn(true);
kenjiArai 1:9db0e321a9f4 46 }
kenjiArai 1:9db0e321a9f4 47 core_util_critical_section_exit();
kenjiArai 1:9db0e321a9f4 48 }
kenjiArai 1:9db0e321a9f4 49
kenjiArai 1:9db0e321a9f4 50 void mbed_mpu_manager_lock_rom_write()
kenjiArai 1:9db0e321a9f4 51 {
kenjiArai 1:9db0e321a9f4 52 core_util_critical_section_enter();
kenjiArai 1:9db0e321a9f4 53 MBED_ASSERT(mem_wn_lock != USHRT_MAX);
kenjiArai 1:9db0e321a9f4 54 if (mem_wn_lock == 0) {
kenjiArai 1:9db0e321a9f4 55 mbed_mpu_enable_rom_wn(false);
kenjiArai 1:9db0e321a9f4 56 }
kenjiArai 1:9db0e321a9f4 57 mem_wn_lock++;
kenjiArai 1:9db0e321a9f4 58 core_util_critical_section_exit();
kenjiArai 1:9db0e321a9f4 59 }
kenjiArai 1:9db0e321a9f4 60
kenjiArai 1:9db0e321a9f4 61 void mbed_mpu_manager_unlock_rom_write()
kenjiArai 1:9db0e321a9f4 62 {
kenjiArai 1:9db0e321a9f4 63 core_util_critical_section_enter();
kenjiArai 1:9db0e321a9f4 64 MBED_ASSERT(mem_wn_lock != 0);
kenjiArai 1:9db0e321a9f4 65 mem_wn_lock--;
kenjiArai 1:9db0e321a9f4 66 if (mem_wn_lock == 0) {
kenjiArai 1:9db0e321a9f4 67 mbed_mpu_enable_rom_wn(true);
kenjiArai 1:9db0e321a9f4 68 }
kenjiArai 1:9db0e321a9f4 69 core_util_critical_section_exit();
kenjiArai 1:9db0e321a9f4 70 }
kenjiArai 1:9db0e321a9f4 71
kenjiArai 1:9db0e321a9f4 72 #endif