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.
Dependents: SPIne CH_Communicatuin_Test CH_Communicatuin_Test2 MCP_SPIne ... more
Fork of mbed-dev-f303 by
CriticalSectionLock.h
00001 /* 00002 * PackageLicenseDeclared: Apache-2.0 00003 * Copyright (c) 2017 ARM Limited 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef MBED_CRITICALSECTIONLOCK_H 00019 #define MBED_CRITICALSECTIONLOCK_H 00020 00021 #include "platform/mbed_critical.h" 00022 00023 namespace mbed { 00024 00025 /** RAII object for disabling, then restoring, interrupt state 00026 * Usage: 00027 * @code 00028 * 00029 * void f() { 00030 * // some code here 00031 * { 00032 * CriticalSectionLock lock; 00033 * // Code in this block will run with interrupts disabled 00034 * } 00035 * // interrupts will be restored to their previous state 00036 * } 00037 * @endcode 00038 */ 00039 class CriticalSectionLock { 00040 public: 00041 CriticalSectionLock() 00042 { 00043 core_util_critical_section_enter(); 00044 } 00045 00046 ~CriticalSectionLock() 00047 { 00048 core_util_critical_section_exit(); 00049 } 00050 00051 /** Mark the start of a critical section 00052 * 00053 */ 00054 void lock() 00055 { 00056 core_util_critical_section_enter(); 00057 } 00058 00059 /** Mark the end of a critical section 00060 * 00061 */ 00062 void unlock() 00063 { 00064 core_util_critical_section_exit(); 00065 } 00066 }; 00067 00068 00069 } // namespace mbed 00070 00071 #endif
Generated on Tue Jul 12 2022 19:39:48 by
