nrf: Rewrite more common-hal with nrfx and sync with atsamd port

This commit is contained in:
arturo182 2018-06-27 20:14:25 +02:00
parent 91427b0b23
commit b87bba8a28
5 changed files with 22 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -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.
}

View File

@ -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);
}

View File

@ -45,6 +45,8 @@
extern "C" {
#endif
#include <drivers/nrfx_common.h>
/**
* @defgroup nrfx_glue nrfx_glue.h
* @{