Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions ports/nrf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,27 @@ LIBS := -L $(dir $(LIBM_FILE_NAME)) -lm
LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc
LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc

SRC_NRFX = $(addprefix nrfx/,\
SRC_NRFX += $(addprefix nrfx/,\
drivers/src/nrfx_power.c \
drivers/src/nrfx_spim.c \
drivers/src/nrfx_twim.c \
drivers/src/nrfx_uart.c \
hal/nrf_nvmc.c \
mdk/system_$(MCU_SUB_VARIANT).c \
)

SRC_C += \
background.c \
fatfs_port.c \
internal_flash.c \
mphalport.c \
tick.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
drivers/bluetooth/ble_drv.c \
drivers/bluetooth/ble_uart.c \
flash_api/internal_flash.c \
flash_api/flash_api.c \
lib/libc/string0.c \
lib/mp-readline/readline.c \
lib/oofatfs/ff.c \
Expand All @@ -116,14 +119,18 @@ SRC_C += \
lib/utils/pyexec.c \
lib/utils/stdout_helpers.c \
lib/utils/sys_stdio_mphal.c \
nrfx/hal/nrf_nvmc.c \
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \
peripherals/nrf/cache.c \
peripherals/nrf/clocks.c \
peripherals/nrf/$(MCU_CHIP)/pins.c \
peripherals/nrf/$(MCU_CHIP)/power.c \
supervisor/shared/memory.c

ifeq ($(QSPI_FLASH_FILESYSTEM),1)
SRC_C += flash_api/qspi_flash.c
SRC_NRFX += nrfx/drivers/src/nrfx_qspi.c
CFLAGS += -DQSPI_FLASH_FILESYSTEM
endif

DRIVERS_SRC_C += $(addprefix modules/,\
ubluepy/modubluepy.c \
ubluepy/ubluepy_peripheral.c \
Expand Down
3 changes: 1 addition & 2 deletions ports/nrf/boards/feather_nrf52840_express/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
*/

#include "boards/board.h"
#include "usb.h"

void board_init(void) {
usb_init();

}

bool board_requests_safe_mode(void) {
Expand Down
58 changes: 30 additions & 28 deletions ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,47 @@

#define FEATHER52840

#define MICROPY_HW_BOARD_NAME "Adafruit Feather nRF52840 Express"
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "Feather52840Express"
#define MICROPY_HW_BOARD_NAME "Adafruit Feather nRF52840 Express"
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "Feather52840Express"

#define MICROPY_HW_NEOPIXEL (&pin_P0_13)
#define MICROPY_HW_NEOPIXEL (&pin_P0_13)

#define MICROPY_QSPI_DATA0 (&pin_P1_09)
#define MICROPY_QSPI_DATA1 (&pin_P0_11)
#define MICROPY_QSPI_DATA2 (&pin_P0_12)
#define MICROPY_QSPI_DATA3 (&pin_P0_14)
#define MICROPY_QSPI_SCK (&pin_P0_08)
#define MICROPY_QSPI_CS (&pin_P1_08)
#define MICROPY_HW_LED_MSC NRF_GPIO_PIN_MAP(0, 13)
#define MICROPY_HW_LED_MSC_ACTIVE_LEVEL 1

// Flash operation mode is determined by MICROPY_QSPI_DATAn pin configuration.
// A pin config is valid if it is defined and its value is not 0xFF.
// Quad mode: If all DATA0 --> DATA3 are valid
// Dual mode: If DATA0 and DATA1 are valid while either DATA2 and/or DATA3 are invalid
// Single mode: If only DATA0 is valid
#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(1, 9)
#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 11)
#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 12)
#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 14)
#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 8)
#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 8)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems inconsistent that all other defines in this file use the pin__ objects but for QSPI we use the pin number


#define CIRCUITPY_AUTORELOAD_DELAY_MS 500

// If you change this, then make sure to update the linker scripts as well to
// make sure you don't overwrite code
#define PORT_HEAP_SIZE (128 * 1024)
#define PORT_HEAP_SIZE (128 * 1024)
// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192

#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)

// TODO #include "external_flash/devices.h"

#define EXTERNAL_FLASH_DEVICE_COUNT 1
#define EXTERNAL_FLASH_DEVICES GD25Q16C

#define EXTERNAL_FLASH_QSPI_DUAL
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)

// TODO include "external_flash/external_flash.h"
// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES GD25Q16C

#define BOARD_HAS_CRYSTAL 1
#define BOARD_HAS_CRYSTAL 1

#define DEFAULT_I2C_BUS_SCL (&pin_P1_11)
#define DEFAULT_I2C_BUS_SDA (&pin_P1_12)
#define DEFAULT_I2C_BUS_SCL (&pin_P1_11)
#define DEFAULT_I2C_BUS_SDA (&pin_P1_12)

#define DEFAULT_SPI_BUS_SCK (&pin_P0_20)
#define DEFAULT_SPI_BUS_MOSI (&pin_P0_23)
#define DEFAULT_SPI_BUS_MISO (&pin_P0_22)
#define DEFAULT_SPI_BUS_SCK (&pin_P0_20)
#define DEFAULT_SPI_BUS_MOSI (&pin_P0_23)
#define DEFAULT_SPI_BUS_MISO (&pin_P0_22)

#define DEFAULT_UART_BUS_RX (&pin_P1_0)
#define DEFAULT_UART_BUS_TX (&pin_P0_24)
#define DEFAULT_UART_BUS_RX (&pin_P1_0)
#define DEFAULT_UART_BUS_TX (&pin_P0_24)
1 change: 1 addition & 0 deletions ports/nrf/boards/feather_nrf52840_express/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SD ?= s140
SOFTDEV_VERSION ?= 6.1.0

BOOT_SETTING_ADDR = 0xFF000
QSPI_FLASH_FILESYSTEM = 1

ifeq ($(SD),)
LD_FILE = boards/nrf52840_1M_256k.ld
Expand Down
14 changes: 12 additions & 2 deletions ports/nrf/boards/pca10056/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,26 @@
*/

#include "boards/board.h"
#include "usb.h"
#include "nrf_gpio.h"

void board_init(void) {
usb_init();

}

bool board_requests_safe_mode(void) {
return false;
}

void reset_board(void) {
// LEDs
for ( int i = 13; i <= 16; i++ ) {
nrf_gpio_cfg_output(i);
nrf_gpio_pin_set(i);
}

// Buttons
nrf_gpio_cfg_input(11, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_input(12, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_input(24, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_input(25, NRF_GPIO_PIN_PULLUP);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like test code that shouldn't be merged.

}
52 changes: 36 additions & 16 deletions ports/nrf/boards/pca10056/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,47 @@
* THE SOFTWARE.
*/

#define MICROPY_HW_BOARD_NAME "PCA10056 nRF52840-DK"
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "nRF52840-DK"
#define MICROPY_HW_BOARD_NAME "PCA10056 nRF52840-DK"
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "nRF52840-DK"

// See legend on bottom of board
#define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8)
#define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6)
#define MICROPY_HW_UART_HWFC (0)
#define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8)
#define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6)
#define MICROPY_HW_UART_HWFC (0)

#define PORT_HEAP_SIZE (128 * 1024)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
#define MICROPY_HW_LED_MSC NRF_GPIO_PIN_MAP(0, 13)
#define MICROPY_HW_LED_MSC_ACTIVE_LEVEL 0

#define PORT_HEAP_SIZE (128 * 1024)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500

// Temp (could be removed) 0: usb cdc (default), 1 : hwuart (jlink)
#define CFG_HWUART_FOR_SERIAL 0
#define CFG_HWUART_FOR_SERIAL 0

#define DEFAULT_I2C_BUS_SCL (&pin_P0_27)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_26)

#define DEFAULT_SPI_BUS_SCK (&pin_P1_15)
#define DEFAULT_SPI_BUS_MOSI (&pin_P1_13)
#define DEFAULT_SPI_BUS_MISO (&pin_P1_14)

#define DEFAULT_UART_BUS_RX (&pin_P1_01)
#define DEFAULT_UART_BUS_TX (&pin_P1_02)

// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES MX25R6435F

#define DEFAULT_I2C_BUS_SCL (&pin_P0_27)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_26)
// Flash operation mode is determined by MICROPY_QSPI_DATAn pin configuration.
// A pin config is valid if it is defined and its value is not 0xFF.
// Quad mode: If all DATA0 --> DATA3 are valid
// Dual mode: If DATA0 and DATA1 are valid while either DATA2 and/or DATA3 are invalid
// Single mode: If only DATA0 is valid
#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 20)
#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 21)
#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 22)
#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 23)
#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19)
#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 17)

#define DEFAULT_SPI_BUS_SCK (&pin_P1_15)
#define DEFAULT_SPI_BUS_MOSI (&pin_P1_13)
#define DEFAULT_SPI_BUS_MISO (&pin_P1_14)

#define DEFAULT_UART_BUS_RX (&pin_P1_01)
#define DEFAULT_UART_BUS_TX (&pin_P1_02)
1 change: 1 addition & 0 deletions ports/nrf/boards/pca10056/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SD ?= s140
SOFTDEV_VERSION ?= 6.1.0

BOOT_SETTING_ADDR = 0xFF000
QSPI_FLASH_FILESYSTEM = 1

ifeq ($(SD),)
LD_FILE = boards/nrf52840_1M_256k.ld
Expand Down
2 changes: 0 additions & 2 deletions ports/nrf/boards/pca10059/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
#include <stdbool.h>
#include "boards/board.h"
#include "nrfx.h"
#include "usb.h"

void board_init(void) {
usb_init();
}

bool board_requests_safe_mode(void) {
Expand Down
Loading