Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-cloud-workshop-connect-HTS221 by
critical-pal.c
00001 // ---------------------------------------------------------------------------- 00002 // Copyright 2015-2017 ARM Ltd. 00003 // 00004 // SPDX-License-Identifier: Apache-2.0 00005 // 00006 // Licensed under the Apache License, Version 2.0 (the "License"); 00007 // you may not use this file except in compliance with the License. 00008 // You may obtain a copy of the License at 00009 // 00010 // http://www.apache.org/licenses/LICENSE-2.0 00011 // 00012 // Unless required by applicable law or agreed to in writing, software 00013 // distributed under the License is distributed on an "AS IS" BASIS, 00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 // See the License for the specific language governing permissions and 00016 // limitations under the License. 00017 // ---------------------------------------------------------------------------- 00018 00019 #if defined(ATOMIC_QUEUE_USE_PAL) && !defined(TARGET_LIKE_MBED) 00020 00021 #include <stdint.h> 00022 #include <assert.h> 00023 #include <unistd.h> 00024 00025 #include "pal.h" 00026 // Module include 00027 #include "aq_critical.h" 00028 00029 static palMutexID_t mutex = NULLPTR; 00030 static volatile unsigned irq_nesting_depth = 0; 00031 00032 void aq_critical_section_enter() { 00033 if (mutex == NULLPTR) { 00034 palStatus_t rc = pal_osMutexCreate(&mutex); 00035 assert(rc == PAL_SUCCESS); 00036 } 00037 if (++irq_nesting_depth > 1) { 00038 return; 00039 } 00040 palStatus_t rc = pal_osMutexWait(mutex, PAL_RTOS_WAIT_FOREVER); 00041 assert(rc == PAL_SUCCESS); 00042 } 00043 00044 void aq_critical_section_exit(void) { 00045 assert(irq_nesting_depth > 0); 00046 if (--irq_nesting_depth == 0) { 00047 palStatus_t rc = pal_osMutexRelease(mutex); 00048 assert(rc == PAL_SUCCESS); 00049 } 00050 } 00051 00052 #endif // defined(ATOMIC_QUEUE_USE_PAL)
Generated on Tue Jul 12 2022 19:12:12 by
1.7.2
