Skip to content

Commit b084812

Browse files
committed
current critical section implementation makes possible that interrupt
signals are lost. It was observed at last for tests-api-spi ci-test-shield's test. This patch introduce usage of sdk5 origin implementation in which sd_nvic_critical_region_enter/exit is calling each time critical region is enter/exit. This fixes the issue.
1 parent 4e22295 commit b084812

File tree

1 file changed

+5
-31
lines changed

1 file changed

+5
-31
lines changed

targets/TARGET_NORDIC/TARGET_NRF5/nordic_critical.c

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,17 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include <stdint.h> // uint32_t, UINT32_MAX
19-
#include <assert.h> // uint32_t, UINT32_MAX
20-
#include "cmsis.h"
21-
#include "nrf_soc.h"
22-
#include "nrf_sdm.h"
23-
#include "nrf_nvic.h"
18+
#include <stdint.h>
19+
#include "app_util_platform.h"
2420

25-
static uint8_t _sd_state = 0;
26-
static volatile uint32_t _entry_count = 0;
21+
static uint8_t nordic_cr_nested = 0;
2722

2823
void core_util_critical_section_enter()
2924
{
30-
// if a critical section has already been entered, just update the counter
31-
if (_entry_count) {
32-
++_entry_count;
33-
return;
34-
}
35-
36-
// in this path, a critical section has never been entered
37-
// routine of SD V11 work even if the softdevice is not active
38-
sd_nvic_critical_region_enter(&_sd_state);
39-
40-
assert(_entry_count == 0); // entry count should always be equal to 0 at this point
41-
++_entry_count;
25+
app_util_critical_region_enter(&nordic_cr_nested);
4226
}
4327

4428
void core_util_critical_section_exit()
4529
{
46-
assert(_entry_count > 0);
47-
--_entry_count;
48-
49-
// If their is other segments which have entered the critical section, just leave
50-
if (_entry_count) {
51-
return;
52-
}
53-
54-
// This is the last segment of the critical section, state should be restored as before entering
55-
// the critical section
56-
sd_nvic_critical_region_exit(_sd_state);
30+
app_util_critical_region_exit(nordic_cr_nested);
5731
}

0 commit comments

Comments
 (0)