Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 063a01b4f -> dfd03160d
Get the 16K bsp looking like the nrf51dk bsp (except for the additional RAM). Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/dfd03160 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/dfd03160 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/dfd03160 Branch: refs/heads/develop Commit: dfd03160d59ecbd2c6b25a6529051589facea961 Parents: 6512e62 Author: William San Filippo <wi...@runtime.io> Authored: Thu Sep 22 21:09:15 2016 -0700 Committer: William San Filippo <wi...@runtime.io> Committed: Thu Sep 22 21:10:14 2016 -0700 ---------------------------------------------------------------------- hw/bsp/nrf51dk-16kbram/include/bsp/bsp.h | 5 ++- hw/bsp/nrf51dk-16kbram/pkg.yml | 35 +++++++++--------- hw/bsp/nrf51dk-16kbram/src/os_bsp.c | 52 ++++++++++++++++++--------- hw/bsp/nrf51dk/pkg.yml | 3 ++ 4 files changed, 62 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dfd03160/hw/bsp/nrf51dk-16kbram/include/bsp/bsp.h ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk-16kbram/include/bsp/bsp.h b/hw/bsp/nrf51dk-16kbram/include/bsp/bsp.h index 7f6c8e7..9309cbe 100644 --- a/hw/bsp/nrf51dk-16kbram/include/bsp/bsp.h +++ b/hw/bsp/nrf51dk-16kbram/include/bsp/bsp.h @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -39,6 +39,9 @@ extern uint8_t _ram_start; /* LED pins */ #define LED_BLINK_PIN (21) +/* SPI SS */ +#define SPI_SS_PIN (24) + /* UART info */ #define CONSOLE_UART "uart0" #define CONSOLE_UART_SPEED 115200 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dfd03160/hw/bsp/nrf51dk-16kbram/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk-16kbram/pkg.yml b/hw/bsp/nrf51dk-16kbram/pkg.yml index 991c55c..d65887d 100644 --- a/hw/bsp/nrf51dk-16kbram/pkg.yml +++ b/hw/bsp/nrf51dk-16kbram/pkg.yml @@ -34,8 +34,8 @@ pkg.part2linkerscript: "split-nrf51dk-16kbram.ld" pkg.downloadscript: nrf51dk-16kbram_download.sh pkg.debugscript: nrf51dk-16kbram_debug.sh pkg.cflags: - # Nordic SDK files require these defines. - - '-DNRF52' + # Nordic SDK files require this define. + - '-DNRF51' pkg.deps: - hw/mcu/nordic/nrf51xxx @@ -60,7 +60,7 @@ pkg.syscfg_defs: CLOCK_FREQ: description: 'TBD' - value: 1000000 + value: 1000000 XTAL_32768: description: 'TBD' @@ -68,27 +68,30 @@ pkg.syscfg_defs: ADC_0: description: 'TBD' - value: 0 - ADC_0_RESOLUTION: - description: 'TBD' - value: 'SAADC_CONFIG_RESOLUTION' - ADC_0_OVERSAMPLE: - description: 'TBD' - value: 'SAADC_CONFIG_OVERSAMPLE' + value: 0 ADC_0_INTERRUPT_PRIORITY: description: 'TBD' - value: 'SAADC_CONFIG_IRQ_PRIORITY' + value: 'ADC_CONFIG_IRQ_PRIORITY' UART_0: description: 'TBD' - value: 1 - UART_1: + value: 1 + UART_0_PIN_TX: + description: 'TBD' + value: 9 + UART_0_PIN_RX: + description: 'TBD' + value: 11 + UART_0_PIN_RTS: + description: 'TBD' + value: 8 + UART_0_PIN_CTS: description: 'TBD' - value: 0 + value: 10 SPI_MASTER: description: 'TBD' - value: 0 + value: 0 SPI_SLAVE: description: 'TBD' - value: 0 + value: 0 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dfd03160/hw/bsp/nrf51dk-16kbram/src/os_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk-16kbram/src/os_bsp.c b/hw/bsp/nrf51dk-16kbram/src/os_bsp.c index abcf5e4..4fc35e0 100644 --- a/hw/bsp/nrf51dk-16kbram/src/os_bsp.c +++ b/hw/bsp/nrf51dk-16kbram/src/os_bsp.c @@ -17,17 +17,23 @@ * under the License. */ #include <assert.h> -#include <hal/flash_map.h> -#include <hal/hal_bsp.h> -#include <hal/hal_spi.h> -#ifdef BSP_CFG_SPI_MASTER +#include "syscfg/syscfg.h" +#include "bsp.h" +#include "hal/flash_map.h" +#include "hal/hal_bsp.h" +#include "hal/hal_spi.h" +#include "mcu/nrf51_hal.h" +#if MYNEWT_VAL(SPI_MASTER) #include "nrf_drv_spi.h" #endif -#ifdef BSP_CFG_SPI_SLAVE +#if MYNEWT_VAL(SPI_SLAVE) #include "nrf_drv_spis.h" #endif #include "nrf_drv_config.h" -#include <app_util_platform.h> +#include "app_util_platform.h" +#include "os/os_dev.h" +#include "uart/uart.h" +#include "uart_hal/uart_hal.h" static struct flash_area bsp_flash_areas[] = { [FLASH_AREA_BOOTLOADER] = { @@ -57,6 +63,16 @@ static struct flash_area bsp_flash_areas[] = { } }; +#if MYNEWT_VAL(UART_0) +static struct uart_dev os_bsp_uart0; +static const struct nrf51_uart_cfg os_bsp_uart0_cfg = { + .suc_pin_tx = MYNEWT_VAL(UART_0_PIN_TX), + .suc_pin_rx = MYNEWT_VAL(UART_0_PIN_RX), + .suc_pin_rts = MYNEWT_VAL(UART_0_PIN_RTS), + .suc_pin_cts = MYNEWT_VAL(UART_0_PIN_CTS), +}; +#endif + void _close(int fd); void bsp_hal_init(void); @@ -83,12 +99,20 @@ void bsp_slot_init_split_application(void) { void bsp_init(void) { -#ifdef BSP_CFG_SPI_MASTER int rc; + + (void)rc; + +#if MYNEWT_VAL(UART_0) + rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0", + OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&os_bsp_uart0_cfg); + assert(rc == 0); +#endif + +#if MYNEWT_VAL(SPI_MASTER) nrf_drv_spi_config_t spi_cfg = NRF_DRV_SPI_DEFAULT_CONFIG(0); #endif -#ifdef BSP_CFG_SPI_SLAVE - int rc; +#if MYNEWT_VAL(SPI_SLAVE) nrf_drv_spis_config_t spi_cfg = NRF_DRV_SPIS_DEFAULT_CONFIG(1); #endif @@ -101,17 +125,13 @@ bsp_init(void) flash_area_init(bsp_flash_areas, sizeof(bsp_flash_areas) / sizeof(bsp_flash_areas[0])); - bsp_hal_init(); - -#ifdef BSP_CFG_SPI_MASTER - /* We initialize one SPI interface as a master. */ +#if MYNEWT_VAL(SPI_MASTER) rc = hal_spi_init(0, &spi_cfg, HAL_SPI_TYPE_MASTER); assert(rc == 0); #endif -#ifdef BSP_CFG_SPI_SLAVE - /* We initialize one SPI interface as a master. */ - spi_cfg.csn_pin = SPIS1_CONFIG_CSN_PIN; +#if MYNEWT_VAL(SPI_SLAVE) + spi_cfg.csn_pin = SPI_SS_PIN; spi_cfg.csn_pullup = NRF_GPIO_PIN_PULLUP; rc = hal_spi_init(1, &spi_cfg, HAL_SPI_TYPE_SLAVE); assert(rc == 0); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dfd03160/hw/bsp/nrf51dk/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml index 8ad78e3..2a6dd06 100644 --- a/hw/bsp/nrf51dk/pkg.yml +++ b/hw/bsp/nrf51dk/pkg.yml @@ -50,6 +50,9 @@ pkg.deps.ADC_0: pkg.deps.UART_0: - drivers/uart/uart_hal +pkg.deps.UART_1: + - drivers/uart/uart_bitbang + pkg.syscfg_defs: BSP_NRF51: description: 'TBD'