summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/nrf/README.md2
-rw-r--r--ports/nrf/boards/pca10059/modules/boardmodules.h34
-rw-r--r--ports/nrf/boards/pca10059/modules/boardmodules.mk11
-rw-r--r--ports/nrf/boards/pca10059/modules/recover_uicr_regout0.c61
-rw-r--r--ports/nrf/boards/pca10059/mpconfigboard.h73
-rw-r--r--ports/nrf/boards/pca10059/mpconfigboard.mk7
-rw-r--r--ports/nrf/boards/pca10059/pins.csv31
7 files changed, 219 insertions, 0 deletions
diff --git a/ports/nrf/README.md b/ports/nrf/README.md
index 49642f00e..834e2ea29 100644
--- a/ports/nrf/README.md
+++ b/ports/nrf/README.md
@@ -39,6 +39,7 @@ This is a port of MicroPython to the Nordic Semiconductor nRF series of chips.
* [uBlox EVK-NINA-B1](https://www.u-blox.com/en/product/evk-nina-b1)
* nRF52840
* [PCA10056](http://www.nordicsemi.com/eng/Products/nRF52840-Preview-DK)
+ * [PCA10059](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle)
* [Particle Xenon](https://docs.particle.io/xenon/)
## Compile and Flash
@@ -129,6 +130,7 @@ idk_blyst_nano | s132 | Peripheral and Central | [IDAP]
blueio_tag_evim | s132 | Peripheral and Central | [IDAP](#idap-midap-link-targets)
evk_nina_b1 | s132 | Peripheral and Central | [Segger](#segger-targets)
pca10056 | s140 | Peripheral and Central | [Segger](#segger-targets)
+pca10059 | s140 | Peripheral and Central | Manual, SWDIO and SWCLK solder points on the sides.
particle_xenon | s140 | Peripheral and Central | [Black Magic Probe](#black-magic-probe-targets)
## IDAP-M/IDAP-Link Targets
diff --git a/ports/nrf/boards/pca10059/modules/boardmodules.h b/ports/nrf/boards/pca10059/modules/boardmodules.h
new file mode 100644
index 000000000..1d70ec916
--- /dev/null
+++ b/ports/nrf/boards/pca10059/modules/boardmodules.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Glenn Ruben Bakke
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H
+#define MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H
+
+#define BOARD_MODULES
+
+void board_modules_init0(void);
+
+#endif // MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H
diff --git a/ports/nrf/boards/pca10059/modules/boardmodules.mk b/ports/nrf/boards/pca10059/modules/boardmodules.mk
new file mode 100644
index 000000000..413790fbe
--- /dev/null
+++ b/ports/nrf/boards/pca10059/modules/boardmodules.mk
@@ -0,0 +1,11 @@
+BOARD_PCA10059_DIR = boards/pca10059/modules
+
+INC += -I./$(BOARD_PCA10059_DIR)
+CFLAGS += -DBOARD_SPECIFIC_MODULES
+
+SRC_BOARD_MODULES = $(addprefix $(BOARD_PCA10059_DIR)/,\
+ recover_uicr_regout0.c \
+ )
+
+OBJ += $(addprefix $(BUILD)/, $(SRC_BOARD_MODULES:.c=.o))
+
diff --git a/ports/nrf/boards/pca10059/modules/recover_uicr_regout0.c b/ports/nrf/boards/pca10059/modules/recover_uicr_regout0.c
new file mode 100644
index 000000000..8ae5e218a
--- /dev/null
+++ b/ports/nrf/boards/pca10059/modules/recover_uicr_regout0.c
@@ -0,0 +1,61 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Glenn Ruben Bakke
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <stdbool.h>
+
+#include "nrf.h"
+#include "nrf52840_bitfields.h"
+
+bool uicr_REGOUT0_erased() {
+ if (NRF_UICR->REGOUT0 == 0xFFFFFFFFUL) {
+ return true;
+ }
+ return false;
+}
+
+void board_modules_init0(void)
+{
+ if (uicr_REGOUT0_erased()) {
+
+ // Wait for pending NVMC operations to finish.
+ while (NRF_NVMC->READY != NVMC_READY_READY_Ready);
+
+ // Enable write mode in NVMC.
+ NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
+ while (NRF_NVMC->READY != NVMC_READY_READY_Ready);
+
+ // Write 3v3 value to UICR->REGOUT0.
+ NRF_UICR->REGOUT0 = (UICR_REGOUT0_VOUT_3V3 & UICR_REGOUT0_VOUT_Msk) << UICR_REGOUT0_VOUT_Pos;
+ while (NRF_NVMC->READY != NVMC_READY_READY_Ready);
+
+ // Enable read mode in NVMC.
+ NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
+ while (NRF_NVMC->READY != NVMC_READY_READY_Ready);
+
+ // Reset to apply the update.
+ NVIC_SystemReset();
+ }
+}
diff --git a/ports/nrf/boards/pca10059/mpconfigboard.h b/ports/nrf/boards/pca10059/mpconfigboard.h
new file mode 100644
index 000000000..08fda1bb2
--- /dev/null
+++ b/ports/nrf/boards/pca10059/mpconfigboard.h
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Glenn Ruben Bakke
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#define MICROPY_HW_BOARD_NAME "PCA10059"
+#define MICROPY_HW_MCU_NAME "NRF52840"
+#define MICROPY_PY_SYS_PLATFORM "nrf52840-Dongle"
+
+#define MICROPY_PY_MACHINE_UART (1)
+#define MICROPY_PY_MACHINE_HW_PWM (1)
+#define MICROPY_PY_MACHINE_HW_SPI (1)
+#define MICROPY_PY_MACHINE_TIMER (1)
+#define MICROPY_PY_MACHINE_RTCOUNTER (1)
+#define MICROPY_PY_MACHINE_I2C (1)
+#define MICROPY_PY_MACHINE_ADC (1)
+#define MICROPY_PY_MACHINE_TEMP (1)
+#define MICROPY_PY_RANDOM_HW_RNG (1)
+
+#define MICROPY_HW_USB_CDC (1)
+
+#define MICROPY_HW_HAS_LED (1)
+#define MICROPY_HW_LED_COUNT (4)
+#define MICROPY_HW_LED_PULLUP (1)
+
+#define MICROPY_HW_LED1 (6) // LED1 GREEN
+#define MICROPY_HW_LED2 (8) // LED2 RED (RGB)
+#define MICROPY_HW_LED3 (41) // LED2 GREEN (RGB)
+#define MICROPY_HW_LED4 (12) // LED2 BLUE (RGB)
+
+// UART config
+#define MICROPY_HW_UART1_RX (13)
+#define MICROPY_HW_UART1_TX (15)
+#define MICROPY_HW_UART1_CTS (17)
+#define MICROPY_HW_UART1_RTS (20)
+#define MICROPY_HW_UART1_HWFC (1)
+
+// SPI0 config
+#define MICROPY_HW_SPI0_NAME "SPI0"
+
+#define MICROPY_HW_SPI0_SCK (22)
+#define MICROPY_HW_SPI0_MOSI (32)
+#define MICROPY_HW_SPI0_MISO (24)
+
+#define MICROPY_HW_PWM0_NAME "PWM0"
+#define MICROPY_HW_PWM1_NAME "PWM1"
+#define MICROPY_HW_PWM2_NAME "PWM2"
+#if 0
+#define MICROPY_HW_PWM3_NAME "PWM3"
+#endif
+
+#define HELP_TEXT_BOARD_LED "1,2,3,4"
diff --git a/ports/nrf/boards/pca10059/mpconfigboard.mk b/ports/nrf/boards/pca10059/mpconfigboard.mk
new file mode 100644
index 000000000..ca555d393
--- /dev/null
+++ b/ports/nrf/boards/pca10059/mpconfigboard.mk
@@ -0,0 +1,7 @@
+MCU_SERIES = m4
+MCU_VARIANT = nrf52
+MCU_SUB_VARIANT = nrf52840
+SOFTDEV_VERSION = 6.1.1
+LD_FILES += boards/nrf52840_1M_256k.ld
+
+NRF_DEFINES += -DNRF52840_XXAA
diff --git a/ports/nrf/boards/pca10059/pins.csv b/ports/nrf/boards/pca10059/pins.csv
new file mode 100644
index 000000000..9d142b9f1
--- /dev/null
+++ b/ports/nrf/boards/pca10059/pins.csv
@@ -0,0 +1,31 @@
+P2,P2,ADC0_IN0
+P4,P4,ADC0_IN2
+LED1_GREEN,P6
+LED2_RED,P8
+P9,P9
+P10,P10
+P11,P11
+LED2_BLUE,P12
+UART1_RX,P13
+P14,P14
+UART1_TX,P15
+P16,P16
+UART1_CTS,P17
+SWITCH2_NRESET,P18
+UART1_RTS,P20
+SPI0_SCK,P22,P22
+SPI0_MISO,P24
+P26,P26
+P29,P29,ADC0_IN5
+P31,P31,ADC0_IN7
+SPI0_MOSI,P32
+P33,P33
+P34,P34
+P36,P36
+SWITCH1,P38,P38
+P39,P39
+LED2_GREEN,P41
+P42,P42
+P43,P43
+P45,P45
+P47,P47