You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/04/25 09:38:48 UTC

[GitHub] rymanluk closed pull request #1052: hw/nrf/adc: Fix adc device configuration

rymanluk closed pull request #1052: hw/nrf/adc: Fix adc device configuration
URL: https://github.com/apache/mynewt-core/pull/1052
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/bsp/ada_feather_nrf52/src/hal_bsp.c b/hw/bsp/ada_feather_nrf52/src/hal_bsp.c
index 3f098d326f..eca0a00ca9 100644
--- a/hw/bsp/ada_feather_nrf52/src/hal_bsp.c
+++ b/hw/bsp/ada_feather_nrf52/src/hal_bsp.c
@@ -42,6 +42,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -93,9 +94,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -219,13 +218,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
index 35da374847..639277e8b2 100644
--- a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
+++ b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
@@ -41,6 +41,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -91,10 +92,8 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
-static nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -216,13 +215,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/bmd200/src/hal_bsp.c b/hw/bsp/bmd200/src/hal_bsp.c
index 76890c867b..935ce62450 100644
--- a/hw/bsp/bmd200/src/hal_bsp.c
+++ b/hw/bsp/bmd200/src/hal_bsp.c
@@ -37,6 +37,7 @@
 
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf51/adc_nrf51.h>
+#include <nrfx_adc.h>
 #endif
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/bsp/bmd300eval/src/hal_bsp.c b/hw/bsp/bmd300eval/src/hal_bsp.c
index dcf99fab96..b0515dba85 100644
--- a/hw/bsp/bmd300eval/src/hal_bsp.c
+++ b/hw/bsp/bmd300eval/src/hal_bsp.c
@@ -41,6 +41,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -100,9 +101,7 @@ static const struct nrf52_hal_i2c_cfg hal_i2c_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
diff --git a/hw/bsp/calliope_mini/src/hal_bsp.c b/hw/bsp/calliope_mini/src/hal_bsp.c
index 32adeeee3c..d03746682d 100644
--- a/hw/bsp/calliope_mini/src/hal_bsp.c
+++ b/hw/bsp/calliope_mini/src/hal_bsp.c
@@ -34,6 +34,7 @@
 
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf51/adc_nrf51.h>
+#include <nrfx_adc.h>
 #endif
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/bsp/dwm1001-dev/src/hal_bsp.c b/hw/bsp/dwm1001-dev/src/hal_bsp.c
index f1df02c8bb..2d047620fc 100644
--- a/hw/bsp/dwm1001-dev/src/hal_bsp.c
+++ b/hw/bsp/dwm1001-dev/src/hal_bsp.c
@@ -42,6 +42,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -105,9 +106,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi1s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -231,13 +230,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/nina-b1/src/hal_bsp.c b/hw/bsp/nina-b1/src/hal_bsp.c
index 95ee509870..5ce9a6422b 100644
--- a/hw/bsp/nina-b1/src/hal_bsp.c
+++ b/hw/bsp/nina-b1/src/hal_bsp.c
@@ -42,6 +42,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -93,9 +94,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -219,13 +218,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/nrf51-arduino_101/src/hal_bsp.c b/hw/bsp/nrf51-arduino_101/src/hal_bsp.c
index 50e2dc8461..83be2bb0f9 100644
--- a/hw/bsp/nrf51-arduino_101/src/hal_bsp.c
+++ b/hw/bsp/nrf51-arduino_101/src/hal_bsp.c
@@ -39,6 +39,7 @@
 
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf51/adc_nrf51.h>
+#include <nrfx_adc.h>
 #endif
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/bsp/nrf51-arduino_101/syscfg.yml b/hw/bsp/nrf51-arduino_101/syscfg.yml
index 352f2bb0a6..00a1a86aee 100644
--- a/hw/bsp/nrf51-arduino_101/syscfg.yml
+++ b/hw/bsp/nrf51-arduino_101/syscfg.yml
@@ -40,16 +40,6 @@ syscfg.defs:
         description: 'CTS pin for UART0'
         value: 10
 
-    ADC_0_REFMV_0:
-        description: 'reference mV in AREF0 if used'
-        value: 0
-    ADC_0_REFMV_1:
-        description: 'reference mV in AREF1 if used'
-        value: 0
-    ADC_0_REFMV_VDD:
-        description: 'reference mV in VDD if used'
-        value: 0
-
     SPI_0_MASTER_PIN_SCK:
         description: 'SCK pin for SPI_0_MASTER'
         value:  29
diff --git a/hw/bsp/nrf51-blenano/src/hal_bsp.c b/hw/bsp/nrf51-blenano/src/hal_bsp.c
index 2a4b7d08f9..2deb2edc1a 100644
--- a/hw/bsp/nrf51-blenano/src/hal_bsp.c
+++ b/hw/bsp/nrf51-blenano/src/hal_bsp.c
@@ -32,6 +32,7 @@
 
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf51/adc_nrf51.h>
+#include <nrfx_adc.h>
 #endif
 
 #if MYNEWT_VAL(I2C_0) || MYNEWT_VAL(I2C_1)
