Skip to content

Commit

Permalink
Merge pull request apache#951 from rymanluk/adc_fix
Browse files Browse the repository at this point in the history
hw/nrfxx/adc: Fix handling ADC configuration
  • Loading branch information
sterlinghughes committed Mar 23, 2018
2 parents 316a2ec + 32af2e4 commit ce57073
Show file tree
Hide file tree
Showing 25 changed files with 82 additions and 79 deletions.
9 changes: 4 additions & 5 deletions hw/bsp/ada_feather_nrf52/src/hal_bsp.c
Expand Up @@ -45,7 +45,6 @@
#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>
Expand Down Expand Up @@ -96,10 +95,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
Expand Up @@ -44,7 +44,6 @@
#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>
Expand Down Expand Up @@ -95,10 +94,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
1 change: 0 additions & 1 deletion hw/bsp/bmd200/src/hal_bsp.c
Expand Up @@ -39,7 +39,6 @@

#if MYNEWT_VAL(ADC_0)
#include <adc_nrf51/adc_nrf51.h>
#include <nrfx_adc.h>
#endif

#if MYNEWT_VAL(UART_0)
Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/bmd300eval/src/hal_bsp.c
Expand Up @@ -42,7 +42,6 @@
#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>
Expand Down Expand Up @@ -93,10 +92,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
1 change: 0 additions & 1 deletion hw/bsp/calliope_mini/src/hal_bsp.c
Expand Up @@ -36,7 +36,6 @@

#if MYNEWT_VAL(ADC_0)
#include <adc_nrf51/adc_nrf51.h>
#include <nrfx_adc.h>
#endif

#if MYNEWT_VAL(UART_0)
Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/dwm1001-dev/src/hal_bsp.c
Expand Up @@ -45,7 +45,6 @@
#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>
Expand Down Expand Up @@ -108,10 +107,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi1s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/nina-b1/src/hal_bsp.c
Expand Up @@ -45,7 +45,6 @@
#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>
Expand Down Expand Up @@ -96,10 +95,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
1 change: 0 additions & 1 deletion hw/bsp/nrf51-arduino_101/src/hal_bsp.c
Expand Up @@ -41,7 +41,6 @@

#if MYNEWT_VAL(ADC_0)
#include <adc_nrf51/adc_nrf51.h>
#include <nrfx_adc.h>
#endif

#if MYNEWT_VAL(UART_0)
Expand Down
1 change: 0 additions & 1 deletion hw/bsp/nrf51-blenano/src/hal_bsp.c
Expand Up @@ -34,7 +34,6 @@

#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)
Expand Down
1 change: 0 additions & 1 deletion hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
Expand Up @@ -39,7 +39,6 @@

#if MYNEWT_VAL(ADC_0)
#include <adc_nrf51/adc_nrf51.h>
#include <nrfx_adc.h>
#endif

#if MYNEWT_VAL(UART_0)
Expand Down
1 change: 0 additions & 1 deletion hw/bsp/nrf51dk/src/hal_bsp.c
Expand Up @@ -34,7 +34,6 @@

#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)
Expand Down
9 changes: 9 additions & 0 deletions hw/bsp/nrf52-thingy/src/hal_bsp.c
Expand Up @@ -100,6 +100,15 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
};
#endif

#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),
};
#endif

#if MYNEWT_VAL(PWM_0)
static struct pwm_dev os_bsp_pwm0;
int pwm0_idx;
Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/nrf52840pdk/src/hal_bsp.c
Expand Up @@ -45,7 +45,6 @@
#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) || \
Expand Down Expand Up @@ -99,10 +98,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
8 changes: 4 additions & 4 deletions hw/bsp/nrf52dk/src/hal_bsp.c
Expand Up @@ -96,10 +96,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/puckjs/src/hal_bsp.c
Expand Up @@ -45,7 +45,6 @@
#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>
Expand Down Expand Up @@ -96,10 +95,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/rb-blend2/src/hal_bsp.c
Expand Up @@ -45,7 +45,6 @@
#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>
Expand Down Expand Up @@ -96,10 +95,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/rb-nano2/src/hal_bsp.c
Expand Up @@ -44,7 +44,6 @@
#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>
Expand Down Expand Up @@ -95,10 +94,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/ruuvi_tag_revb2/src/hal_bsp.c
Expand Up @@ -48,7 +48,6 @@
#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>
Expand Down Expand Up @@ -127,10 +126,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/telee02/src/hal_bsp.c
Expand Up @@ -46,7 +46,6 @@
#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>
Expand Down Expand Up @@ -88,10 +87,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0m_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
1 change: 0 additions & 1 deletion hw/bsp/vbluno51/src/hal_bsp.c
Expand Up @@ -39,7 +39,6 @@

#if MYNEWT_VAL(ADC_0)
#include <adc_nrf51/adc_nrf51.h>
#include <nrfx_adc.h>
#endif

#if MYNEWT_VAL(UART_0)
Expand Down
9 changes: 4 additions & 5 deletions hw/bsp/vbluno52/src/hal_bsp.c
Expand Up @@ -45,7 +45,6 @@
#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>
Expand Down Expand Up @@ -96,10 +95,10 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {

#if MYNEWT_VAL(ADC_0)
static struct adc_dev os_bsp_adc0;
static nrfx_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),
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),
};
#endif

Expand Down
2 changes: 2 additions & 0 deletions hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h
Expand Up @@ -24,12 +24,14 @@

#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 */
Expand Down

0 comments on commit ce57073

Please sign in to comment.