summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/adc.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/src/adc.c')
-rw-r--r--zephyr/shim/src/adc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/zephyr/shim/src/adc.c b/zephyr/shim/src/adc.c
index c6fbed23c5..93a99c3973 100644
--- a/zephyr/shim/src/adc.c
+++ b/zephyr/shim/src/adc.c
@@ -4,10 +4,13 @@
*/
#include <drivers/adc.h>
+#include <logging/log.h>
#include "adc.h"
#include "zephyr_adc.h"
-#define ADC_DEV DT_LABEL(DT_NODELABEL(adc0))
+LOG_MODULE_REGISTER(shim_adc, LOG_LEVEL_ERR);
+
+#define ADC_NODE DT_NODELABEL(adc0)
const struct device *adc_dev;
#define HAS_NAMED_ADC_CHANNELS DT_NODE_EXISTS(DT_INST(0, named_adc_channels))
@@ -35,7 +38,12 @@ const struct adc_t adc_channels[] = { DT_FOREACH_CHILD(
static int init_device_bindings(const struct device *device)
{
ARG_UNUSED(device);
- adc_dev = device_get_binding(ADC_DEV);
+ adc_dev = DEVICE_DT_GET(ADC_NODE);
+
+ if (!device_is_ready(adc_dev)) {
+ LOG_ERR("Error: device %s is not ready", adc_dev->name);
+ return -1;
+ }
#if HAS_NAMED_ADC_CHANNELS
for (int i = 0; i < ARRAY_SIZE(adc_channels); i++)