From f548f558da387be2ac88249c87d14dbd784ad81e Mon Sep 17 00:00:00 2001 From: George Beckstein Date: Thu, 20 Jun 2019 14:54:10 -0400 Subject: [PATCH 1/2] Fixed bug causing Nordic drivers to use a different critical section API from Mbed. This caused conflicts when Nordic's critical section API would globally reenable interrupts while Mbed still expected to be in a critical section. --- .../components/libraries/README.md | 2 ++ .../components/libraries/util/app_util_platform.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/README.md b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/README.md index d1fbd84ee1..9a998afc0d 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/README.md +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/README.md @@ -4,6 +4,8 @@ components/libraries # Modifications + * Modified util/app_util_platform.c to retarget critical section enter/exit calls to Mbed's HAL API so they both share the same nested critical regions counter. This only applies in builds without `SOFTDEVICE_PRESENT` defined. + Only essential folders have been copied over. Removed: diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util/app_util_platform.c b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util/app_util_platform.c index 71690d0fdc..cb59facac3 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util/app_util_platform.c +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util/app_util_platform.c @@ -39,6 +39,8 @@ */ #include "app_util_platform.h" +#include "mbed_critical.h" + #ifdef SOFTDEVICE_PRESENT /* Global nvic state instance, required by nrf_nvic.h */ nrf_nvic_state_t nrf_nvic_state; @@ -71,8 +73,13 @@ void app_util_critical_region_enter(uint8_t *p_nested) /* return value can be safely ignored */ (void) sd_nvic_critical_region_enter(p_nested); #else - app_util_disable_irq(); + /** Mbed modification + * Retarget nRF SDK to use Mbed critical section API + */ + //app_util_disable_irq(); + core_util_critical_section_enter(); #endif + } void app_util_critical_region_exit(uint8_t nested) @@ -85,7 +92,11 @@ void app_util_critical_region_exit(uint8_t nested) /* return value can be safely ignored */ (void) sd_nvic_critical_region_exit(nested); #else - app_util_enable_irq(); + /** Mbed modification + * Retarget nRF SDK to use Mbed critical section API + */ + //app_util_enable_irq(); + core_util_critical_section_exit(); #endif } From 15cd907d35240eed7a47c6155c99cbde3a4311b4 Mon Sep 17 00:00:00 2001 From: George Beckstein Date: Mon, 24 Jun 2019 08:34:54 -0400 Subject: [PATCH 2/2] Fix alignment --- .../components/libraries/util/app_util_platform.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util/app_util_platform.c b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util/app_util_platform.c index cb59facac3..af453651ef 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util/app_util_platform.c +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util/app_util_platform.c @@ -77,7 +77,7 @@ void app_util_critical_region_enter(uint8_t *p_nested) * Retarget nRF SDK to use Mbed critical section API */ //app_util_disable_irq(); - core_util_critical_section_enter(); + core_util_critical_section_enter(); #endif } @@ -93,10 +93,10 @@ void app_util_critical_region_exit(uint8_t nested) (void) sd_nvic_critical_region_exit(nested); #else /** Mbed modification - * Retarget nRF SDK to use Mbed critical section API - */ - //app_util_enable_irq(); - core_util_critical_section_exit(); + * Retarget nRF SDK to use Mbed critical section API + */ + //app_util_enable_irq(); + core_util_critical_section_exit(); #endif }