Bring bmd300 bsp up to date.
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/b2bf7ada Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b2bf7ada Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b2bf7ada Branch: refs/heads/develop Commit: b2bf7ada22691526cc33bf864b491b0510eaee12 Parents: e5156a2 Author: William San Filippo <wi...@runtime.io> Authored: Thu Sep 22 22:22:06 2016 -0700 Committer: William San Filippo <wi...@runtime.io> Committed: Thu Sep 22 22:57:00 2016 -0700 ---------------------------------------------------------------------- hw/bsp/bmd300eval/include/bsp/bsp.h | 5 +- hw/bsp/bmd300eval/include/bsp/nrf_drv_config.h | 2 - hw/bsp/bmd300eval/pkg.yml | 15 ++- hw/bsp/bmd300eval/src/os_bsp.c | 102 +++++++++++++++++--- 4 files changed, 103 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b2bf7ada/hw/bsp/bmd300eval/include/bsp/bsp.h ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/include/bsp/bsp.h b/hw/bsp/bmd300eval/include/bsp/bsp.h index 6edeeb4..a338875 100644 --- a/hw/bsp/bmd300eval/include/bsp/bsp.h +++ b/hw/bsp/bmd300eval/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, @@ -42,7 +42,8 @@ extern uint8_t _ram_start; #define LED_BLINK_PIN (17) /* UART info */ -#define CONSOLE_UART 0 +#define CONSOLE_UART "uart0" +#define CONSOLE_UART_SPEED 115200 #define NFFS_AREA_MAX (8) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b2bf7ada/hw/bsp/bmd300eval/include/bsp/nrf_drv_config.h ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/include/bsp/nrf_drv_config.h b/hw/bsp/bmd300eval/include/bsp/nrf_drv_config.h index 173193a..653a4de 100644 --- a/hw/bsp/bmd300eval/include/bsp/nrf_drv_config.h +++ b/hw/bsp/bmd300eval/include/bsp/nrf_drv_config.h @@ -208,7 +208,6 @@ #if (SPI0_ENABLED == 1) #define SPI0_USE_EASY_DMA 1 -#define SPI0_CONFIG_CSN_PIN 22 /* Note: not defined by SDK */ #define SPI0_CONFIG_SCK_PIN 23 #define SPI0_CONFIG_MOSI_PIN 24 #define SPI0_CONFIG_MISO_PIN 25 @@ -249,7 +248,6 @@ #define SPIS0_ENABLED 1 #if (SPIS0_ENABLED == 1) -#define SPIS0_CONFIG_CSN_PIN 22 /* Note: not defined by SDK */ #define SPIS0_CONFIG_SCK_PIN 23 #define SPIS0_CONFIG_MOSI_PIN 24 #define SPIS0_CONFIG_MISO_PIN 25 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b2bf7ada/hw/bsp/bmd300eval/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/pkg.yml b/hw/bsp/bmd300eval/pkg.yml index 8849cdb..d54aa7f 100644 --- a/hw/bsp/bmd300eval/pkg.yml +++ b/hw/bsp/bmd300eval/pkg.yml @@ -83,8 +83,21 @@ pkg.syscfg_defs: UART_0: description: 'TBD' value: 1 - UART_1: + UART_0_PIN_TX: + description: 'TBD' + value: 6 + UART_0_PIN_RX: + description: 'TBD' + value: 8 + UART_0_PIN_RTS: description: 'TBD' + value: 5 + UART_0_PIN_CTS: + description: 'TBD' + value: 7 + + UART_1: + description: 'Bitbanger UART' value: 0 SPI_MASTER: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b2bf7ada/hw/bsp/bmd300eval/src/os_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/src/os_bsp.c b/hw/bsp/bmd300eval/src/os_bsp.c index 4e336be..259701d 100644 --- a/hw/bsp/bmd300eval/src/os_bsp.c +++ b/hw/bsp/bmd300eval/src/os_bsp.c @@ -16,18 +16,36 @@ * specific language governing permissions and limitations * 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 "hal/flash_map.h" +#include "hal/hal_bsp.h" +#include "hal/hal_cputime.h" +#include "hal/hal_flash.h" +#include "hal/hal_spi.h" +#include "mcu/nrf52_hal.h" +#include "uart/uart.h" +#include "uart_hal/uart_hal.h" +#include "os/os_dev.h" +#include "bsp.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 "nrf.h" +#include "app_error.h" +#include "nrf_drv_saadc.h" + +#if MYNEWT_VAL(ADC_0) +#include "adc_nrf52/adc_nrf52.h" +#endif static struct flash_area bsp_flash_areas[] = { [FLASH_AREA_BOOTLOADER] = { @@ -58,6 +76,34 @@ static struct flash_area bsp_flash_areas[] = { } }; +#if MYNEWT_VAL(UART_0) +static struct uart_dev os_bsp_uart0; +static const struct nrf52_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 + +#if MYNEWT_VAL(UART_1) +static struct uart_dev os_bsp_bitbang_uart1; +static const struct uart_bitbang_conf os_bsp_uart1_cfg = { + .ubc_rxpin = MYNEWT_VAL(UART_1_PIN_TX), + .ubc_txpin = MYNEWT_VAL(UART_1_PIN_RX), + .ubc_cputimer_freq = MYNEWT_VAL(CLOCK_FREQ), +}; +#endif + +#if MYNEWT_VAL(ADC_0) +static struct adc_dev os_bsp_adc0; +static nrf_drv_saadc_config_t os_bsp_adc0_config = { + .resolution = MYNEWT_VAL(ADC_0_RESOLUTION), + .oversample = MYNEWT_VAL(ADC_0_OVERSAMPLE), + .interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY), +}; +#endif + void _close(int fd); /* @@ -87,35 +133,59 @@ void bsp_slot_init_split_application(void) { void bsp_init(void) { -#ifdef BSP_CFG_SPI_MASTER int rc; + +#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(0); #endif /* * XXX this reference is here to keep this function in. */ - _sbrk(0); - _close(0); + (void)_sbrk; + //(void)_close; + + /* Set cputime to count at 1 usec increments */ + rc = cputime_init(MYNEWT_VAL(CLOCK_FREQ)); + assert(rc == 0); flash_area_init(bsp_flash_areas, sizeof(bsp_flash_areas) / sizeof(bsp_flash_areas[0])); -#ifdef BSP_CFG_SPI_MASTER - /* We initialize one SPI interface as a master. */ + rc = hal_flash_init(); + assert(rc == 0); + +#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 = SPIS0_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(0, &spi_cfg, HAL_SPI_TYPE_SLAVE); assert(rc == 0); #endif + +#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(UART_1) + rc = os_dev_create((struct os_dev *) &os_bsp_bitbang_uart1, "uart1", + OS_DEV_INIT_PRIMARY, 0, uart_bitbang_init, (void *)&os_bsp_uart1_cfg); + assert(rc == 0); +#endif + +#if MYNEWT_VAL(ADC_0) + rc = os_dev_create((struct os_dev *) &os_bsp_adc0, "adc0", + OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT, + nrf52_adc_dev_init, &os_bsp_adc0_config); + assert(rc == 0); +#endif }