diff --git a/hw/bsp/nrf51-blenano/syscfg.yml b/hw/bsp/nrf51-blenano/syscfg.yml
index c562e5d7dc..a87d0acc85 100644
--- a/hw/bsp/nrf51-blenano/syscfg.yml
+++ b/hw/bsp/nrf51-blenano/syscfg.yml
@@ -40,16 +40,6 @@ syscfg.defs:
         description: 'CTS pin for UART0'
         value: 10
 
-    ADC_0_REFMV_0:
-        description: 'reference mV in AREF0 if used'
-        value: 0
-    ADC_0_REFMV_1:
-        description: 'reference mV in AREF1 if used'
-        value: 0
-    ADC_0_REFMV_VDD:
-        description: 'reference mV in VDD if used'
-        value: 0
-
     I2C_0_SDA_PIN:
         description: 'Data pin for I2C0'
         value: 6
diff --git a/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c b/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
index 9ec1d8f88f..b501dd3215 100644
--- a/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
+++ b/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
@@ -37,6 +37,7 @@
 
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf51/adc_nrf51.h>
+#include <nrfx_adc.h>
 #endif
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/bsp/nrf51dk-16kbram/syscfg.yml b/hw/bsp/nrf51dk-16kbram/syscfg.yml
index 22f965e282..13bb4eedec 100644
--- a/hw/bsp/nrf51dk-16kbram/syscfg.yml
+++ b/hw/bsp/nrf51dk-16kbram/syscfg.yml
@@ -40,17 +40,6 @@ syscfg.defs:
         description: 'CTS pin for UART0'
         value: 10
 
-    ADC_0_REFMV_0:
-        description: 'reference mV in AREF0 if used'
-        value: 0
-    ADC_0_REFMV_1:
-        description: 'reference mV in AREF1 if used'
-        value: 0
-    ADC_0_REFMV_VDD:
-        description: 'reference mV in VDD if used'
-        value: 0
-
-
     SPI_0_MASTER_PIN_SCK:
         description: 'SCK pin for SPI_0_MASTER'
         value:  29
diff --git a/hw/bsp/nrf51dk/src/hal_bsp.c b/hw/bsp/nrf51dk/src/hal_bsp.c
index de14b69625..bd4ea2a664 100644
--- a/hw/bsp/nrf51dk/src/hal_bsp.c
+++ b/hw/bsp/nrf51dk/src/hal_bsp.c
@@ -32,6 +32,7 @@
 
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf51/adc_nrf51.h>
+#include <nrfx_adc.h>
 #endif
 
 #if MYNEWT_VAL(UART_0) || MYNEWT_VAL(UART_1)
diff --git a/hw/bsp/nrf51dk/syscfg.yml b/hw/bsp/nrf51dk/syscfg.yml
index c3d5a6386b..f7be1ed476 100644
--- a/hw/bsp/nrf51dk/syscfg.yml
+++ b/hw/bsp/nrf51dk/syscfg.yml
@@ -40,15 +40,6 @@ syscfg.defs:
         description: 'CTS pin for UART0'
         value: 10
 
-    ADC_0_REFMV_0:
-        description: 'reference mV in AREF0 if used'
-        value: 0
-    ADC_0_REFMV_1:
-        description: 'reference mV in AREF1 if used'
-        value: 0
-    ADC_0_REFMV_VDD:
-        description: 'reference mV in VDD if used'
-        value: 0
     SPI_0_MASTER_PIN_SCK:
         description: 'SCK pin for SPI_0_MASTER'
         value:  29
diff --git a/hw/bsp/nrf52-thingy/src/hal_bsp.c b/hw/bsp/nrf52-thingy/src/hal_bsp.c
index fbde6d35e0..2f4e1c1654 100644
--- a/hw/bsp/nrf52-thingy/src/hal_bsp.c
+++ b/hw/bsp/nrf52-thingy/src/hal_bsp.c
@@ -99,9 +99,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -278,13 +276,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/nrf52840pdk/src/hal_bsp.c b/hw/bsp/nrf52840pdk/src/hal_bsp.c
index ae4774a996..e155e85322 100644
--- a/hw/bsp/nrf52840pdk/src/hal_bsp.c
+++ b/hw/bsp/nrf52840pdk/src/hal_bsp.c
@@ -42,6 +42,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || \
     MYNEWT_VAL(PWM_1) || \
