source: asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/hal/critical_section_api.h@ 374

Last change on this file since 374 was 374, checked in by coas-nagasima, 5 years ago

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

  • Property charset set to UTF-8
  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
File size: 3.9 KB
Line 
1/** \addtogroup hal */
2/** @{*/
3/* mbed Microcontroller Library
4 * Copyright (c) 2006-2017 ARM Limited
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may 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,
14 * WITHOUT 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#ifndef MBED_CRITICAL_SECTION_API_H
19#define MBED_CRITICAL_SECTION_API_H
20
21#include <stdbool.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/**
28 * \defgroup hal_critical Critical Section HAL functions
29 * @{
30 */
31
32/**
33 * Mark the start of a critical section
34 *
35 * This function will be called by core_util_critical_section_enter() each time
36 * the application requests to enter a critical section. The purpose of the
37 * critical section is to ensure mutual-exclusion synchronisation of the
38 * processor by preventing any change in processor control, the default
39 * behaviour requires storing the state of interrupts in the system before
40 * disabling them.
41 *
42 * The critical section code supports nesting. When a thread has entered a
43 * critical section it can make additional calls to
44 * core_util_critical_section_enter() without deadlocking itself. The critical
45 * section driver API tracks the number of nested calls to the critical section.
46 * The critical section will only be exited when
47 * core_util_critical_section_exit() has been called once for each time it
48 * entered the critical section.
49 *
50 * On the first call to enter a critical section this function MUST store the
51 * state of any interrupts or other application settings it will modify to
52 * facilitate the critical section.
53 *
54 * Each successive call to enter the critical section MUST ignore storing or
55 * modifying any application state.
56 *
57 * The default implementation of this function which will save the current state
58 * of interrupts before disabling them. This implementation can be found in
59 * mbed_critical_section_api.c. This behaviour is can be overridden on a per
60 * platform basis by providing a different implementation within the correct
61 * targets directory.
62 */
63void hal_critical_section_enter(void);
64
65
66/** Mark the end of a critical section.
67 *
68 * The purpose of this function is to restore any state that was modified upon
69 * entering the critical section, allowing other threads or interrupts to change
70 * the processor control.
71 *
72 * This function will be called once by core_util_critical_section_exit() per
73 * critical section on last call to exit. When called, the application MUST
74 * restore the saved interrupt/application state that was saved when entering
75 * the critical section.
76 *
77 * There is a default implementation of this function, it will restore the state
78 * of interrupts that were previously saved when hal_critical_section_enter was
79 * first called, this implementation can be found in
80 * mbed_critical_section_api.c. This behaviour is overridable by providing a
81 * different function implementation within the correct targets directory.
82 */
83void hal_critical_section_exit(void);
84
85
86/** Determine if the application is currently running in a critical section
87 *
88 * The purpose of this function is to inform the caller whether or not the
89 * application is running in a critical section. This is done by checking if
90 * the current interrupt state has been saved in the underlying implementation,
91 * this could also be done by checking the state of the interrupts at the time
92 * of calling.
93 *
94 * @return True if running in a critical section, false if not.
95 */
96bool hal_in_critical_section(void);
97
98
99/**@}*/
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif // MBED_CRITICAL_SECTION_API_H
106
107/** @}*/
Note: See TracBrowser for help on using the repository browser.