File tree Expand file tree Collapse file tree 6 files changed +40
-48
lines changed
features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/hal_patch
targets/TARGET_NORDIC/TARGET_NRF5 Expand file tree Collapse file tree 6 files changed +40
-48
lines changed Original file line number Diff line number Diff line change @@ -77,3 +77,8 @@ void hal_critical_section_exit(void)
77
77
__set_PRIMASK (_state ._PRIMASK_state );
78
78
}
79
79
}
80
+
81
+ bool hal_in_critical_section (void )
82
+ {
83
+ return (_state_saved == true);
84
+ }
Original file line number Diff line number Diff line change 18
18
#ifndef MBED_CRITICAL_SECTION_API_H
19
19
#define MBED_CRITICAL_SECTION_API_H
20
20
21
+ #include <stdbool.h>
22
+
21
23
#ifdef __cplusplus
22
24
extern "C" {
23
25
#endif
@@ -60,6 +62,7 @@ extern "C" {
60
62
*/
61
63
void hal_critical_section_enter (void );
62
64
65
+
63
66
/** Mark the end of a critical section.
64
67
*
65
68
* The purpose of this function is to restore any state that was modified upon
@@ -79,6 +82,20 @@ void hal_critical_section_enter(void);
79
82
*/
80
83
void hal_critical_section_exit (void );
81
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
+ */
96
+ bool hal_in_critical_section (void );
97
+
98
+
82
99
/**@}*/
83
100
84
101
#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -47,15 +47,21 @@ MBED_WEAK void hal_critical_section_enter(void)
47
47
state_saved = true;
48
48
}
49
49
50
- MBED_WEAK void hal_critical_section_exit ()
50
+ MBED_WEAK void hal_critical_section_exit (void )
51
51
{
52
+ #ifndef FEATURE_UVISOR
52
53
// Interrupts must be disabled on invoking an exit from a critical section
53
54
MBED_ASSERT (!are_interrupts_enabled ());
54
-
55
+ #endif
55
56
state_saved = false;
56
57
57
58
// Restore the IRQs to their state prior to entering the critical section
58
59
if (critical_interrupts_enabled == true) {
59
60
__enable_irq ();
60
61
}
61
62
}
63
+
64
+ MBED_WEAK bool hal_in_critical_section (void )
65
+ {
66
+ return (state_saved == true);
67
+ }
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ bool core_util_is_isr_active(void)
53
53
54
54
bool core_util_in_critical_section (void )
55
55
{
56
- return ( critical_section_reentrancy_counter != 0 );
56
+ return hal_in_critical_section ( );
57
57
}
58
58
59
59
void core_util_critical_section_enter (void )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ static void nordic_nvic_critical_region_enter(void);
25
25
static void nordic_nvic_critical_region_exit (void );
26
26
#endif
27
27
28
- void core_util_critical_section_enter ()
28
+ void hal_critical_section_enter ()
29
29
{
30
30
#ifdef NRF52
31
31
ASSERT (APP_LEVEL_PRIVILEGED == privilege_level_get ())
@@ -39,7 +39,7 @@ void core_util_critical_section_enter()
39
39
#endif
40
40
}
41
41
42
- void core_util_critical_section_exit ()
42
+ void hal_critical_section_exit ()
43
43
{
44
44
#ifdef NRF52
45
45
ASSERT (APP_LEVEL_PRIVILEGED == privilege_level_get ())
@@ -53,6 +53,13 @@ void core_util_critical_section_exit()
53
53
#endif
54
54
}
55
55
56
+
57
+ bool hal_in_critical_section (void )
58
+ {
59
+ return (nordic_cr_nested != 0 );
60
+ }
61
+
62
+
56
63
#if defined(SOFTDEVICE_PRESENT )
57
64
/**@brief Enters critical region.
58
65
*
You can’t perform that action at this time.
0 commit comments