@@ -96,9 +97,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -231,13 +230,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/nrf52dk/src/hal_bsp.c b/hw/bsp/nrf52dk/src/hal_bsp.c
index dabedb70a2..0afdbc145b 100644
--- a/hw/bsp/nrf52dk/src/hal_bsp.c
+++ b/hw/bsp/nrf52dk/src/hal_bsp.c
@@ -94,9 +94,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -220,13 +218,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/puckjs/src/hal_bsp.c b/hw/bsp/puckjs/src/hal_bsp.c
index 3f098d326f..eca0a00ca9 100644
--- a/hw/bsp/puckjs/src/hal_bsp.c
+++ b/hw/bsp/puckjs/src/hal_bsp.c
@@ -42,6 +42,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -93,9 +94,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -219,13 +218,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/rb-blend2/src/hal_bsp.c b/hw/bsp/rb-blend2/src/hal_bsp.c
index 642ab05a8e..a8608c565c 100644
--- a/hw/bsp/rb-blend2/src/hal_bsp.c
+++ b/hw/bsp/rb-blend2/src/hal_bsp.c
@@ -42,6 +42,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -93,9 +94,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -219,13 +218,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/rb-nano2/src/hal_bsp.c b/hw/bsp/rb-nano2/src/hal_bsp.c
index 1f4d4295a5..1427d34b64 100644
--- a/hw/bsp/rb-nano2/src/hal_bsp.c
+++ b/hw/bsp/rb-nano2/src/hal_bsp.c
@@ -41,6 +41,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -92,9 +93,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -210,13 +209,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c b/hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c
index 1791502289..ef99da8082 100644
--- a/hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c
+++ b/hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c
@@ -43,6 +43,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -122,12 +123,11 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
+
 #if MYNEWT_VAL(PWM_0)
 static struct pwm_dev os_bsp_pwm0;
 int pwm0_idx;
@@ -337,13 +337,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/telee02/src/hal_bsp.c b/hw/bsp/telee02/src/hal_bsp.c
index 3b09016e62..87bc79ba9f 100644
--- a/hw/bsp/telee02/src/hal_bsp.c
+++ b/hw/bsp/telee02/src/hal_bsp.c
@@ -43,6 +43,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -85,9 +86,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0m_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -204,13 +203,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
diff --git a/hw/bsp/vbluno51/src/hal_bsp.c b/hw/bsp/vbluno51/src/hal_bsp.c
index d5c5ff4a78..e54e6a7295 100644
--- a/hw/bsp/vbluno51/src/hal_bsp.c
+++ b/hw/bsp/vbluno51/src/hal_bsp.c
@@ -37,6 +37,7 @@
 
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf51/adc_nrf51.h>
+#include <nrfx_adc.h>
 #endif
 
 #if MYNEWT_VAL(UART_0)
diff --git a/hw/bsp/vbluno52/src/hal_bsp.c b/hw/bsp/vbluno52/src/hal_bsp.c
index 693e01f3ad..3c7554e66a 100644
--- a/hw/bsp/vbluno52/src/hal_bsp.c
+++ b/hw/bsp/vbluno52/src/hal_bsp.c
@@ -42,6 +42,7 @@
 #include "bsp.h"
 #if MYNEWT_VAL(ADC_0)
 #include <adc_nrf52/adc_nrf52.h>
+#include <nrfx_saadc.h>
 #endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include <pwm_nrf52/pwm_nrf52.h>
@@ -93,9 +94,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
 static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
-    .saadc_cfg.resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .saadc_cfg.oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .saadc_cfg.interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+    .nadc_refmv     = MYNEWT_VAL(ADC_0_REFMV_0),
 };
 #endif
 
@@ -227,13 +226,13 @@ hal_bsp_init(void)
 #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);
+    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
 
 #if MYNEWT_VAL(PWM_0)
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
index 34285a44d8..6432df22aa 100644
--- a/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h
+++ b/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h
@@ -24,14 +24,12 @@
 
 #include <nrfx.h>
 #include <nrf_adc.h>
-#include <nrfx_adc.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 struct nrf51_adc_dev_cfg {
-    nrfx_adc_config_t adc_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 */
diff --git a/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c b/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
index e0610f7433..2a447ccb09 100644
--- a/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
+++ b/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
@@ -45,7 +45,7 @@ static struct nrf51_adc_stats nrf51_adc_stats;
 
 static struct adc_dev *global_adc_dev;
 
-static struct nrf51_adc_dev_cfg *global_adc_config;
+static nrfx_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];
@@ -99,7 +99,7 @@ static int
 nrf51_adc_open(struct os_dev *odev, uint32_t wait, void *arg)
 {
     struct adc_dev *dev;
-    struct nrf51_adc_dev_cfg *cfg = arg;
+    nrfx_adc_config_t *cfg;
     int rc;
 
     if (arg == NULL) {
@@ -116,13 +116,9 @@ nrf51_adc_open(struct os_dev *odev, uint32_t wait, void *arg)
         }
     }
 
