dts: Include ADC DT binding headers from nRF SoC dtsi files
Add inclusions of header files with devicetree related ADC definitions to the nRF SoC dtsi files so that those definitions can be used also for nRF SoC based boards. Provide definitions of nRF ADC and SAADC analog inputs suitable for use in devicetree. Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
parent
8ca23ff2b5
commit
77edc2c852
|
@ -7,6 +7,7 @@
|
|||
#define ADC_CONTEXT_USES_KERNEL_TIMER
|
||||
#include "adc_context.h"
|
||||
#include <nrfx_adc.h>
|
||||
#include <zephyr/dt-bindings/adc/nrf-adc.h>
|
||||
|
||||
#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL
|
||||
#include <zephyr/logging/log.h>
|
||||
|
@ -14,6 +15,17 @@ LOG_MODULE_REGISTER(adc_nrfx_adc);
|
|||
|
||||
#define DT_DRV_COMPAT nordic_nrf_adc
|
||||
|
||||
/* Ensure that definitions in nrf-adc.h match MDK. */
|
||||
BUILD_ASSERT((NRF_ADC_AIN0 == NRF_ADC_CONFIG_INPUT_0) &&
|
||||
(NRF_ADC_AIN1 == NRF_ADC_CONFIG_INPUT_1) &&
|
||||
(NRF_ADC_AIN2 == NRF_ADC_CONFIG_INPUT_2) &&
|
||||
(NRF_ADC_AIN3 == NRF_ADC_CONFIG_INPUT_3) &&
|
||||
(NRF_ADC_AIN4 == NRF_ADC_CONFIG_INPUT_4) &&
|
||||
(NRF_ADC_AIN5 == NRF_ADC_CONFIG_INPUT_5) &&
|
||||
(NRF_ADC_AIN6 == NRF_ADC_CONFIG_INPUT_6) &&
|
||||
(NRF_ADC_AIN7 == NRF_ADC_CONFIG_INPUT_7),
|
||||
"Definitions from nrf-adc.h do not match those from nrf_adc.h");
|
||||
|
||||
struct driver_data {
|
||||
struct adc_context ctx;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define ADC_CONTEXT_USES_KERNEL_TIMER
|
||||
#include "adc_context.h"
|
||||
#include <hal/nrf_saadc.h>
|
||||
#include <zephyr/dt-bindings/adc/nrf-adc.h>
|
||||
|
||||
#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL
|
||||
#include <zephyr/logging/log.h>
|
||||
|
@ -14,6 +15,21 @@ LOG_MODULE_REGISTER(adc_nrfx_saadc);
|
|||
|
||||
#define DT_DRV_COMPAT nordic_nrf_saadc
|
||||
|
||||
BUILD_ASSERT((NRF_SAADC_AIN0 == NRF_SAADC_INPUT_AIN0) &&
|
||||
(NRF_SAADC_AIN1 == NRF_SAADC_INPUT_AIN1) &&
|
||||
(NRF_SAADC_AIN2 == NRF_SAADC_INPUT_AIN2) &&
|
||||
(NRF_SAADC_AIN3 == NRF_SAADC_INPUT_AIN3) &&
|
||||
(NRF_SAADC_AIN4 == NRF_SAADC_INPUT_AIN4) &&
|
||||
(NRF_SAADC_AIN5 == NRF_SAADC_INPUT_AIN5) &&
|
||||
(NRF_SAADC_AIN6 == NRF_SAADC_INPUT_AIN6) &&
|
||||
(NRF_SAADC_AIN7 == NRF_SAADC_INPUT_AIN7) &&
|
||||
(NRF_SAADC_AIN7 == NRF_SAADC_INPUT_AIN7) &&
|
||||
#if defined(SAADC_CH_PSELP_PSELP_VDDHDIV5)
|
||||
(NRF_SAADC_VDDHDIV5 == NRF_SAADC_INPUT_VDDHDIV5) &&
|
||||
#endif
|
||||
(NRF_SAADC_VDD == NRF_SAADC_INPUT_VDD),
|
||||
"Definitions from nrf-adc.h do not match those from nrf_saadc.h");
|
||||
|
||||
struct driver_data {
|
||||
struct adc_context ctx;
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/i2c/i2c.h>
|
||||
#include <zephyr/dt-bindings/adc/adc.h>
|
||||
#include <zephyr/dt-bindings/adc/nrf-adc.h>
|
||||
#include <zephyr/dt-bindings/gpio/gpio.h>
|
||||
#include <zephyr/dt-bindings/i2c/i2c.h>
|
||||
#include <zephyr/dt-bindings/pinctrl/nrf-pinctrl.h>
|
||||
#include <zephyr/dt-bindings/pwm/pwm.h>
|
||||
|
||||
|
|
32
include/zephyr/dt-bindings/adc/nrf-adc.h
Normal file
32
include/zephyr/dt-bindings/adc/nrf-adc.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_ADC_NRF_ADC_H_
|
||||
#define ZEPHYR_INCLUDE_DT_BINDINGS_ADC_NRF_ADC_H_
|
||||
|
||||
#include <zephyr/dt-bindings/dt-util.h>
|
||||
|
||||
#define NRF_ADC_AIN0 BIT(0)
|
||||
#define NRF_ADC_AIN1 BIT(1)
|
||||
#define NRF_ADC_AIN2 BIT(2)
|
||||
#define NRF_ADC_AIN3 BIT(3)
|
||||
#define NRF_ADC_AIN4 BIT(4)
|
||||
#define NRF_ADC_AIN5 BIT(5)
|
||||
#define NRF_ADC_AIN6 BIT(6)
|
||||
#define NRF_ADC_AIN7 BIT(7)
|
||||
|
||||
#define NRF_SAADC_AIN0 1
|
||||
#define NRF_SAADC_AIN1 2
|
||||
#define NRF_SAADC_AIN2 3
|
||||
#define NRF_SAADC_AIN3 4
|
||||
#define NRF_SAADC_AIN4 5
|
||||
#define NRF_SAADC_AIN5 6
|
||||
#define NRF_SAADC_AIN6 7
|
||||
#define NRF_SAADC_AIN7 8
|
||||
#define NRF_SAADC_VDD 9
|
||||
#define NRF_SAADC_VDDHDIV5 13
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_ADC_NRF_ADC_H_ */
|
Loading…
Reference in a new issue