summaryrefslogtreecommitdiff
path: root/ports/nrf/common-hal/microcontroller/__init__.c
AgeCommit message (Collapse)Author
2021-03-15run code formatting scriptmicroDev
2020-07-15nRF: Always use sd_nvic_critical_region callsJeff Epler
The motivation for doing this is so that we can allow common_hal_mcu_disable_interrupts in IRQ context, something that works on other ports, but not on nRF with SD enabled. This is because when SD is enabled, calling sd_softdevice_is_enabled in the context of an interrupt with priority 2 or 3 causes a HardFault. We have chosen to give the USB interrupt priority 2 on nRF, the highest priority that is compatible with SD. Since at least SoftDevice s130 v2.0.1, sd_nvic_critical_region_enter/exit have been implemented as inline functions and are safe to call even if softdevice is not enabled. Reference kindly provided by danh: https://devzone.nordicsemi.com/f/nordic-q-a/29553/sd_nvic_critical_region_enter-exit-missing-in-s130-v2 Switching to these as the default/only way to enable/disable interrupts simplifies things, and fixes several problems and potential problems: * Interrupts at priority 2 or 3 could not call common_hal_mcu_disable_interrupts because the call to sd_softdevice_is_enabled would HardFault * Hypothetically, the state of sd_softdevice_is_enabled could change from the disable to the enable call, meaning the calls would not match (__disable_irq() could be balanced with sd_nvic_critical_region_exit). This also fixes a problem I believe would exist if disable() were called twice when SD is enabled. There is a single "is_nested_critical_region" flag, and the second call would set it to 1. Both of the enable() calls that followed would call critical_region_exit(1), and interrupts would not properly be reenabled. In the new version of the code, we use our own nesting_count value to track the intended state, so now nested disable()s only call critical_region_enter() once, only updating is_nested_critical_region once; and only the second enable() call will call critical_region_exit, with the right value of i_n_c_r. Finally, in port_sleep_until_interrupt, if !sd_enabled, we really do need to __disable_irq, rather than using the common_hal_mcu routines; the reason why is documented in a comment.
2020-05-27watchdog: use common_hal_watchdog_* patternSean Cross
This pulls all common functionality into `shared-bindings` and keeps platform-specific code inside `nrf`. Additionally, this performs most validation in the `shared-bindings` site. The only validation that occurs inside platform-specific `common-hal` code is related to timeout limits that are platform-specific. Additionally, all documentation is now inside the `shared-bindings` directory. Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27nrf: microcontroller: use port reset pathSean Cross
For `microcontroller.reset()`, don't manually call NVIC_SystemReset(). Instead, call the `port_reset()` in case the port wants to do any cleanup. Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27watchdogtimer: refactor to new apiSean Cross
This refactors the WatchDogTimer API to use the format proposed in https://github.com/adafruit/circuitpython/pull/2933#issuecomment-632268227 Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27watchdog: rename module from `wdt` and move to `microcontroller`Sean Cross
This also places it under the `microcontroller` object. Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-21nrf: add support for nrf52833Sean Cross
This adds preliminary support for the nRF52833, which is a variant of the nRF52840 with half the RAM, half the flash, and fewer peripherals. Signed-off-by: Sean Cross <sean@xobs.io>
2020-01-30track vm_used_ble betterDan Halbert
2019-12-05wipDan Halbert
2019-10-20Parameterize linker scriptDan Halbert
2019-08-01nrf: Implement RUNMODE_BOOTLOADER and RUNMODE_SAFE_MODEjepler
2019-04-16Fixups for adafruit/circuitpython#1042Nick Moore
2019-04-16nvm.ByteArray reads & writes but no sensible erase yet ↵Nick Moore
adafruit/circuitpython#1042
2019-04-16Start on nRF nvm.ByteArray adafruit/circuitpython#1042 (doesn't do anything yet)Nick Moore
2019-04-15Revert "nrf nvm: touchups to nickzoic PR #1768"Scott Shawcroft
2019-04-10fix subscriptingDan Halbert
2019-04-09Fixups for adafruit/circuitpython#1042Nick Moore
2019-04-09nvm.ByteArray reads & writes but no sensible erase yet ↵Nick Moore
adafruit/circuitpython#1042
2019-04-09Start on nRF nvm.ByteArray adafruit/circuitpython#1042 (doesn't do anything yet)Nick Moore
2018-09-01fix typos, remove incorrect pca10059 example; add default buses for ↵Dan Halbert
pca10056; improve board names for pca boards
2018-08-31pin files rework; implement pin claiming; add more boardsDan Halbert
2018-07-16Merge 3.0.0 final bugfixes and changes to masterDan Halbert
2018-06-27nrf: Rewrite more common-hal with nrfx and sync with atsamd portarturo182
2018-01-03nrf: fixups for changes from 2.2Dan Halbert
1. bidirectional SPI support (@microbuilder please check) 2. slight changes in DigitalIO types 3. placeholders (not implemented yet) for single/double-click bootloader support
2017-12-21nRF52 update with internal file system supportmicrobuilder
2017-11-23Revert "Supervisor REPL support for ports/nrf/boards/feather52"Kevin Townsend
This reverts commit 92113dde815ce5aaecf63ea9e87bc4addcabd822.
2017-11-23Supervisor REPL support for ports/nrf/boards/feather52Kevin Townsend