Skip to content

Commit 01a3110

Browse files
committed
nrf/boards: Add support for pca10059.
Add support for pca10059 with REPL over tinyusb USB CDC. The board also includes a board specific module that will recover UICR->REGOUT0 in case this has been erased. This initial support does not preserve any existing bootloader on the pca10090 in case this was present, and expects to use all available flash on the device.
1 parent 60b0b69 commit 01a3110

File tree

7 files changed

+219
-0
lines changed

7 files changed

+219
-0
lines changed

ports/nrf/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ This is a port of MicroPython to the Nordic Semiconductor nRF series of chips.
3939
* [uBlox EVK-NINA-B1](https://www.u-blox.com/en/product/evk-nina-b1)
4040
* nRF52840
4141
* [PCA10056](http://www.nordicsemi.com/eng/Products/nRF52840-Preview-DK)
42+
* [PCA10059](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle)
4243
* [Particle Xenon](https://docs.particle.io/xenon/)
4344

4445
## Compile and Flash
@@ -129,6 +130,7 @@ idk_blyst_nano | s132 | Peripheral and Central | [IDAP]
129130
blueio_tag_evim | s132 | Peripheral and Central | [IDAP](#idap-midap-link-targets)
130131
evk_nina_b1 | s132 | Peripheral and Central | [Segger](#segger-targets)
131132
pca10056 | s140 | Peripheral and Central | [Segger](#segger-targets)
133+
pca10059 | s140 | Peripheral and Central | Manual, SWDIO and SWCLK solder points on the sides.
132134
particle_xenon | s140 | Peripheral and Central | [Black Magic Probe](#black-magic-probe-targets)
133135

134136
## IDAP-M/IDAP-Link Targets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Glenn Ruben Bakke
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H
28+
#define MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H
29+
30+
#define BOARD_MODULES
31+
32+
void board_modules_init0(void);
33+
34+
#endif // MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
BOARD_PCA10059_DIR = boards/pca10059/modules
2+
3+
INC += -I./$(BOARD_PCA10059_DIR)
4+
CFLAGS += -DBOARD_SPECIFIC_MODULES
5+
6+
SRC_BOARD_MODULES = $(addprefix $(BOARD_PCA10059_DIR)/,\
7+
recover_uicr_regout0.c \
8+
)
9+
10+
OBJ += $(addprefix $(BUILD)/, $(SRC_BOARD_MODULES:.c=.o))
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Glenn Ruben Bakke
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <stdbool.h>
28+
29+
#include "nrf.h"
30+
#include "nrf52840_bitfields.h"
31+
32+
bool uicr_REGOUT0_erased() {
33+
if (NRF_UICR->REGOUT0 == 0xFFFFFFFFUL) {
34+
return true;
35+
}
36+
return false;
37+
}
38+
39+
void board_modules_init0(void)
40+
{
41+
if (uicr_REGOUT0_erased()) {
42+
43+
// Wait for pending NVMC operations to finish.
44+
while (NRF_NVMC->READY != NVMC_READY_READY_Ready);
45+
46+
// Enable write mode in NVMC.
47+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
48+
while (NRF_NVMC->READY != NVMC_READY_READY_Ready);
49+
50+
// Write 3v3 value to UICR->REGOUT0.
51+
NRF_UICR->REGOUT0 = (UICR_REGOUT0_VOUT_3V3 & UICR_REGOUT0_VOUT_Msk) << UICR_REGOUT0_VOUT_Pos;
52+
while (NRF_NVMC->READY != NVMC_READY_READY_Ready);
53+
54+
// Enable read mode in NVMC.
55+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
56+
while (NRF_NVMC->READY != NVMC_READY_READY_Ready);
57+
58+
// Reset to apply the update.
59+
NVIC_SystemReset();
60+
}
61+
}
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Glenn Ruben Bakke
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#define MICROPY_HW_BOARD_NAME "PCA10059"
28+
#define MICROPY_HW_MCU_NAME "NRF52840"
29+
#define MICROPY_PY_SYS_PLATFORM "nrf52840-Dongle"
30+
31+
#define MICROPY_PY_MACHINE_UART (1)
32+
#define MICROPY_PY_MACHINE_HW_PWM (1)
33+
#define MICROPY_PY_MACHINE_HW_SPI (1)
34+
#define MICROPY_PY_MACHINE_TIMER (1)
35+
#define MICROPY_PY_MACHINE_RTCOUNTER (1)
36+
#define MICROPY_PY_MACHINE_I2C (1)
37+
#define MICROPY_PY_MACHINE_ADC (1)
38+
#define MICROPY_PY_MACHINE_TEMP (1)
39+
#define MICROPY_PY_RANDOM_HW_RNG (1)
40+
41+
#define MICROPY_HW_USB_CDC (1)
42+
43+
#define MICROPY_HW_HAS_LED (1)
44+
#define MICROPY_HW_LED_COUNT (4)
45+
#define MICROPY_HW_LED_PULLUP (1)
46+
47+
#define MICROPY_HW_LED1 (6) // LED1 GREEN
48+
#define MICROPY_HW_LED2 (8) // LED2 RED (RGB)
49+
#define MICROPY_HW_LED3 (41) // LED2 GREEN (RGB)
50+
#define MICROPY_HW_LED4 (12) // LED2 BLUE (RGB)
51+
52+
// UART config
53+
#define MICROPY_HW_UART1_RX (13)
54+
#define MICROPY_HW_UART1_TX (15)
55+
#define MICROPY_HW_UART1_CTS (17)
56+
#define MICROPY_HW_UART1_RTS (20)
57+
#define MICROPY_HW_UART1_HWFC (1)
58+
59+
// SPI0 config
60+
#define MICROPY_HW_SPI0_NAME "SPI0"
61+
62+
#define MICROPY_HW_SPI0_SCK (22)
63+
#define MICROPY_HW_SPI0_MOSI (32)
64+
#define MICROPY_HW_SPI0_MISO (24)
65+
66+
#define MICROPY_HW_PWM0_NAME "PWM0"
67+
#define MICROPY_HW_PWM1_NAME "PWM1"
68+
#define MICROPY_HW_PWM2_NAME "PWM2"
69+
#if 0
70+
#define MICROPY_HW_PWM3_NAME "PWM3"
71+
#endif
72+
73+
#define HELP_TEXT_BOARD_LED "1,2,3,4"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MCU_SERIES = m4
2+
MCU_VARIANT = nrf52
3+
MCU_SUB_VARIANT = nrf52840
4+
SOFTDEV_VERSION = 6.1.1
5+
LD_FILES += boards/nrf52840_1M_256k.ld
6+
7+
NRF_DEFINES += -DNRF52840_XXAA

ports/nrf/boards/pca10059/pins.csv

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
P2,P2,ADC0_IN0
2+
P4,P4,ADC0_IN2
3+
LED1_GREEN,P6
4+
LED2_RED,P8
5+
P9,P9
6+
P10,P10
7+
P11,P11
8+
LED2_BLUE,P12
9+
UART1_RX,P13
10+
P14,P14
11+
UART1_TX,P15
12+
P16,P16
13+
UART1_CTS,P17
14+
SWITCH2_NRESET,P18
15+
UART1_RTS,P20
16+
SPI0_SCK,P22,P22
17+
SPI0_MISO,P24
18+
P26,P26
19+
P29,P29,ADC0_IN5
20+
P31,P31,ADC0_IN7
21+
SPI0_MOSI,P32
22+
P33,P33
23+
P34,P34
24+
P36,P36
25+
SWITCH1,P38,P38
26+
P39,P39
27+
LED2_GREEN,P41
28+
P42,P42
29+
P43,P43
30+
P45,P45
31+
P47,P47

0 commit comments

Comments
 (0)