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