Syscfg - Fix a few more BSPs.
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/a1d31def Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a1d31def Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a1d31def Branch: refs/heads/develop Commit: a1d31defe5a9873d6a0ac7b49c3d22f80a1d3344 Parents: c181ac3 Author: Christopher Collins <ccoll...@apache.org> Authored: Tue Sep 13 10:15:03 2016 -0700 Committer: Christopher Collins <ccoll...@apache.org> Committed: Tue Sep 13 15:28:03 2016 -0700 ---------------------------------------------------------------------- hw/bsp/arduino_primo_nrf52/pkg.yml | 25 ++++++ hw/bsp/arduino_primo_nrf52/src/hal_bsp.c | 42 +--------- hw/bsp/arduino_primo_nrf52/src/os_bsp.c | 110 ++++++++++++++++++++++++-- hw/bsp/nrf51-blenano/pkg.yml | 17 +++- hw/bsp/nrf51-blenano/src/hal_bsp.c | 12 --- hw/bsp/nrf51-blenano/src/os_bsp.c | 31 +++++++- hw/bsp/nrf51dk/pkg.yml | 22 ++++-- hw/bsp/nrf51dk/src/hal_bsp.c | 31 ++------ hw/bsp/nrf51dk/src/os_bsp.c | 48 +++++++---- hw/bsp/nrf52dk/pkg.yml | 15 +++- hw/bsp/nrf52dk/src/hal_bsp.c | 15 +--- hw/bsp/nrf52dk/src/os_bsp.c | 23 +++++- 12 files changed, 268 insertions(+), 123 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/arduino_primo_nrf52/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/arduino_primo_nrf52/pkg.yml b/hw/bsp/arduino_primo_nrf52/pkg.yml index 63fe461..048f663 100644 --- a/hw/bsp/arduino_primo_nrf52/pkg.yml +++ b/hw/bsp/arduino_primo_nrf52/pkg.yml @@ -83,7 +83,32 @@ pkg.syscfg_defs: UART_0: description: 'TBD' value: 1 + UART_0_PIN_TX: + description: 'TBD' + value: 6 + UART_0_PIN_RX: + description: 'TBD' + value: 5 + UART_0_PIN_RTS: + description: 'TBD' + value: 0 + UART_0_PIN_CTS: + description: 'TBD' + value: 0 + UART_1: + description: 'Bitbanger UART' + value: 0 + UART_1_PIN_TX: + description: 'TBD' + value: 11 + UART_1_PIN_RX: + description: 'TBD' + value: 12 + UART_1_PIN_RTS: + description: 'TBD' + value: 0 + UART_1_PIN_CTS: description: 'TBD' value: 0 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c index 669c8f7..56501ac 100644 --- a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c +++ b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c @@ -24,27 +24,8 @@ #include <hal/hal_bsp.h> #include "mcu/nrf52_hal.h" -#include <hal/hal_cputime.h> #include <os/os_dev.h> -#include <uart/uart.h> -#include <uart_hal/uart_hal.h> -#include <uart_bitbang/uart_bitbang.h> -static const struct nrf52_uart_cfg uart0_cfg = { - .suc_pin_tx = 6, - .suc_pin_rx = 5, - .suc_pin_rts = 0, - .suc_pin_cts = 0 -}; - -static const struct uart_bitbang_conf uart1_cfg = { - .ubc_rxpin = 11, - .ubc_txpin = 12, - .ubc_cputimer_freq = 1000000, -}; - -static struct uart_dev hal_uart0; -static struct uart_dev bitbang_uart1; /* * What memory to include in coredump. @@ -75,25 +56,8 @@ bsp_core_dump(int *area_cnt) return dump_cfg; } -int -bsp_hal_init(void) +uint16_t +bsp_get_refmv(void *cfgdata) { - int rc; - - rc = os_dev_create((struct os_dev *) &hal_uart0, "uart0", - OS_DEV_INIT_PRIMARY, OS_DEV_INIT_PRIO_DEFAULT, - uart_hal_init, (void *)&uart0_cfg); - assert(rc == 0); - - /* - * Need to initialize cputime here, because bitbanger uart uses it. - */ - rc = cputime_init(1000000); - assert(rc == 0); - - rc = os_dev_create((struct os_dev *) &bitbang_uart1, "uart1", - OS_DEV_INIT_PRIMARY, 0, - uart_bitbang_init, (void *)&uart1_cfg); - assert(rc == 0); - return 0; + return (2800); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/arduino_primo_nrf52/src/os_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/arduino_primo_nrf52/src/os_bsp.c b/hw/bsp/arduino_primo_nrf52/src/os_bsp.c index 9682d45..09baf71 100644 --- a/hw/bsp/arduino_primo_nrf52/src/os_bsp.c +++ b/hw/bsp/arduino_primo_nrf52/src/os_bsp.c @@ -16,8 +16,33 @@ * specific language governing permissions and limitations * under the License. */ -#include <hal/flash_map.h> -#include <hal/hal_bsp.h> + +#include <assert.h> +#include "hal/flash_map.h" +#include "hal/hal_bsp.h" +#include "hal/hal_cputime.h" +#include "mcu/nrf52_hal.h" +#include "uart/uart.h" +#if MYNEWT_VAL(SPI_MASTER) +#include "hal/hal_spi.h" +#include "nrf_drv_spi.h" +#endif +#if MYNEWT_VAL(SPI_SLAVE) +#include "hal/hal_spi.h" +#include "nrf_drv_spis.h" +#endif +#if MYNEWT_VAL(UART_0) +#include "uart_hal/uart_hal.h" +#endif +#if MYNEWT_VAL(UART_1) +#include "uart_bitbang/uart_bitbang.h" +#endif +#include "nrf_drv_config.h" +#include "app_util_platform.h" +#include "nrf.h" +#include "app_error.h" +#include "adc_nrf52/adc_nrf52.h" +#include "nrf_drv_saadc.h" static struct flash_area bsp_flash_areas[] = { [FLASH_AREA_BOOTLOADER] = { @@ -48,10 +73,35 @@ static struct flash_area bsp_flash_areas[] = { } }; -void _close(int fd); +#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 -/* XXX should not be declaring function prototypes here */ -extern int bsp_hal_init(void); +#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); /* * Returns the flash map slot where the currently active image is located. @@ -70,6 +120,10 @@ bsp_imgr_current_slot(void) void bsp_init(void) { + int rc; + + (void)rc; + /* * XXX this reference is here to keep this function in. */ @@ -78,5 +132,49 @@ bsp_init(void) flash_area_init(bsp_flash_areas, sizeof(bsp_flash_areas) / sizeof(bsp_flash_areas[0])); - bsp_hal_init(); + + /* + * Need to initialize cputime here, because bitbanger uart uses it. + */ + rc = cputime_init(MYNEWT_VAL(CLOCK_FREQ)); + assert(rc == 0); + +#if MYNEWT_VAL(SPI_MASTER) + nrf_drv_spi_config_t spi_cfg = NRF_DRV_SPI_DEFAULT_CONFIG(0); +#endif +#if MYNEWT_VAL(SPI_SLAVE) + nrf_drv_spis_config_t spi_cfg = NRF_DRV_SPIS_DEFAULT_CONFIG(0); +#endif + +#if MYNEWT_VAL(SPI_MASTER) + /* We initialize one SPI interface as a master. */ + rc = hal_spi_init(0, &spi_cfg, HAL_SPI_TYPE_MASTER); + assert(rc == 0); +#endif + +#if MYNEWT_VAL(SPI_SLAVE) + /* We initialize one SPI interface as a master. */ + spi_cfg.csn_pin = SPIS0_CONFIG_CSN_PIN; + 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 } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/nrf51-blenano/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-blenano/pkg.yml b/hw/bsp/nrf51-blenano/pkg.yml index 20cd656..1914ca9 100644 --- a/hw/bsp/nrf51-blenano/pkg.yml +++ b/hw/bsp/nrf51-blenano/pkg.yml @@ -35,7 +35,7 @@ pkg.downloadscript: nrf51dk_download.sh pkg.debugscript: nrf51dk_debug.sh pkg.cflags: # Nordic SDK files require these defines. - - '-DNRF52' + - '-DNRF51' pkg.deps: - hw/mcu/nordic/nrf51xxx @@ -82,13 +82,22 @@ pkg.syscfg_defs: UART_0: description: 'TBD' value: 1 - UART_1: + UART_0_PIN_TX: description: 'TBD' - value: 0 + 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: 10 SPI_MASTER: description: 'TBD' - value: 1 + value: 0 SPI_SLAVE: description: 'TBD' value: 0 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/nrf51-blenano/src/hal_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-blenano/src/hal_bsp.c b/hw/bsp/nrf51-blenano/src/hal_bsp.c index bfca6f9..ee84922 100644 --- a/hw/bsp/nrf51-blenano/src/hal_bsp.c +++ b/hw/bsp/nrf51-blenano/src/hal_bsp.c @@ -21,18 +21,6 @@ #include <stddef.h> #include "mcu/nrf51_hal.h" -static const struct nrf51_uart_cfg uart_cfg = { - .suc_pin_tx = 9, - .suc_pin_rx = 11, - .suc_pin_rts = 8, - .suc_pin_cts = 10 -}; - -const struct nrf51_uart_cfg *bsp_uart_config(void) -{ - return &uart_cfg; -} - const struct hal_flash * bsp_flash_dev(uint8_t id) { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/nrf51-blenano/src/os_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-blenano/src/os_bsp.c b/hw/bsp/nrf51-blenano/src/os_bsp.c index 2b88f27..d64c265 100644 --- a/hw/bsp/nrf51-blenano/src/os_bsp.c +++ b/hw/bsp/nrf51-blenano/src/os_bsp.c @@ -16,7 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -#include <hal/flash_map.h> + +#include <assert.h> +#include "syscfg/syscfg.h" +#include "hal/flash_map.h" +#if MYNEWT_VAL(UART_0) +#include "mcu/nrf51_hal.h" +#include "uart/uart.h" +#include "uart_hal/uart_hal.h" +#endif +#include "os/os_dev.h" +#include "app_util_platform.h" static struct flash_area bsp_flash_areas[] = { [FLASH_AREA_BOOTLOADER] = { @@ -46,6 +56,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 *_sbrk(int incr); void _close(int fd); @@ -66,6 +86,10 @@ bsp_imgr_current_slot(void) void os_bsp_init(void) { + int rc; + + (void)rc; + /* * XXX this reference is here to keep this function in. */ @@ -75,4 +99,9 @@ os_bsp_init(void) flash_area_init(bsp_flash_areas, sizeof(bsp_flash_areas) / sizeof(bsp_flash_areas[0])); +#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 } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/nrf51dk/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml index c6d66bc..2ce5123 100644 --- a/hw/bsp/nrf51dk/pkg.yml +++ b/hw/bsp/nrf51dk/pkg.yml @@ -58,13 +58,13 @@ pkg.syscfg_defs: description: 'TBD' value: 1000000 - 32768_XTAL: + XTAL_32768: description: 'TBD' value: 1 ADC_0: description: 'TBD' - value: 1 + value: 1 ADC_0_RESOLUTION: description: 'TBD' value: 'SAADC_CONFIG_RESOLUTION' @@ -77,11 +77,23 @@ pkg.syscfg_defs: UART_0: description: 'TBD' - value: 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: 10 SPI_MASTER: description: 'TBD' - value: 1 + value: 1 SPI_SLAVE: description: 'TBD' - value: 0 + value: 0 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/nrf51dk/src/hal_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/src/hal_bsp.c b/hw/bsp/nrf51dk/src/hal_bsp.c index bf8711d..83d9bee 100644 --- a/hw/bsp/nrf51dk/src/hal_bsp.c +++ b/hw/bsp/nrf51dk/src/hal_bsp.c @@ -20,23 +20,12 @@ #include <stdint.h> #include <stddef.h> #include <assert.h> -#include <hal/hal_bsp.h> -#include <mcu/nrf51_hal.h> +#include "hal/hal_bsp.h" +#include "mcu/nrf51_hal.h" #include "bsp/bsp.h" -#include <nrf_adc.h> -#include <nrf_drv_adc.h> -#include <os/os_dev.h> -#include <uart/uart.h> -#include <uart_hal/uart_hal.h> - -static const struct nrf51_uart_cfg uart_cfg = { - .suc_pin_tx = 9, - .suc_pin_rx = 11, - .suc_pin_rts = 8, - .suc_pin_cts = 10 -}; - -static struct uart_dev hal_uart0; +#include "nrf_adc.h" +#include "nrf_drv_adc.h" +#include "os/os_dev.h" /* * What memory to include in coredump. @@ -102,13 +91,3 @@ bsp_get_refmv(void *cfgdata) return refmv; } - -void -bsp_hal_init(void) -{ - int rc; - - rc = os_dev_create((struct os_dev *)&hal_uart0, "uart0", - OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&uart_cfg); - assert(rc == 0); -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/nrf51dk/src/os_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/src/os_bsp.c b/hw/bsp/nrf51dk/src/os_bsp.c index 6d0800d..b772ac2 100644 --- a/hw/bsp/nrf51dk/src/os_bsp.c +++ b/hw/bsp/nrf51dk/src/os_bsp.c @@ -17,17 +17,22 @@ * 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_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,7 +62,16 @@ static struct flash_area bsp_flash_areas[] = { } }; -void bsp_hal_init(void); +#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); /* @@ -77,12 +91,20 @@ bsp_imgr_current_slot(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 @@ -95,15 +117,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 +#if MYNEWT_VAL(SPI_MASTER) /* We initialize one SPI interface as a master. */ rc = hal_spi_init(0, &spi_cfg, HAL_SPI_TYPE_MASTER); assert(rc == 0); #endif -#ifdef BSP_CFG_SPI_SLAVE +#if MYNEWT_VAL(SPI_SLAVE) /* We initialize one SPI interface as a master. */ spi_cfg.csn_pin = SPIS1_CONFIG_CSN_PIN; spi_cfg.csn_pullup = NRF_GPIO_PIN_PULLUP; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/nrf52dk/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52dk/pkg.yml b/hw/bsp/nrf52dk/pkg.yml index 5e617e5..fc7c774 100644 --- a/hw/bsp/nrf52dk/pkg.yml +++ b/hw/bsp/nrf52dk/pkg.yml @@ -82,8 +82,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/a1d31def/hw/bsp/nrf52dk/src/hal_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52dk/src/hal_bsp.c b/hw/bsp/nrf52dk/src/hal_bsp.c index cc5d7b6..9446b45 100644 --- a/hw/bsp/nrf52dk/src/hal_bsp.c +++ b/hw/bsp/nrf52dk/src/hal_bsp.c @@ -23,29 +23,16 @@ #include <hal/hal_bsp.h> #include "mcu/nrf52_hal.h" -static const struct nrf52_uart_cfg uart_cfg = { - .suc_pin_tx = 6, - .suc_pin_rx = 8, - .suc_pin_rts = 5, - .suc_pin_cts = 7 -}; - /* * What memory to include in coredump. */ static const struct bsp_mem_dump dump_cfg[] = { [0] = { - .bmd_start = &_ram_start, + .bmd_start = &_ram_start, .bmd_size = RAM_SIZE } }; -const struct nrf52_uart_cfg * -bsp_uart_config(void) -{ - return &uart_cfg; -} - const struct hal_flash * bsp_flash_dev(uint8_t id) { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1d31def/hw/bsp/nrf52dk/src/os_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52dk/src/os_bsp.c b/hw/bsp/nrf52dk/src/os_bsp.c index 1b3cfdd..d632d90 100644 --- a/hw/bsp/nrf52dk/src/os_bsp.c +++ b/hw/bsp/nrf52dk/src/os_bsp.c @@ -74,6 +74,21 @@ 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) @@ -144,7 +159,13 @@ bsp_init(void) #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 *)bsp_uart_config()); + 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