c064006ecc
Add a dummy driver for the `vnd,pwm` compatible to allow compilation of drivers utilising PWM when running "build_all" tests. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
77 lines
1.8 KiB
C
77 lines
1.8 KiB
C
/*
|
|
* Copyright (c) 2022, Commonwealth Scientific and Industrial Research
|
|
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/*
|
|
* This is not a real PWM driver. It is used to instantiate struct
|
|
* devices for the "vnd,pwm" devicetree compatible used in test code.
|
|
*/
|
|
|
|
#include <zephyr.h>
|
|
#include <drivers/pwm.h>
|
|
|
|
#define DT_DRV_COMPAT vnd_pwm
|
|
|
|
static int vnd_pwm_pin_set(const struct device *dev, uint32_t pwm,
|
|
uint32_t period_cycles, uint32_t pulse_cycles,
|
|
pwm_flags_t flags)
|
|
{
|
|
return -ENOTSUP;
|
|
}
|
|
|
|
#ifdef CONFIG_PWM_CAPTURE
|
|
static int vnd_pwm_pin_configure_capture(const struct device *dev,
|
|
uint32_t pwm,
|
|
pwm_flags_t flags,
|
|
pwm_capture_callback_handler_t cb,
|
|
void *user_data)
|
|
{
|
|
return -ENOTSUP;
|
|
}
|
|
|
|
static int vnd_pwm_pin_enable_capture(const struct device *dev,
|
|
uint32_t pwm)
|
|
{
|
|
return -ENOTSUP;
|
|
}
|
|
|
|
static int vnd_pwm_pin_disable_capture(const struct device *dev,
|
|
uint32_t pwm)
|
|
{
|
|
return -ENOTSUP;
|
|
}
|
|
#endif /* CONFIG_PWM_CAPTURE */
|
|
|
|
static int vnd_pwm_get_cycles_per_sec(const struct device *dev,
|
|
uint32_t pwm,
|
|
uint64_t *cycles)
|
|
{
|
|
return -ENOTSUP;
|
|
}
|
|
|
|
static const struct pwm_driver_api vnd_pwm_api = {
|
|
.pin_set = vnd_pwm_pin_set,
|
|
#ifdef CONFIG_PWM_CAPTURE
|
|
.pin_configure_capture = vnd_pwm_pin_configure_capture,
|
|
.pin_enable_capture = vnd_pwm_pin_enable_capture,
|
|
.pin_disable_capture = vnd_pwm_pin_disable_capture,
|
|
#endif /* CONFIG_PWM_CAPTURE */
|
|
.get_cycles_per_sec = vnd_pwm_get_cycles_per_sec,
|
|
};
|
|
|
|
static int vnd_pwm_init(const struct device *dev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#define VND_PWM_INIT(n) \
|
|
DEVICE_DT_INST_DEFINE(n, &vnd_pwm_init, NULL, \
|
|
NULL, NULL, POST_KERNEL, \
|
|
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
|
&vnd_pwm_api);
|
|
|
|
DT_INST_FOREACH_STATUS_OKAY(VND_PWM_INIT)
|