Skip to content

Commit

Permalink
Update to use soft device by default
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Jun 23, 2024
1 parent aa128fb commit 1e0d00a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
11 changes: 6 additions & 5 deletions low_level_platform/api/platform/lf_nrf52_support.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* nRF52832 API support for the C target of Lingua Franca. */
/* nRF52 API support for the C target of Lingua Franca. */

/*************
Copyright (c) 2021, The University of California at Berkeley.
Expand All @@ -24,11 +24,12 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************/

/** nrf52 API support for the C target of Lingua Franca.
/**
* nRF52 API support for the C target of Lingua Franca.
*
* @author{Soroush Bateni <[email protected]>}
* @author{Abhi Gundrala <[email protected]>}
* @author{Erling Rennemo Jellum <[email protected]>}
* @author{Soroush Bateni <[email protected]>}
* @author{Abhi Gundrala <[email protected]>}
* @author{Erling Rennemo Jellum <[email protected]>}
*/

#ifndef LF_NRF52_SUPPORT_H
Expand Down
20 changes: 12 additions & 8 deletions low_level_platform/impl/src/lf_nrf52_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ int _lf_interruptable_sleep_until_locked(environment_t* env, instant_t wakeup_ti
}
}

// Definition required by sd_nvic_critical_region_enter() and exit() below.
nrf_nvic_state_t nrf_nvic_state = {0};

/**
* @brief Enter critical section. Let NRF Softdevice handle nesting
* @return 0
Expand All @@ -276,10 +279,10 @@ int lf_enable_interrupts_nested() {
if (_lf_nested_count == 0)
return 1; // Error. Interrupts have not been disabled.
_lf_nested_count--;
__enable_irq();
// FIXME: If softdevice is enabled, do the following:
// return sd_nvic_critical_region_exit(&_lf_nested_count);
return 0;
return sd_nvic_critical_region_exit(0);
// FIXME: If softdevice is not enabled, do the following instead of above:
// __enable_irq();
// return 0;
}

/**
Expand All @@ -289,10 +292,11 @@ int lf_enable_interrupts_nested() {
*/
int lf_disable_interrupts_nested() {
_lf_nested_count++;
__disable_irq();
// FIXME: If softdevice is enabled, do the following:
// return sd_nvic_critical_region_enter(_lf_nested_count);
return 0;
uint8_t success = 0;
return sd_nvic_critical_region_enter(&success);
// FIXME: If softdevice is not enabled, do the following instead of the above:
// __disable_irq();
// return 0;
}

/**
Expand Down

0 comments on commit 1e0d00a

Please sign in to comment.