Skip to content

Commit

Permalink
add feather52840 board
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Feb 13, 2018
1 parent 4f32732 commit 3bb4551
Show file tree
Hide file tree
Showing 10 changed files with 515 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ports/nrf/boards/feather52/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@
#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
uint32_t bootloaderVersion = 0;

void board_init(void)
void board_init (void)
{
// Retrieve bootloader version
bootloaderVersion = BOOTLOADER_VERSION_REGISTER;
// Retrieve bootloader version
bootloaderVersion = BOOTLOADER_VERSION_REGISTER;
}

// Check the status of the two buttons on CircuitPlayground Express. If both are
// pressed, then boot into user safe mode.
bool board_requests_safe_mode(void) {
bool board_requests_safe_mode (void)
{
// gpio_set_pin_function(PIN_PA14, GPIO_PIN_FUNCTION_OFF);
// gpio_set_pin_direction(PIN_PA14, GPIO_DIRECTION_IN);
// gpio_set_pin_pull_mode(PIN_PA14, GPIO_PULL_DOWN);
Expand All @@ -57,10 +58,11 @@ bool board_requests_safe_mode(void) {
// reset_pin(PIN_PA28);
// return safe_mode;

return false;
return false;
}

void reset_board(void) {
void reset_board (void)
{
// uint8_t empty[30];
// memset(empty, 0, 30);
// digitalio_digitalinout_obj_t neopixel_pin;
Expand Down
47 changes: 47 additions & 0 deletions ports/nrf/boards/feather52840/bluefruit_nrf52840_s140_6.0.0.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
GNU linker script for NRF52 w/ s132 5.0.0 SoftDevice

MEMORY MAP
------------------------------------------------------------------------
START ADDR END ADDR SIZE DESCRIPTION
---------- ---------- ------- -----------------------------------------
0x000FF000..0x000FFFFF ( 4KB) Bootloader Settings
0x000FE000..0x000FEFFF ( 4KB) Master Boot Record Params
0x000F4000..0x000FDFFF ( 40KB) Serial + OTA Bootloader

0x000F3000..0x000F3FFF ( 4KB ) Private Config Data (Bonding, Keys, etc.)
0x000F2000..0x000F2FFF ( 4KB ) User NVM data
0x000D9000..0x000F1FFF ( 100KB) User Filesystem

0x00025000..0x000D8FFF (720KB) Application Code (including ISR vector)
0x00001000..0x00024FFF (144KB) SoftDevice
0x00000000..0x00000FFF (4KB) Master Boot Record
*/

/* Specify the memory areas (S132 5.0.0) */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000

FLASH_ISR (rx) : ORIGIN = 0x00025000, LENGTH = 0x001000
FLASH_TEXT (rx) : ORIGIN = 0x00026000, LENGTH = 0x0B3000
FLASH_FATFS (r) : ORIGIN = 0x000D9000, LENGTH = 0x019000

/* 0x2000000 - RAM:ORGIGIN is reserved for Softdevice */
RAM (xrw) : ORIGIN = 0x20004000, LENGTH = 0x20040000 - 0x20004000
}

/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 0 /*16K Circuit Python use static variable for HEAP */;

/* top end of the stack */

/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
_estack = ORIGIN(RAM) + LENGTH(RAM);

/* RAM extents for the garbage collector */
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_end = 0x20007000; /* tunable */

INCLUDE "boards/common.ld"
44 changes: 44 additions & 0 deletions ports/nrf/boards/feather52840/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* 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 <string.h>
#include <stdbool.h>

#include "nrf.h"

#include "boards/board.h"

void board_init(void) {

}

bool board_requests_safe_mode(void) {
return false;
}

void reset_board(void) {

}
87 changes: 87 additions & 0 deletions ports/nrf/boards/feather52840/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 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 PCA10056

#define MICROPY_HW_BOARD_NAME "PCA10056"
#define MICROPY_HW_MCU_NAME "NRF52840"
#define MICROPY_PY_SYS_PLATFORM "nrf52840-PDK"

#define MICROPY_PY_MACHINE_HW_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)
#define MICROPY_PY_MACHINE_RTC (1)
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_HAS_SWITCH (0)
#define MICROPY_HW_HAS_FLASH (0)
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)
#define MICROPY_HW_HAS_LCD (0)
#define MICROPY_HW_ENABLE_RNG (0)
#define MICROPY_HW_ENABLE_RTC (0)
#define MICROPY_HW_ENABLE_TIMER (0)
#define MICROPY_HW_ENABLE_SERVO (0)
#define MICROPY_HW_ENABLE_DAC (0)
#define MICROPY_HW_ENABLE_CAN (0)

#define MICROPY_HW_LED_COUNT (4)
#define MICROPY_HW_LED_PULLUP (1)

#define MICROPY_HW_LED1 (13) // LED1
#define MICROPY_HW_LED2 (14) // LED2
#define MICROPY_HW_LED3 (15) // LED3
#define MICROPY_HW_LED4 (16) // LED4

// UART config
#define MICROPY_HW_UART1_RX (pin_A8)
#define MICROPY_HW_UART1_TX (pin_A6)
#define MICROPY_HW_UART1_CTS (pin_A7)
#define MICROPY_HW_UART1_RTS (pin_A5)
#define MICROPY_HW_UART1_HWFC (1)

// SPI0 config
#define MICROPY_HW_SPI0_NAME "SPI0"

#define MICROPY_HW_SPI0_SCK (pin_B15)
#define MICROPY_HW_SPI0_MOSI (pin_B13)
#define MICROPY_HW_SPI0_MISO (pin_B14)

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

#define PORT_HEAP_SIZE (128*1024)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
13 changes: 13 additions & 0 deletions ports/nrf/boards/feather52840/mpconfigboard.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52840
SOFTDEV_VERSION ?= 6.0.0-6.alpha

LD_FILE = boards/nrf52840_1M_256k.ld

NRF_DEFINES += -DNRF52840_XXAA

ifeq ($(SD), )
INC += -Idrivers/bluetooth/s140_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/s140_$(MCU_SUB_VARIANT)_$(SOFTDEV_VERSION)_API/include
INC += -Idrivers/bluetooth/s140_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/s140_$(MCU_SUB_VARIANT)_$(SOFTDEV_VERSION)_API/include/$(MCU_VARIANT)
endif
8 changes: 8 additions & 0 deletions ports/nrf/boards/feather52840/mpconfigboard_s140.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52840
SOFTDEV_VERSION ?= 6.0.0-6.alpha

LD_FILE = boards/nrf52840_1M_256k_s140_$(SOFTDEV_VERSION).ld

NRF_DEFINES += -DNRF52840_XXAA
18 changes: 18 additions & 0 deletions ports/nrf/boards/feather52840/nrf52_hal_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef NRF52_HAL_CONF_H__
#define NRF52_HAL_CONF_H__

#define HAL_UART_MODULE_ENABLED
#define HAL_SPI_MODULE_ENABLED
#define HAL_TIME_MODULE_ENABLED
#define HAL_PWM_MODULE_ENABLED
#define HAL_RTC_MODULE_ENABLED
#define HAL_TIMER_MODULE_ENABLED
#define HAL_TWI_MODULE_ENABLED
#define HAL_ADCE_MODULE_ENABLED
#define HAL_TEMP_MODULE_ENABLED
#define HAL_RNG_MODULE_ENABLED
// #define HAL_UARTE_MODULE_ENABLED
// #define HAL_SPIE_MODULE_ENABLED
// #define HAL_TWIE_MODULE_ENABLED

#endif // NRF52_HAL_CONF_H__
Loading

0 comments on commit 3bb4551

Please sign in to comment.