* debundle nordic ADC drivers, as they rely on Nordic SDK, which is now bundled separately
* debundle libraries/* which was not licensed correctly, and is distributed separately as a part of the nordic sdk * remove pointers to external nordic SDK, project now builds successfully without that dependency 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/267d86b3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/267d86b3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/267d86b3 Branch: refs/heads/1_0_0_b1_dev Commit: 267d86b3a639d4fb50bef65624fed797e9fcf419 Parents: a1481cb Author: Sterling Hughes <[email protected]> Authored: Mon Nov 21 21:30:09 2016 -0800 Committer: Sterling Hughes <[email protected]> Committed: Mon Nov 21 21:30:09 2016 -0800 ---------------------------------------------------------------------- hw/bsp/arduino_primo_nrf52/pkg.yml | 3 - hw/bsp/arduino_primo_nrf52/src/hal_bsp.c | 16 - hw/bsp/arduino_primo_nrf52/syscfg.yml | 13 - hw/bsp/bmd300eval/pkg.yml | 3 - hw/bsp/bmd300eval/src/hal_bsp.c | 18 - hw/bsp/bmd300eval/syscfg.yml | 13 - hw/bsp/nrf51-arduino_101/pkg.yml | 2 - hw/bsp/nrf51-arduino_101/syscfg.yml | 7 - hw/bsp/nrf51-blenano/pkg.yml | 3 - hw/bsp/nrf51-blenano/syscfg.yml | 7 - hw/bsp/nrf51dk-16kbram/pkg.yml | 3 - hw/bsp/nrf51dk-16kbram/syscfg.yml | 7 - hw/bsp/nrf51dk/pkg.yml | 5 - hw/bsp/nrf51dk/syscfg.yml | 7 - hw/bsp/nrf52dk/pkg.yml | 3 - hw/bsp/nrf52dk/src/hal_bsp.c | 16 - hw/bsp/nrf52dk/syscfg.yml | 13 - hw/bsp/rb-nano2/pkg.yml | 3 - hw/bsp/rb-nano2/syscfg.yml | 13 - .../adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h | 44 - hw/drivers/adc/adc_nrf51/pkg.yml | 28 - hw/drivers/adc/adc_nrf51/src/adc_nrf51.c | 405 --- .../adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h | 42 - hw/drivers/adc/adc_nrf52/pkg.yml | 28 - hw/drivers/adc/adc_nrf52/src/adc_nrf52.c | 404 --- hw/mcu/nordic/nrf51xxx/pkg.yml | 2 +- hw/mcu/nordic/nrf52xxx/pkg.yml | 2 +- hw/mcu/nordic/pkg.yml | 22 +- .../components/libraries/ant_fs/antfs.c | 2337 ------------------ .../components/libraries/ant_fs/antfs.h | 358 --- .../components/libraries/ant_fs/crc.c | 55 - .../components/libraries/ant_fs/crc.h | 50 - .../components/libraries/ant_fs/defines.h | 68 - .../components/libraries/ecc/ecc.c | 123 - .../components/libraries/ecc/ecc.h | 61 - .../components/libraries/timer/app_timer_rtx.c | 239 -- .../components/libraries/trace/app_trace.h | 64 - .../components/libraries/util/nrf_assert.h | 68 - .../components/libraries/util/nrf_log.c | 425 ---- .../components/libraries/util/nrf_log.h | 707 ------ 40 files changed, 3 insertions(+), 5684 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/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 ecaa468..8d6af0a 100644 --- a/hw/bsp/arduino_primo_nrf52/pkg.yml +++ b/hw/bsp/arduino_primo_nrf52/pkg.yml @@ -88,9 +88,6 @@ pkg.deps: pkg.deps.BLE_DEVICE: - hw/drivers/nimble/nrf52 -pkg.deps.ADC_0: - - hw/drivers/adc/adc_nrf52 - pkg.deps.UART_0: - hw/drivers/uart/uart_hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/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 232bd6d..1a61b07 100644 --- a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c +++ b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c @@ -37,9 +37,6 @@ #if MYNEWT_VAL(UART_1) #include "uart_bitbang/uart_bitbang.h" #endif -#if MYNEWT_VAL(ADC_0) -#include "adc_nrf52/adc_nrf52.h" -#endif #if MYNEWT_VAL(UART_0) static struct uart_dev os_bsp_uart0; @@ -60,13 +57,6 @@ static const struct uart_bitbang_conf os_bsp_uart1_cfg = { }; #endif -#if MYNEWT_VAL(ADC_0) -static struct adc_dev os_bsp_adc0; -static struct nrf52_adc_dev_cfg os_bsp_adc0_config = { - .nadc_refmv = 2800 -}; -#endif - #if MYNEWT_VAL(SPI_0_MASTER) /* * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line @@ -200,10 +190,4 @@ hal_bsp_init(void) 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/267d86b3/hw/bsp/arduino_primo_nrf52/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/arduino_primo_nrf52/syscfg.yml b/hw/bsp/arduino_primo_nrf52/syscfg.yml index cea5591..c353c54 100644 --- a/hw/bsp/arduino_primo_nrf52/syscfg.yml +++ b/hw/bsp/arduino_primo_nrf52/syscfg.yml @@ -36,19 +36,6 @@ syscfg.defs: description: 'TBD' value: 1 - ADC_0: - description: 'TBD' - value: 0 - ADC_0_RESOLUTION: - description: 'TBD' - value: 'SAADC_CONFIG_RESOLUTION' - ADC_0_OVERSAMPLE: - description: 'TBD' - value: 'SAADC_CONFIG_OVERSAMPLE' - ADC_0_INTERRUPT_PRIORITY: - description: 'TBD' - value: 'SAADC_CONFIG_IRQ_PRIORITY' - UART_0: description: 'TBD' value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/bmd300eval/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/pkg.yml b/hw/bsp/bmd300eval/pkg.yml index 4490156..a95cf05 100644 --- a/hw/bsp/bmd300eval/pkg.yml +++ b/hw/bsp/bmd300eval/pkg.yml @@ -87,9 +87,6 @@ pkg.deps: pkg.deps.BLE_DEVICE: - hw/drivers/nimble/nrf52 -pkg.deps.ADC_0: - - hw/drivers/adc/adc_nrf52 - pkg.deps.UART_0: - hw/drivers/uart/uart_hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/bmd300eval/src/hal_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/src/hal_bsp.c b/hw/bsp/bmd300eval/src/hal_bsp.c index 117dd26..7bd7e2d 100644 --- a/hw/bsp/bmd300eval/src/hal_bsp.c +++ b/hw/bsp/bmd300eval/src/hal_bsp.c @@ -33,10 +33,6 @@ #include "os/os_dev.h" #include "bsp.h" -#if MYNEWT_VAL(ADC_0) -#include "adc_nrf52/adc_nrf52.h" -#endif - #if MYNEWT_VAL(UART_0) static struct uart_dev os_bsp_uart0; static const struct nrf52_uart_cfg os_bsp_uart0_cfg = { @@ -56,13 +52,6 @@ static const struct uart_bitbang_conf os_bsp_uart1_cfg = { }; #endif -#if MYNEWT_VAL(ADC_0) -static struct adc_dev os_bsp_adc0; -static struct nrf52_adc_dev_cfg os_bsp_adc0_config = { - .nadc_refmv = 2800 -}; -#endif - #if MYNEWT_VAL(SPI_0_MASTER) /* * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line @@ -195,11 +184,4 @@ hal_bsp_init(void) 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/267d86b3/hw/bsp/bmd300eval/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/syscfg.yml b/hw/bsp/bmd300eval/syscfg.yml index 35837af..ccfdadb 100644 --- a/hw/bsp/bmd300eval/syscfg.yml +++ b/hw/bsp/bmd300eval/syscfg.yml @@ -32,19 +32,6 @@ syscfg.defs: description: 'TBD' value: 1 - ADC_0: - description: 'TBD' - value: 0 - ADC_0_RESOLUTION: - description: 'TBD' - value: 'SAADC_CONFIG_RESOLUTION' - ADC_0_OVERSAMPLE: - description: 'TBD' - value: 'SAADC_CONFIG_OVERSAMPLE' - ADC_0_INTERRUPT_PRIORITY: - description: 'TBD' - value: 'SAADC_CONFIG_IRQ_PRIORITY' - UART_0: description: 'TBD' value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf51-arduino_101/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-arduino_101/pkg.yml b/hw/bsp/nrf51-arduino_101/pkg.yml index 062bd9a..1243efb 100644 --- a/hw/bsp/nrf51-arduino_101/pkg.yml +++ b/hw/bsp/nrf51-arduino_101/pkg.yml @@ -88,8 +88,6 @@ pkg.deps: pkg.deps.BLE_DEVICE: - hw/drivers/nimble/nrf51 -pkg.deps.ADC_0: - - hw/drivers/adc/adc_nrf51 pkg.deps.UART_0: - hw/drivers/uart/uart_hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf51-arduino_101/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-arduino_101/syscfg.yml b/hw/bsp/nrf51-arduino_101/syscfg.yml index 42e8c64..8c47db4 100644 --- a/hw/bsp/nrf51-arduino_101/syscfg.yml +++ b/hw/bsp/nrf51-arduino_101/syscfg.yml @@ -32,13 +32,6 @@ syscfg.defs: description: 'TBD' value: 1 - ADC_0: - description: 'TBD' - value: 0 - ADC_0_INTERRUPT_PRIORITY: - description: 'TBD' - value: 'ADC_CONFIG_IRQ_PRIORITY' - UART_0: description: 'TBD' value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf51-blenano/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-blenano/pkg.yml b/hw/bsp/nrf51-blenano/pkg.yml index 61553a5..839cec8 100644 --- a/hw/bsp/nrf51-blenano/pkg.yml +++ b/hw/bsp/nrf51-blenano/pkg.yml @@ -87,9 +87,6 @@ pkg.deps: pkg.deps.BLE_DEVICE: - hw/drivers/nimble/nrf51 -pkg.deps.ADC_0: - - hw/drivers/adc/adc_nrf51 - pkg.deps.UART_0: - hw/drivers/uart/uart_hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf51-blenano/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-blenano/syscfg.yml b/hw/bsp/nrf51-blenano/syscfg.yml index defcd55..569382d 100644 --- a/hw/bsp/nrf51-blenano/syscfg.yml +++ b/hw/bsp/nrf51-blenano/syscfg.yml @@ -32,13 +32,6 @@ syscfg.defs: description: 'TBD' value: 1 - ADC_0: - description: 'TBD' - value: 1 - ADC_0_INTERRUPT_PRIORITY: - description: 'TBD' - value: 'ADC_CONFIG_IRQ_PRIORITY' - UART_0: description: 'TBD' value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf51dk-16kbram/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk-16kbram/pkg.yml b/hw/bsp/nrf51dk-16kbram/pkg.yml index 9c95016..bbb5f33 100644 --- a/hw/bsp/nrf51dk-16kbram/pkg.yml +++ b/hw/bsp/nrf51dk-16kbram/pkg.yml @@ -88,9 +88,6 @@ pkg.deps: pkg.deps.BLE_DEVICE: - hw/drivers/nimble/nrf51 -pkg.deps.ADC_0: - - hw/drivers/adc/adc_nrf51 - pkg.deps.UART_0: - hw/drivers/uart/uart_hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf51dk-16kbram/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk-16kbram/syscfg.yml b/hw/bsp/nrf51dk-16kbram/syscfg.yml index 8a076f5..8e14b43 100644 --- a/hw/bsp/nrf51dk-16kbram/syscfg.yml +++ b/hw/bsp/nrf51dk-16kbram/syscfg.yml @@ -32,13 +32,6 @@ syscfg.defs: description: 'TBD' value: 1 - ADC_0: - description: 'TBD' - value: 0 - ADC_0_INTERRUPT_PRIORITY: - description: 'TBD' - value: 'ADC_CONFIG_IRQ_PRIORITY' - UART_0: description: 'TBD' value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf51dk/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml index 16d04bd..ddf62bd 100644 --- a/hw/bsp/nrf51dk/pkg.yml +++ b/hw/bsp/nrf51dk/pkg.yml @@ -28,7 +28,6 @@ pkg.keywords: pkg.cflags: # Nordic SDK files require these defines. - - '-DADC_ENABLED=1' - '-DCLOCK_ENABLED=1' - '-DCOMP_ENABLED=0' - '-DEGU_ENABLED=0' @@ -46,7 +45,6 @@ pkg.cflags: - '-DRTC0_ENABLED=0' - '-DRTC1_ENABLED=0' - '-DRTC2_ENABLED=0' - - '-DSAADC_ENABLED=0' - '-DSPI0_CONFIG_MISO_PIN=28' - '-DSPI0_CONFIG_MOSI_PIN=25' - '-DSPI0_CONFIG_SCK_PIN=29' @@ -86,9 +84,6 @@ pkg.deps: pkg.deps.BLE_DEVICE: - hw/drivers/nimble/nrf51 -pkg.deps.ADC_0: - - hw/drivers/adc/adc_nrf51 - pkg.deps.UART_0: - hw/drivers/uart/uart_hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf51dk/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/syscfg.yml b/hw/bsp/nrf51dk/syscfg.yml index 78129ce..bade890 100644 --- a/hw/bsp/nrf51dk/syscfg.yml +++ b/hw/bsp/nrf51dk/syscfg.yml @@ -32,13 +32,6 @@ syscfg.defs: description: 'TBD' value: 1 - ADC_0: - description: 'TBD' - value: 1 - ADC_0_INTERRUPT_PRIORITY: - description: 'TBD' - value: 'ADC_CONFIG_IRQ_PRIORITY' - UART_0: description: 'TBD' value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/nrf52dk/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52dk/pkg.yml b/hw/bsp/nrf52dk/pkg.yml index cdda423..f2685f8 100644 --- a/hw/bsp/nrf52dk/pkg.yml +++ b/hw/bsp/nrf52dk/pkg.yml @@ -87,9 +87,6 @@ pkg.deps: pkg.deps.BLE_DEVICE: - hw/drivers/nimble/nrf52 -pkg.deps.ADC_0: - - hw/drivers/adc/adc_nrf52 - pkg.deps.UART_0: - hw/drivers/uart/uart_hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/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 e6f51fc..be8322e 100644 --- a/hw/bsp/nrf52dk/src/hal_bsp.c +++ b/hw/bsp/nrf52dk/src/hal_bsp.c @@ -35,9 +35,6 @@ #include "uart_hal/uart_hal.h" #include "os/os_dev.h" #include "bsp.h" -#if MYNEWT_VAL(ADC_0) -#include "adc_nrf52/adc_nrf52.h" -#endif #if MYNEWT_VAL(UART_0) static struct uart_dev os_bsp_uart0; @@ -58,13 +55,6 @@ static const struct uart_bitbang_conf os_bsp_uart1_cfg = { }; #endif -#if MYNEWT_VAL(ADC_0) -static struct adc_dev os_bsp_adc0; -static struct nrf52_adc_dev_cfg os_bsp_adc0_config = { - .nadc_refmv = 2800 -}; -#endif - #if MYNEWT_VAL(SPI_0_MASTER) /* * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line @@ -211,10 +201,4 @@ hal_bsp_init(void) 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/267d86b3/hw/bsp/nrf52dk/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52dk/syscfg.yml b/hw/bsp/nrf52dk/syscfg.yml index bc62394..18024af 100644 --- a/hw/bsp/nrf52dk/syscfg.yml +++ b/hw/bsp/nrf52dk/syscfg.yml @@ -29,19 +29,6 @@ syscfg.defs: XTAL_32768: description: 'TBD' value: 1 - ADC_0: - description: 'TBD' - value: 0 - ADC_0_RESOLUTION: - description: 'TBD' - value: 'SAADC_CONFIG_RESOLUTION' - ADC_0_OVERSAMPLE: - description: 'TBD' - value: 'SAADC_CONFIG_OVERSAMPLE' - ADC_0_INTERRUPT_PRIORITY: - description: 'TBD' - value: 'SAADC_CONFIG_IRQ_PRIORITY' - UART_0: description: 'TBD' value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/rb-nano2/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/rb-nano2/pkg.yml b/hw/bsp/rb-nano2/pkg.yml index 69497c0..4bce2f5 100644 --- a/hw/bsp/rb-nano2/pkg.yml +++ b/hw/bsp/rb-nano2/pkg.yml @@ -88,8 +88,5 @@ pkg.deps: pkg.deps.BLE_DEVICE: - hw/drivers/nimble/nrf52 -pkg.deps.ADC_0: - - hw/drivers/adc/adc_nrf52 - pkg.deps.UART_0: - hw/drivers/uart/uart_hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/bsp/rb-nano2/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/rb-nano2/syscfg.yml b/hw/bsp/rb-nano2/syscfg.yml index 8631290..ad48bd6 100644 --- a/hw/bsp/rb-nano2/syscfg.yml +++ b/hw/bsp/rb-nano2/syscfg.yml @@ -31,19 +31,6 @@ syscfg.defs: XTAL_32768: description: 'TBD' value: 1 - ADC_0: - description: 'TBD' - value: 0 - ADC_0_RESOLUTION: - description: 'TBD' - value: 'SAADC_CONFIG_RESOLUTION' - ADC_0_OVERSAMPLE: - description: 'TBD' - value: 'SAADC_CONFIG_OVERSAMPLE' - ADC_0_INTERRUPT_PRIORITY: - description: 'TBD' - value: 'SAADC_CONFIG_IRQ_PRIORITY' - UART_0: description: 'TBD' value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h ---------------------------------------------------------------------- diff --git a/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h b/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h deleted file mode 100644 index d681404..0000000 --- a/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef __ADC_NRF51_H__ -#define __ADC_NRF51_H__ - -#include <adc/adc.h> - -#include <nrf.h> -#include <nrf_adc.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct nrf51_adc_dev_cfg { - uint16_t nadc_refmv0; /* reference mV in AREF0 */ - uint16_t nadc_refmv1; /* reference mV in AREF1 */ - uint16_t nadc_refmv_vdd; /* reference mV in VDD */ -}; - -int nrf51_adc_dev_init(struct os_dev *, void *); - -#ifdef __cplusplus -} -#endif - -#endif /* __ADC_NRF51_H__ */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/drivers/adc/adc_nrf51/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/drivers/adc/adc_nrf51/pkg.yml b/hw/drivers/adc/adc_nrf51/pkg.yml deleted file mode 100644 index 03e4120..0000000 --- a/hw/drivers/adc/adc_nrf51/pkg.yml +++ /dev/null @@ -1,28 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# 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, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -pkg.name: hw/drivers/adc/adc_nrf51 -pkg.description: ADC driver for the NRF51 -pkg.author: "Apache Mynewt <[email protected]>" -pkg.homepage: "http://mynewt.apache.org/" -pkg.keywords: -pkg.apis: - - ADC_HW_IMPL -pkg.deps: - - hw/drivers/adc http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c ---------------------------------------------------------------------- diff --git a/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c b/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c deleted file mode 100644 index 129fb4a..0000000 --- a/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -#include <hal/hal_bsp.h> -#include <adc/adc.h> -#include <assert.h> -#include <os/os.h> -#include <bsp/cmsis_nvic.h> - -/* Nordic headers */ -#include <nrf.h> -#include <nrf_adc.h> -#include <nrf_drv_adc.h> -#include <app_error.h> - -#include "adc_nrf51/adc_nrf51.h" - -/** - * Weak symbol, this is defined in Nordic drivers but not exported. - * Needed for NVIC_SetVector(). - */ -extern void ADC_IRQHandler(void); - -#define NRF_ADC_CHANNEL_COUNT (1) - -struct nrf51_adc_stats { - uint16_t adc_events; - uint16_t adc_events_failed; -}; -static struct nrf51_adc_stats nrf51_adc_stats; - -static struct adc_dev *global_adc_dev; - -static nrf_drv_adc_config_t *global_adc_config; -static struct nrf51_adc_dev_cfg *init_adc_config; - -static struct adc_chan_config nrf51_adc_chans[NRF_ADC_CHANNEL_COUNT]; -static nrf_drv_adc_channel_t *nrf_adc_chan; - -static void -nrf51_adc_event_handler(const nrf_drv_adc_evt_t *event) -{ - nrf_drv_adc_done_evt_t *done_ev; - int rc; - - if (global_adc_dev == NULL) { - ++nrf51_adc_stats.adc_events_failed; - return; - } - - ++nrf51_adc_stats.adc_events; - - /* Right now only data reads supported, assert for unknown event - * type. - */ - assert(event->type == NRF_DRV_ADC_EVT_DONE); - - done_ev = (nrf_drv_adc_done_evt_t * const) &event->data.done; - - rc = global_adc_dev->ad_event_handler_func(global_adc_dev, - global_adc_dev->ad_event_handler_arg, - ADC_EVENT_RESULT, done_ev->p_buffer, - done_ev->size * sizeof(nrf_adc_value_t)); - if (rc != 0) { - ++nrf51_adc_stats.adc_events_failed; - } -} - -/** - * Open the NRF51 ADC device - * - * This function locks the device for access from other tasks. - * - * @param odev The OS device to open - * @param wait The time in MS to wait. If 0 specified, returns immediately - * if resource unavailable. If OS_WAIT_FOREVER specified, blocks - * until resource is available. - * @param arg Argument provided by higher layer to open, in this case - * it can be a nrf_drv_saadc_config_t, to override the default - * configuration. - * - * @return 0 on success, non-zero on failure. - */ -static int -nrf51_adc_open(struct os_dev *odev, uint32_t wait, void *arg) -{ - struct adc_dev *dev; - nrf_drv_adc_config_t *cfg; - int rc; - - dev = (struct adc_dev *) odev; - - if (os_started()) { - rc = os_mutex_pend(&dev->ad_lock, wait); - if (rc != OS_OK) { - goto err; - } - } - - /* Initialize the device */ - cfg = (nrf_drv_adc_config_t *)arg; - rc = nrf_drv_adc_init(cfg, nrf51_adc_event_handler); - if (rc != 0) { - goto err; - } - - global_adc_dev = dev; - global_adc_config = arg; - - return (0); -err: - return (rc); -} - - -/** - * Close the NRF51 ADC device. - * - * This function unlocks the device. - * - * @param odev The device to close. - */ -static int -nrf51_adc_close(struct os_dev *odev) -{ - struct adc_dev *dev; - - dev = (struct adc_dev *) odev; - - nrf_drv_adc_uninit(); - - global_adc_dev = NULL; - global_adc_config = NULL; - - if (os_started()) { - os_mutex_release(&dev->ad_lock); - } - - return (0); -} - -/** - * Configure an ADC channel on the Nordic ADC. - * - * @param dev The ADC device to configure - * @param cnum The channel on the ADC device to configure - * @param cfgdata An opaque pointer to channel config, expected to be - * a nrf_drv_adc_channel_config_t - * - * @return 0 on success, non-zero on failure. - */ -static int -nrf51_adc_configure_channel(struct adc_dev *dev, uint8_t cnum, - void *cfgdata) -{ - nrf_drv_adc_channel_t *cc; - nrf_drv_adc_channel_config_t *cc_cfg; - nrf_adc_config_t adc_cfg; - uint16_t refmv; - uint8_t res; - int rc; - - rc = -1; - if (global_adc_config == NULL) { - goto err; - } - - cc = (nrf_drv_adc_channel_t *)cfgdata; - nrf_adc_chan = cc; - cc_cfg = &cc->config.config; - - adc_cfg.reference = cc_cfg->reference | - (cc_cfg->external_reference << ADC_CONFIG_EXTREFSEL_Pos); - adc_cfg.resolution = cc_cfg->resolution; - adc_cfg.scaling = cc_cfg->input; - nrf_adc_configure(&adc_cfg); - nrf_drv_adc_channel_enable(cc); - - /* Set the resolution and reference voltage for this channel to - * enable conversion functions. - */ - switch (adc_cfg.resolution) { - case NRF_ADC_CONFIG_RES_8BIT: - res = 8; - break; - case NRF_ADC_CONFIG_RES_9BIT: - res = 9; - break; - case NRF_ADC_CONFIG_RES_10BIT: - res = 10; - break; - default: - assert(0); - } - - switch (adc_cfg.reference) { - case NRF_ADC_CONFIG_REF_VBG: - refmv = 1200; /* 1.2V for NRF51 */ - break; - case NRF_ADC_CONFIG_REF_EXT_REF0: - refmv = init_adc_config->nadc_refmv0; - break; - case NRF_ADC_CONFIG_REF_EXT_REF1: - refmv = init_adc_config->nadc_refmv1; - break; - case NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF: - refmv = init_adc_config->nadc_refmv_vdd / 2; - break; - case NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD: - refmv = init_adc_config->nadc_refmv_vdd / 3; - break; - default: - assert(0); - } - - /* Adjust reference voltage for gain. */ - switch (cc_cfg->input) { - case NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE: - break; - case NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD: - refmv *= 3; - break; - case NRF_ADC_CONFIG_SCALING_INPUT_TWO_THIRDS: - refmv = (refmv * 3) / 2; - break; - case NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD: - refmv = refmv * 3; - break; - case NRF_ADC_CONFIG_SCALING_SUPPLY_TWO_THIRDS: - refmv = (refmv * 3) / 2; - break; - default: - break; - } - - /* Store these values in channel definitions, for conversions to - * milivolts. - */ - dev->ad_chans[cnum].c_res = res; - dev->ad_chans[cnum].c_refmv = refmv; - dev->ad_chans[cnum].c_configured = 1; - - return (0); -err: - return (rc); -} - -/** - * Set buffer to read data into. Implementation of setbuffer handler. - * Sets both the primary and secondary buffers for DMA. - */ -static int -nrf51_adc_set_buffer(struct adc_dev *dev, void *buf1, void *buf2, - int buf_len) -{ - int rc; - - /* XXX: If this is called in blocking mode, it will result in a wait. */ - - /* Convert overall buffer length, into a total number of samples which - * Nordic APIs expect. - */ - buf_len /= sizeof(nrf_adc_value_t); - - rc = nrf_drv_adc_buffer_convert((nrf_adc_value_t *) buf1, buf_len); - if (rc != 0) { - goto err; - } - - /* XXX: For now, only support one buffer */ -#if 0 - if (buf2) { - rc = nrf_drv_adc_buffer_convert((nrf_adc_value_t *) buf2, - buf_len); - if (rc != 0) { - goto err; - } - } -#endif - return (0); -err: - return (rc); -} - -static int -nrf51_adc_release_buffer(struct adc_dev *dev, void *buf, int buf_len) -{ - int rc; - - buf_len /= sizeof(nrf_adc_value_t); - - rc = nrf_drv_adc_buffer_convert((nrf_adc_value_t *) buf, buf_len); - if (rc != 0) { - goto err; - } - - return (0); -err: - return (rc); -} - -/** - * Trigger an ADC sample. - */ -static int -nrf51_adc_sample(struct adc_dev *dev) -{ - nrf_drv_adc_sample(); - - return (0); -} - -/** - * Blocking read of an ADC channel, returns result as an integer. - */ -static int -nrf51_adc_read_channel(struct adc_dev *dev, uint8_t cnum, int *result) -{ - nrf_adc_value_t adc_value; - int rc; - - rc = nrf_drv_adc_sample_convert(nrf_adc_chan, &adc_value); - if (rc == 0) { - *result = (int) adc_value; - } - return (rc); -} - -static int -nrf51_adc_read_buffer(struct adc_dev *dev, void *buf, int buf_len, int off, - int *result) -{ - nrf_adc_value_t val; - int data_off; - - data_off = off * sizeof(nrf_adc_value_t); - assert(data_off < buf_len); - - val = *(nrf_adc_value_t *) ((uint8_t *) buf + data_off); - *result = val; - - return (0); -} - -static int -nrf51_adc_size_buffer(struct adc_dev *dev, int chans, int samples) -{ - return (sizeof(nrf_adc_value_t) * chans * samples); -} - - -/** - * Callback to initialize an adc_dev structure from the os device - * initialization callback. This sets up a nrf51_adc_device(), so that - * subsequent lookups to this device allow us to manipulate it. - */ -int -nrf51_adc_dev_init(struct os_dev *odev, void *arg) -{ - struct adc_dev *dev; - struct adc_driver_funcs *af; - - dev = (struct adc_dev *) odev; - - os_mutex_init(&dev->ad_lock); - - dev->ad_chans = (void *) nrf51_adc_chans; - dev->ad_chan_count = NRF_ADC_CHANNEL_COUNT; - - OS_DEV_SETHANDLERS(odev, nrf51_adc_open, nrf51_adc_close); - - assert(init_adc_config == NULL || init_adc_config == arg); - init_adc_config = arg; - - af = &dev->ad_funcs; - - af->af_configure_channel = nrf51_adc_configure_channel; - af->af_sample = nrf51_adc_sample; - af->af_read_channel = nrf51_adc_read_channel; - af->af_set_buffer = nrf51_adc_set_buffer; - af->af_release_buffer = nrf51_adc_release_buffer; - af->af_read_buffer = nrf51_adc_read_buffer; - af->af_size_buffer = nrf51_adc_size_buffer; - - NVIC_SetVector(ADC_IRQn, (uint32_t) ADC_IRQHandler); - - return (0); -} - - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h ---------------------------------------------------------------------- diff --git a/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h b/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h deleted file mode 100644 index 6aadb4c..0000000 --- a/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef __ADC_NRF52_H__ -#define __ADC_NRF52_H__ - -#include <adc/adc.h> - -#include <nrf.h> -#include <nrf_saadc.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct nrf52_adc_dev_cfg { - uint16_t nadc_refmv; /* reference VDD in mV */ -}; - -int nrf52_adc_dev_init(struct os_dev *, void *); - -#ifdef __cplusplus -} -#endif - -#endif /* __ADC_H__ */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/drivers/adc/adc_nrf52/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/drivers/adc/adc_nrf52/pkg.yml b/hw/drivers/adc/adc_nrf52/pkg.yml deleted file mode 100644 index cd029e5..0000000 --- a/hw/drivers/adc/adc_nrf52/pkg.yml +++ /dev/null @@ -1,28 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# 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, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -pkg.name: hw/drivers/adc/adc_nrf52 -pkg.description: ADC driver for the NRF52 -pkg.author: "Apache Mynewt <[email protected]>" -pkg.homepage: "http://mynewt.apache.org/" -pkg.keywords: -pkg.apis: - - ADC_HW_IMPL -pkg.deps: - - hw/drivers/adc http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c ---------------------------------------------------------------------- diff --git a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c deleted file mode 100644 index 5054a9f..0000000 --- a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -#include <hal/hal_bsp.h> -#include <adc/adc.h> -#include <assert.h> -#include <os/os.h> -#include <bsp/cmsis_nvic.h> - -/* Nordic headers */ -#include <nrf.h> -#include <nrf_saadc.h> -#include <nrf_drv_saadc.h> -#include <app_error.h> - -#include "adc_nrf52/adc_nrf52.h" - -/** - * Weak symbol, this is defined in Nordic drivers but not exported. - * Needed for NVIC_SetVector(). - */ -extern void SAADC_IRQHandler(void); - -struct nrf52_saadc_stats { - uint16_t saadc_events; - uint16_t saadc_events_failed; -}; -static struct nrf52_saadc_stats nrf52_saadc_stats; - -static struct adc_dev *global_adc_dev; -static nrf_drv_saadc_config_t *global_adc_config; -static struct nrf52_adc_dev_cfg *init_adc_config; - -static uint8_t nrf52_adc_chans[NRF_SAADC_CHANNEL_COUNT * sizeof(struct adc_chan_config)]; - -static void -nrf52_saadc_event_handler(const nrf_drv_saadc_evt_t *event) -{ - nrf_drv_saadc_done_evt_t *done_ev; - int rc; - - if (global_adc_dev == NULL) { - ++nrf52_saadc_stats.saadc_events_failed; - return; - } - - ++nrf52_saadc_stats.saadc_events; - - /* Right now only data reads supported, assert for unknown event - * type. - */ - assert(event->type == NRF_DRV_SAADC_EVT_DONE); - - done_ev = (nrf_drv_saadc_done_evt_t * const) &event->data.done; - - rc = global_adc_dev->ad_event_handler_func(global_adc_dev, - global_adc_dev->ad_event_handler_arg, - ADC_EVENT_RESULT, done_ev->p_buffer, - done_ev->size * sizeof(nrf_saadc_value_t)); - if (rc != 0) { - ++nrf52_saadc_stats.saadc_events_failed; - } -} - - -/** - * Open the NRF52 ADC device - * - * This function locks the device for access from other tasks. - * - * @param odev The OS device to open - * @param wait The time in MS to wait. If 0 specified, returns immediately - * if resource unavailable. If OS_WAIT_FOREVER specified, blocks - * until resource is available. - * @param arg Argument provided by higher layer to open, in this case - * it can be a nrf_drv_saadc_config_t, to override the default - * configuration. - * - * @return 0 on success, non-zero on failure. - */ -static int -nrf52_adc_open(struct os_dev *odev, uint32_t wait, void *arg) -{ - struct adc_dev *dev; - int rc; - - dev = (struct adc_dev *) odev; - - if (os_started()) { - rc = os_mutex_pend(&dev->ad_lock, wait); - if (rc != OS_OK) { - goto err; - } - } - - if (odev->od_flags & OS_DEV_F_STATUS_OPEN) { - os_mutex_release(&dev->ad_lock); - rc = OS_EBUSY; - goto err; - } - - /* Initialize the device */ - rc = nrf_drv_saadc_init((nrf_drv_saadc_config_t *) arg, - nrf52_saadc_event_handler); - if (rc != 0) { - goto err; - } - - global_adc_dev = dev; - global_adc_config = arg; - - return (0); -err: - return (rc); -} - - -/** - * Close the NRF52 ADC device. - * - * This function unlocks the device. - * - * @param odev The device to close. - */ -static int -nrf52_adc_close(struct os_dev *odev) -{ - struct adc_dev *dev; - - dev = (struct adc_dev *) odev; - - nrf_drv_saadc_uninit(); - - global_adc_dev = NULL; - global_adc_config = NULL; - - if (os_started()) { - os_mutex_release(&dev->ad_lock); - } - - return (0); -} - -/** - * Configure an ADC channel on the Nordic ADC. - * - * @param dev The ADC device to configure - * @param cnum The channel on the ADC device to configure - * @param cfgdata An opaque pointer to channel config, expected to be - * a nrf_saadc_channel_config_t - * - * @return 0 on success, non-zero on failure. - */ -static int -nrf52_adc_configure_channel(struct adc_dev *dev, uint8_t cnum, - void *cfgdata) -{ - nrf_saadc_channel_config_t *cc; - uint16_t refmv; - uint8_t res; - int rc; - - cc = (nrf_saadc_channel_config_t *) cfgdata; - - rc = nrf_drv_saadc_channel_init(cnum, cc); - if (rc != 0) { - goto err; - } - - if (global_adc_config) { - /* Set the resolution and reference voltage for this channel to - * enable conversion functions. - */ - switch (global_adc_config->resolution) { - case NRF_SAADC_RESOLUTION_8BIT: - res = 8; - break; - case NRF_SAADC_RESOLUTION_10BIT: - res = 10; - break; - case NRF_SAADC_RESOLUTION_12BIT: - res = 12; - break; - case NRF_SAADC_RESOLUTION_14BIT: - res = 14; - break; - default: - assert(0); - } - } else { - /* Default to 10-bit resolution. */ - res = 10; - } - - switch (cc->reference) { - case NRF_SAADC_REFERENCE_INTERNAL: - refmv = 600; /* 0.6V for NRF52 */ - break; - case NRF_SAADC_REFERENCE_VDD4: - refmv = init_adc_config->nadc_refmv / 4; - break; - default: - assert(0); - } - - /* Adjust reference voltage for gain. */ - switch (cc->gain) { - case NRF_SAADC_GAIN1_6: - refmv *= 6; - break; - case NRF_SAADC_GAIN1_5: - refmv *= 5; - break; - case NRF_SAADC_GAIN1_4: - refmv *= 4; - break; - case NRF_SAADC_GAIN1_3: - refmv *= 3; - break; - case NRF_SAADC_GAIN1_2: - refmv *= 2; - break; - case NRF_SAADC_GAIN2: - refmv /= 2; - break; - case NRF_SAADC_GAIN4: - refmv /= 4; - break; - default: - break; - } - - /* Store these values in channel definitions, for conversions to - * milivolts. - */ - dev->ad_chans[cnum].c_res = res; - dev->ad_chans[cnum].c_refmv = refmv; - dev->ad_chans[cnum].c_configured = 1; - - return (0); -err: - return (rc); -} - -/** - * Set buffer to read data into. Implementation of setbuffer handler. - * Sets both the primary and secondary buffers for DMA. - */ -static int -nrf52_adc_set_buffer(struct adc_dev *dev, void *buf1, void *buf2, - int buf_len) -{ - int rc; - - /* Convert overall buffer length, into a total number of samples which - * Nordic APIs expect. - */ - buf_len /= sizeof(nrf_saadc_value_t); - - rc = nrf_drv_saadc_buffer_convert((nrf_saadc_value_t *) buf1, buf_len); - if (rc != 0) { - goto err; - } - - if (buf2) { - rc = nrf_drv_saadc_buffer_convert((nrf_saadc_value_t *) buf2, - buf_len); - if (rc != 0) { - goto err; - } - } - return (0); -err: - return (rc); -} - -static int -nrf52_adc_release_buffer(struct adc_dev *dev, void *buf, int buf_len) -{ - int rc; - - buf_len /= sizeof(nrf_saadc_value_t); - - rc = nrf_drv_saadc_buffer_convert((nrf_saadc_value_t *) buf, buf_len); - if (rc != 0) { - goto err; - } - - return (0); -err: - return (rc); -} - -/** - * Trigger an ADC sample. - */ -static int -nrf52_adc_sample(struct adc_dev *dev) -{ - nrf_drv_saadc_sample(); - - return (0); -} - -/** - * Blocking read of an ADC channel, returns result as an integer. - */ -static int -nrf52_adc_read_channel(struct adc_dev *dev, uint8_t cnum, int *result) -{ - nrf_saadc_value_t adc_value; - int rc; - - rc = nrf_drv_saadc_sample_convert(cnum, &adc_value); - if (rc != 0) { - goto err; - } - - *result = (int) adc_value; - - return (0); -err: - return (rc); -} - -static int -nrf52_adc_read_buffer(struct adc_dev *dev, void *buf, int buf_len, int off, - int *result) -{ - nrf_saadc_value_t val; - int data_off; - - data_off = off * sizeof(nrf_saadc_value_t); - assert(data_off < buf_len); - - val = *(nrf_saadc_value_t *) ((uint8_t *) buf + data_off); - *result = val; - - return (0); -} - -static int -nrf52_adc_size_buffer(struct adc_dev *dev, int chans, int samples) -{ - return (sizeof(nrf_saadc_value_t) * chans * samples); -} - - -/** - * Callback to initialize an adc_dev structure from the os device - * initialization callback. This sets up a nrf52_adc_device(), so - * that subsequent lookups to this device allow us to manipulate it. - */ -int -nrf52_adc_dev_init(struct os_dev *odev, void *arg) -{ - struct adc_dev *dev; - struct adc_driver_funcs *af; - - dev = (struct adc_dev *) odev; - - os_mutex_init(&dev->ad_lock); - - dev->ad_chans = (void *) nrf52_adc_chans; - dev->ad_chan_count = NRF_SAADC_CHANNEL_COUNT; - - OS_DEV_SETHANDLERS(odev, nrf52_adc_open, nrf52_adc_close); - - assert(init_adc_config == NULL || init_adc_config == arg); - init_adc_config = arg; - - af = &dev->ad_funcs; - - af->af_configure_channel = nrf52_adc_configure_channel; - af->af_sample = nrf52_adc_sample; - af->af_read_channel = nrf52_adc_read_channel; - af->af_set_buffer = nrf52_adc_set_buffer; - af->af_release_buffer = nrf52_adc_release_buffer; - af->af_read_buffer = nrf52_adc_read_buffer; - af->af_size_buffer = nrf52_adc_size_buffer; - - NVIC_SetVector(SAADC_IRQn, (uint32_t) SAADC_IRQHandler); - - return (0); -} - - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/mcu/nordic/nrf51xxx/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/nrf51xxx/pkg.yml b/hw/mcu/nordic/nrf51xxx/pkg.yml index 1043c16..d81834f 100644 --- a/hw/mcu/nordic/nrf51xxx/pkg.yml +++ b/hw/mcu/nordic/nrf51xxx/pkg.yml @@ -25,7 +25,7 @@ pkg.keywords: - nrf51 pkg.deps: - - '@mynewt_nordic/hw/mcu/nordic_sdk' + - hw/mcu/nordic - compiler/arm-none-eabi-m0 - hw/cmsis-core - hw/hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/mcu/nordic/nrf52xxx/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/nrf52xxx/pkg.yml b/hw/mcu/nordic/nrf52xxx/pkg.yml index a9d4862..463dfff 100644 --- a/hw/mcu/nordic/nrf52xxx/pkg.yml +++ b/hw/mcu/nordic/nrf52xxx/pkg.yml @@ -25,7 +25,7 @@ pkg.keywords: - nrf52 pkg.deps: - - '@mynewt_nordic/hw/mcu/nordic_sdk' + - hw/mcu/nordic - compiler/arm-none-eabi-m4 - hw/cmsis-core - hw/hal http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/267d86b3/hw/mcu/nordic/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/pkg.yml b/hw/mcu/nordic/pkg.yml index 54e3173..463aa68 100644 --- a/hw/mcu/nordic/pkg.yml +++ b/hw/mcu/nordic/pkg.yml @@ -26,31 +26,11 @@ pkg.keywords: pkg.type: sdk -pkg.ign_files.BSP_NRF52: - - "nrf_drv_adc.c" - - "pstorage*" - - "sdk_mapped_flags.c" - -pkg.ign_files.BSP_NRF51: - - "nrf_saadc.c" - - "nrf_drv_saadc.c" - - "nrf_drv_comp.c" - - "nrf_drv_i2s.c" - - "nrf_drv_pdm.c" - - "nrf_drv_pwm.c" - - "nrf_drv_spis.c" - - "nrf_drv_twis.c" - - "spi_5W_master.c" - - "pstorage*" - - "sdk_mapped_flags.c" - pkg.ign_dirs: - "deprecated" pkg.src_dirs: - - "src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/" - - "src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/fifo/" - - "src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/" + - "src/ext/nRF5_SDK_11.0.0_89a8197/components/device/" pkg.cflags: -std=gnu99 -DNRF52_PAN_28
