diff options
| author | arturo182 <arturo182@tlen.pl> | 2018-06-27 20:14:25 +0200 |
|---|---|---|
| committer | arturo182 <arturo182@tlen.pl> | 2018-06-27 20:55:29 +0200 |
| commit | b87bba8a286bd57fe1d9f3bfe2aec5adb2137780 (patch) | |
| tree | 8fbce1891c7c90a36bcc6e2e2b0e1bb9db321e26 /ports/nrf/common-hal | |
| parent | 91427b0b2366a792e165b48e81453d0cf98e1fb9 (diff) | |
nrf: Rewrite more common-hal with nrfx and sync with atsamd port
Diffstat (limited to 'ports/nrf/common-hal')
| -rw-r--r-- | ports/nrf/common-hal/board/__init__.c | 8 | ||||
| -rw-r--r-- | ports/nrf/common-hal/microcontroller/__init__.c | 10 | ||||
| -rw-r--r-- | ports/nrf/common-hal/storage/__init__.c | 13 | ||||
| -rw-r--r-- | ports/nrf/common-hal/time/__init__.c | 8 |
4 files changed, 20 insertions, 19 deletions
diff --git a/ports/nrf/common-hal/board/__init__.c b/ports/nrf/common-hal/board/__init__.c index 634760335..257b8108d 100644 --- a/ports/nrf/common-hal/board/__init__.c +++ b/ports/nrf/common-hal/board/__init__.c @@ -24,11 +24,5 @@ * THE SOFTWARE. */ -#include <string.h> - -#include "py/runtime.h" -#include "py/mphal.h" -#include "common-hal/microcontroller/Pin.h" - // Pins aren't actually defined here. They are in the board specific directory -// such as boards/arduino_zero/pins.c. +// such as boards/feather52832/pins.csv diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index e26acff1b..b63ee5a88 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -27,14 +27,15 @@ #include "common-hal/microcontroller/Pin.h" #include "common-hal/microcontroller/Processor.h" - #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" -// TODO porting common_hal_mcu +#include "supervisor/filesystem.h" +#include "nrfx_glue.h" + void common_hal_mcu_delay_us(uint32_t delay) { -// os_delay_us(delay); + NRFX_DELAY_US(delay); } void common_hal_mcu_disable_interrupts() { @@ -48,7 +49,8 @@ void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { } void common_hal_mcu_reset(void) { - // TODO: see atmel-samd for functionality + filesystem_flush(); + NVIC_SystemReset(); } // The singleton microcontroller.Processor object, bound to microcontroller.cpu diff --git a/ports/nrf/common-hal/storage/__init__.c b/ports/nrf/common-hal/storage/__init__.c index 76ff81466..18334181a 100644 --- a/ports/nrf/common-hal/storage/__init__.c +++ b/ports/nrf/common-hal/storage/__init__.c @@ -28,16 +28,19 @@ #include "py/mperrno.h" #include "py/runtime.h" +#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/storage/__init__.h" +#include "supervisor/filesystem.h" extern volatile bool mp_msc_enabled; -void common_hal_storage_remount(const char* mount_path, bool readonly) { - if (strcmp(mount_path, "/") != 0) { +void common_hal_storage_remount(const char *mount_path, bool readonly) { + if (strcmp(mount_path, "/") != 0) mp_raise_OSError(MP_EINVAL); - } } -void common_hal_storage_erase_filesystem() { - mp_raise_NotImplementedError(""); +void common_hal_storage_erase_filesystem(void) { + filesystem_init(false, true); // Force a re-format. + common_hal_mcu_reset(); + // We won't actually get here, since we're resetting. } diff --git a/ports/nrf/common-hal/time/__init__.c b/ports/nrf/common-hal/time/__init__.c index ec77354a9..5e5e9fdf1 100644 --- a/ports/nrf/common-hal/time/__init__.c +++ b/ports/nrf/common-hal/time/__init__.c @@ -29,10 +29,12 @@ #include "shared-bindings/time/__init__.h" #include "tick.h" -inline uint64_t common_hal_time_monotonic() { - return ticks_ms; +#include "nrfx_glue.h" + +inline uint64_t common_hal_time_monotonic(void) { + return ticks_ms; } void common_hal_time_delay_ms(uint32_t delay) { - mp_hal_delay_ms(delay); + NRFX_DELAY_US(delay); } |
