2017-10-26 02:27:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Intel Corporation
|
2020-06-07 03:38:38 +08:00
|
|
|
* Copyright (c) 2020-2021 Vestas Wind Systems A/S
|
2017-10-26 02:27:37 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2023-09-27 06:46:01 +08:00
|
|
|
#include <zephyr/internal/syscall_handler.h>
|
2022-05-06 16:25:46 +08:00
|
|
|
#include <zephyr/drivers/pwm.h>
|
2017-10-26 02:27:37 +08:00
|
|
|
|
2022-04-01 16:24:14 +08:00
|
|
|
static inline int z_vrfy_pwm_set_cycles(const struct device *dev,
|
|
|
|
uint32_t channel, uint32_t period,
|
|
|
|
uint32_t pulse, pwm_flags_t flags)
|
2017-10-26 02:27:37 +08:00
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PWM(dev, set_cycles));
|
2022-04-01 16:24:14 +08:00
|
|
|
return z_impl_pwm_set_cycles((const struct device *)dev, channel,
|
2022-04-04 22:35:22 +08:00
|
|
|
period, pulse, flags);
|
2017-10-26 02:27:37 +08:00
|
|
|
}
|
2022-04-01 16:24:14 +08:00
|
|
|
#include <syscalls/pwm_set_cycles_mrsh.c>
|
2017-10-26 02:27:37 +08:00
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
static inline int z_vrfy_pwm_get_cycles_per_sec(const struct device *dev,
|
2022-04-04 22:35:22 +08:00
|
|
|
uint32_t channel,
|
2020-05-01 02:33:38 +08:00
|
|
|
uint64_t *cycles)
|
2017-10-26 02:27:37 +08:00
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PWM(dev, get_cycles_per_sec));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(cycles, sizeof(uint64_t)));
|
2020-05-01 02:33:38 +08:00
|
|
|
return z_impl_pwm_get_cycles_per_sec((const struct device *)dev,
|
2022-04-04 22:35:22 +08:00
|
|
|
channel, (uint64_t *)cycles);
|
2017-10-26 02:27:37 +08:00
|
|
|
}
|
2019-08-14 02:34:34 +08:00
|
|
|
#include <syscalls/pwm_get_cycles_per_sec_mrsh.c>
|
2020-06-07 03:38:38 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_PWM_CAPTURE
|
|
|
|
|
2022-04-01 16:24:14 +08:00
|
|
|
static inline int z_vrfy_pwm_enable_capture(const struct device *dev,
|
|
|
|
uint32_t channel)
|
2020-06-07 03:38:38 +08:00
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PWM(dev, enable_capture));
|
2022-04-01 16:24:14 +08:00
|
|
|
return z_impl_pwm_enable_capture((const struct device *)dev, channel);
|
2020-06-07 03:38:38 +08:00
|
|
|
}
|
2022-04-01 16:24:14 +08:00
|
|
|
#include <syscalls/pwm_enable_capture_mrsh.c>
|
2020-06-07 03:38:38 +08:00
|
|
|
|
2022-04-01 16:24:14 +08:00
|
|
|
static inline int z_vrfy_pwm_disable_capture(const struct device *dev,
|
|
|
|
uint32_t channel)
|
2020-06-07 03:38:38 +08:00
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PWM(dev, disable_capture));
|
2022-04-01 16:24:14 +08:00
|
|
|
return z_impl_pwm_disable_capture((const struct device *)dev, channel);
|
2020-06-07 03:38:38 +08:00
|
|
|
}
|
2022-04-01 16:24:14 +08:00
|
|
|
#include <syscalls/pwm_disable_capture_mrsh.c>
|
2020-06-07 03:38:38 +08:00
|
|
|
|
2022-04-01 16:24:14 +08:00
|
|
|
static inline int z_vrfy_pwm_capture_cycles(const struct device *dev,
|
|
|
|
uint32_t channel, pwm_flags_t flags,
|
|
|
|
uint32_t *period_cycles,
|
|
|
|
uint32_t *pulse_cycles,
|
|
|
|
k_timeout_t timeout)
|
2020-06-07 03:38:38 +08:00
|
|
|
{
|
|
|
|
uint32_t period;
|
|
|
|
uint32_t pulse;
|
|
|
|
int err;
|
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PWM(dev, configure_capture));
|
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PWM(dev, enable_capture));
|
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PWM(dev, disable_capture));
|
2020-06-07 03:38:38 +08:00
|
|
|
|
2022-04-01 16:24:14 +08:00
|
|
|
err = z_impl_pwm_capture_cycles((const struct device *)dev, channel,
|
|
|
|
flags, &period, &pulse, timeout);
|
2020-06-07 03:38:38 +08:00
|
|
|
if (period_cycles != NULL) {
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(k_usermode_to_copy(period_cycles, &period,
|
2020-06-07 03:38:38 +08:00
|
|
|
sizeof(*period_cycles)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pulse_cycles != NULL) {
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(k_usermode_to_copy(pulse_cycles, &pulse,
|
2020-06-07 03:38:38 +08:00
|
|
|
sizeof(*pulse_cycles)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
2022-04-01 16:24:14 +08:00
|
|
|
#include <syscalls/pwm_capture_cycles_mrsh.c>
|
2020-06-07 03:38:38 +08:00
|
|
|
|
|
|
|
#endif /* CONFIG_PWM_CAPTURE */
|