Skip to content

Commit

Permalink
nRF5x: Don't disable IRQs completely for some things - only disable E…
Browse files Browse the repository at this point in the history
…spruino ones
  • Loading branch information
gfwilliams committed Aug 9, 2017
1 parent 697608b commit e8ceb5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -16,6 +16,7 @@
nRF5x: If a task is in progress, report the task ID (BleTask enum)
nRF52: Report central mode promise errors correctly if returned by softdevice
Remove 'out of memory' warning messages (it's stored as a flag anyway)
nRF5x: Don't disable IRQs completely for some things - only disable Espruino ones

1v93 : Ensure that specifying too many advertising UUIDs causes an exception, not a reboot
nRF5x: Fix for time jump caused by reentrancy in jshGetSystemTime
Expand Down
28 changes: 12 additions & 16 deletions targets/nrf5x/jshardware.c
Expand Up @@ -354,25 +354,21 @@ JsVarFloat jshGetMillisecondsFromTime(JsSysTime time) {
}

void jshInterruptOff() {
__disable_irq(); // Disabling interrupts is not reasonable when using one of the SoftDevices.
#ifdef BLUETOOTH
// disable non-softdevice IRQs
__set_BASEPRI(4<<5); // Disabling interrupts completely is not reasonable when using one of the SoftDevices.
#else
__disable_irq();
#endif
}

void jshInterruptOn() {
__enable_irq(); // *** This wont be good with SoftDevice!
}

/* TODO: Looks like we could use:
__set_BASEPRI(3<<5);
to turn IRQs off for *just* the softdevice
SWI IRQs, and then
#ifdef BLUETOOTH
__set_BASEPRI(0);
to turn them back on. It could be useful
if we wanted to avoid causing SD issues
by blocking IRQs. */
#else
__enable_irq();
#endif
}


/// Are we currently in an interrupt?
Expand Down Expand Up @@ -1272,7 +1268,7 @@ unsigned int jshGetRandomNumber() {
unsigned int v = 0;
uint8_t bytes_avail = 0;
WAIT_UNTIL((sd_rand_application_bytes_available_get(&bytes_avail),bytes_avail>=sizeof(v)),"Random number");
sd_rand_application_vector_get(&v, sizeof(v));
sd_rand_application_vector_get((uint8_t*)&v, sizeof(v));
return v;
}

Expand Down

0 comments on commit e8ceb5c

Please sign in to comment.