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.
pull/5177/merge
Glenn Ruben Bakke 2019-10-09 20:25:12 +02:00
rodzic 60b0b69f20
commit 01a3110e36
7 zmienionych plików z 219 dodań i 0 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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