-    if (!cfg) {
-        /* Use initial configuration */
-        cfg = init_adc_config;
-    }
- 
     /* Initialize the device */
-    rc = nrfx_adc_init(&cfg->adc_cfg, nrf51_adc_event_handler);
+    cfg = (nrfx_adc_config_t *)arg;
+    rc = nrfx_adc_init(cfg, nrf51_adc_event_handler);
     if (rc != NRFX_SUCCESS) {
         goto err;
     }
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
index 746ec369db..edd0938425 100644
--- a/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
+++ b/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
@@ -21,14 +21,12 @@
 #define __ADC_NRF52_H__
 
 #include <adc/adc.h>
-#include <nrfx_saadc.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 struct nrf52_adc_dev_cfg {
-    nrfx_saadc_config_t saadc_cfg;
     uint16_t nadc_refmv;		/* reference VDD in mV */
 };
 
diff --git a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
index 045cffb72f..2c3f9b31d8 100644
--- a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
+++ b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
@@ -37,7 +37,7 @@ struct nrf52_saadc_stats {
 static struct nrf52_saadc_stats nrf52_saadc_stats;
 
 static struct adc_dev *global_adc_dev;
-static struct nrf52_adc_dev_cfg *global_adc_config;
+static nrfx_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)];
@@ -91,7 +91,6 @@ static int
 nrf52_adc_open(struct os_dev *odev, uint32_t wait, void *arg)
 {
     struct adc_dev *dev;
-    struct nrf52_adc_dev_cfg *cfg = arg;
     int rc;
 
     dev = (struct adc_dev *) odev;
@@ -109,13 +108,9 @@ nrf52_adc_open(struct os_dev *odev, uint32_t wait, void *arg)
         goto err;
     }
 
-    /* If user did not provide config let us use init */
-    if (!cfg) {
-        cfg = init_adc_config;
-    }
-
     /* Initialize the device */
-    rc = nrfx_saadc_init(&cfg->saadc_cfg, nrf52_saadc_event_handler);
+    rc = nrfx_saadc_init((nrfx_saadc_config_t *) arg,
+            nrf52_saadc_event_handler);
     if (rc != NRFX_SUCCESS) {
         goto err;
     }
@@ -185,7 +180,7 @@ nrf52_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
         /* Set the resolution and reference voltage for this channel to
         * enable conversion functions.
         */
-        switch (global_adc_config->saadc_cfg.resolution) {
+        switch (global_adc_config->resolution) {
             case NRF_SAADC_RESOLUTION_8BIT:
                 res = 8;
                 break;
diff --git a/hw/mcu/nordic/nrf51xxx/syscfg.yml b/hw/mcu/nordic/nrf51xxx/syscfg.yml
index 91197fde67..42e608f27b 100644
--- a/hw/mcu/nordic/nrf51xxx/syscfg.yml
+++ b/hw/mcu/nordic/nrf51xxx/syscfg.yml
@@ -75,6 +75,16 @@ syscfg.defs:
         description: 'ADC'
         value:  0
 
+    ADC_0_REFMV_0:
+        description: 'reference mV in AREF0 if used'
+        value: 0
+    ADC_0_REFMV_1:
+        description: 'reference mV in AREF1 if used'
+        value: 0
+    ADC_0_REFMV_VDD:
+        description: 'reference mV in VDD if used'
+        value: 0
+
 # The XTAL_xxx definitions are used to set the clock source used for the low
 # frequency clock. It is required that at least one of these sources is
 # enabled (the bsp should set one of these clock sources).
diff --git a/hw/mcu/nordic/nrf52xxx/syscfg.yml b/hw/mcu/nordic/nrf52xxx/syscfg.yml
index 612503c01d..ecabe56633 100644
--- a/hw/mcu/nordic/nrf52xxx/syscfg.yml
+++ b/hw/mcu/nordic/nrf52xxx/syscfg.yml
@@ -86,17 +86,9 @@ syscfg.defs:
         description: 'NRF52 ADC 0'
         value:  0
 
-    ADC_0_RESOLUTION:
-        description: 'NRF52 ADC 0 RESOLUTION'
-        value: 'NRFX_SAADC_CONFIG_RESOLUTION'
-
-    ADC_0_OVERSAMPLE:
-        description: 'NRF52 ADC 0 OVERSAMPLE'
-        value: 'NRFX_SAADC_CONFIG_OVERSAMPLE'
-
-    ADC_0_INTERRUPT_PRIORITY:
-        description: 'NRF52 ADC IRQ PRIORITY'
-        value: 'NRFX_SAADC_CONFIG_IRQ_PRIORITY'
+    ADC_0_REFMV_0:
+        description: 'reference mV in AREF0 if used'
+        value: 0
 
     PWM_0:
         description: 'NRF52 PWM 0'


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services