|
| 1 | +/* |
| 2 | + * Copyright (c) 2021, Commonwealth Scientific and Industrial Research |
| 3 | + * Organisation (CSIRO) ABN 41 687 119 230. |
| 4 | + * |
| 5 | + * SPDX-License-Identifier: Apache-2.0 |
| 6 | + */ |
| 7 | + |
| 8 | +/* |
| 9 | + * This is not a real ADC driver. It is used to instantiate struct |
| 10 | + * devices for the "vnd,adc" devicetree compatible used in test code. |
| 11 | + */ |
| 12 | + |
| 13 | +#define DT_DRV_COMPAT vnd_adc |
| 14 | + |
| 15 | +#include <drivers/adc.h> |
| 16 | +#include <device.h> |
| 17 | +#include <kernel.h> |
| 18 | + |
| 19 | +static int vnd_adc_channel_setup(const struct device *dev, |
| 20 | + const struct adc_channel_cfg *channel_cfg) |
| 21 | +{ |
| 22 | + return -ENOTSUP; |
| 23 | +} |
| 24 | + |
| 25 | +static int vnd_adc_read(const struct device *dev, |
| 26 | + const struct adc_sequence *sequence) |
| 27 | +{ |
| 28 | + return -ENOTSUP; |
| 29 | +} |
| 30 | + |
| 31 | +#ifdef CONFIG_ADC_ASYNC |
| 32 | +static int vnd_adc_read_async(const struct device *dev, |
| 33 | + const struct adc_sequence *sequence, |
| 34 | + struct k_poll_signal *async) |
| 35 | +{ |
| 36 | + return -ENOTSUP; |
| 37 | +} |
| 38 | +#endif |
| 39 | + |
| 40 | +static const struct adc_driver_api vnd_adc_api = { |
| 41 | + .channel_setup = vnd_adc_channel_setup, |
| 42 | + .read = vnd_adc_read, |
| 43 | +#ifdef CONFIG_ADC_ASYNC |
| 44 | + .read_async = vnd_adc_read_async, |
| 45 | +#endif |
| 46 | +}; |
| 47 | + |
| 48 | +static int vnd_adc_init(const struct device *dev) |
| 49 | +{ |
| 50 | + return 0; |
| 51 | +} |
| 52 | + |
| 53 | +#define VND_ADC_INIT(n) \ |
| 54 | + DEVICE_DT_INST_DEFINE(n, &vnd_adc_init, NULL, \ |
| 55 | + NULL, NULL, POST_KERNEL, \ |
| 56 | + CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ |
| 57 | + &vnd_adc_api); |
| 58 | + |
| 59 | +DT_INST_FOREACH_STATUS_OKAY(VND_ADC_INIT) |
0 commit comments