Mistake on this page?
Report an issue in GitHub or email us
mbed_critical.h
1 
2 /*
3  * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License"); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef __MBED_UTIL_CRITICAL_H__
20 #define __MBED_UTIL_CRITICAL_H__
21 
22 #include <stdbool.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /** \addtogroup platform */
29 /** @{*/
30 /**
31  * \defgroup platform_critical critical section function
32  * @{
33  */
34 
35 /** Determine the current interrupts enabled state
36  *
37  * This function can be called to determine whether or not interrupts are currently enabled.
38  * @note
39  * NOTE:
40  * This function works for both cortex-A and cortex-M, although the underlying implementation
41  * differs.
42  * @return true if interrupts are enabled, false otherwise
43  */
45 
46 /** Determine if this code is executing from an interrupt
47  *
48  * This function can be called to determine if the code is running on interrupt context.
49  * @note
50  * NOTE:
51  * This function works for both cortex-A and cortex-M, although the underlying implementation
52  * differs.
53  * @return true if in an isr, false otherwise
54  */
55 bool core_util_is_isr_active(void);
56 
57 /** Mark the start of a critical section
58  *
59  * This function should be called to mark the start of a critical section of code.
60  * @note
61  * NOTES:
62  * 1) The use of this style of critical section is targetted at C based implementations.
63  * 2) These critical sections can be nested.
64  * 3) The interrupt enable state on entry to the first critical section (of a nested set, or single
65  * section) will be preserved on exit from the section.
66  * 4) This implementation will currently only work on code running in privileged mode.
67  */
69 
70 /** Mark the end of a critical section
71  *
72  * This function should be called to mark the end of a critical section of code.
73  * @note
74  * NOTES:
75  * 1) The use of this style of critical section is targetted at C based implementations.
76  * 2) These critical sections can be nested.
77  * 3) The interrupt enable state on entry to the first critical section (of a nested set, or single
78  * section) will be preserved on exit from the section.
79  * 4) This implementation will currently only work on code running in privileged mode.
80  */
82 
83 /**
84  * Determine if we are currently in a critical section
85  *
86  * @return true if in a critical section, false otherwise.
87  */
89 
90 /**@}*/
91 
92 /**@}*/
93 
94 #ifdef __cplusplus
95 } // extern "C"
96 #endif
97 
98 #endif // __MBED_UTIL_CRITICAL_H__
99 
100 
101 
void core_util_critical_section_exit(void)
Mark the end of a critical section.
void core_util_critical_section_enter(void)
Mark the start of a critical section.
bool core_util_in_critical_section(void)
Determine if we are currently in a critical section.
bool core_util_are_interrupts_enabled(void)
Determine the current interrupts enabled state.
bool core_util_is_isr_active(void)
Determine if this code is executing from an interrupt.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.