Lines Matching +full:pulse +full:- +full:width
3 * Copyright (c) 2020-2021 Vestas Wind Systems A/S
5 * SPDX-License-Identifier: Apache-2.0
34 #include <zephyr/dt-bindings/pwm/pwm.h>
57 /** PWM pin capture captures pulse width. */
60 /** PWM pin capture captures both period and pulse width. */
64 /** PWM pin capture captures a single period/pulse width. */
67 /** PWM pin capture captures period/pulse width continuously. */
121 * pwm-names = "alpha", "beta";
146 * @param name Lowercase-and-underscores name of a pwms element as defined by
147 * the node's pwm-names property.
166 * @param name Lowercase-and-underscores name of a pwms element as defined by
167 * the node's pwm-names property.
185 * @param name Lowercase-and-underscores name of a pwms element as defined by
186 * the node's pwm-names property
204 * @param name Lowercase-and-underscores name of a pwms element as defined by
205 * the node's pwm-names property.
383 * @param period_cycles Captured PWM period width (in clock cycles). HW
385 * @param pulse_cycles Captured PWM pulse width (in clock cycles). HW specific.
399 * @brief PWM driver API call to configure PWM pin period and pulse width.
450 * @brief Set the period and pulse width for a single PWM output.
452 * The PWM period and pulse width will synchronously be set to the new values
456 * @note Not all PWM controllers support synchronous, glitch-free updates of the
457 * PWM period and pulse width. Depending on the hardware, changing the PWM
458 * period and/or pulse width may cause a glitch in the generated PWM signal.
460 * @note Some multi-channel PWM controllers share the PWM period across all
464 * Passing 0 as @p pulse will cause the pin to be driven to a constant
466 * Passing a non-zero @p pulse equal to @p period will cause the pin
472 * @param pulse Pulse width (in clock cycles) set to the PWM. HW specific.
476 * @retval -EINVAL If pulse > period.
477 * @retval -errno Negative errno code on failure.
480 uint32_t period, uint32_t pulse,
485 uint32_t pulse, pwm_flags_t flags) in z_impl_pwm_set_cycles() argument
488 (const struct pwm_driver_api *)dev->api; in z_impl_pwm_set_cycles()
490 if (pulse > period) { in z_impl_pwm_set_cycles()
491 return -EINVAL; in z_impl_pwm_set_cycles()
494 return api->set_cycles(dev, channel, period, pulse, flags); in z_impl_pwm_set_cycles()
506 * @retval -errno Negative errno code on failure.
516 (const struct pwm_driver_api *)dev->api; in z_impl_pwm_get_cycles_per_sec()
518 return api->get_cycles_per_sec(dev, channel, cycles); in z_impl_pwm_get_cycles_per_sec()
522 * @brief Set the period and pulse width in nanoseconds for a single PWM output.
530 * @param pulse Pulse width (in nanoseconds) set to the PWM.
534 * @retval -ENOTSUP If requested period or pulse cycles are not supported.
535 * @retval -errno Other negative errno code on failure.
538 uint32_t period, uint32_t pulse, pwm_flags_t flags) in pwm_set() argument
552 return -ENOTSUP; in pwm_set()
555 pulse_cycles = (pulse * cycles_per_sec) / NSEC_PER_SEC; in pwm_set()
557 return -ENOTSUP; in pwm_set()
565 * @brief Set the period and pulse width in nanoseconds from a struct
570 * pwm_set(spec->dev, spec->channel, period, pulse, spec->flags)
577 * @param pulse Pulse width (in nanoseconds) set to the PWM.
584 uint32_t pulse) in pwm_set_dt() argument
586 return pwm_set(spec->dev, spec->channel, period, pulse, spec->flags); in pwm_set_dt()
590 * @brief Set the period and pulse width in nanoseconds from a struct
595 * pwm_set(spec->dev, spec->channel, spec->period, pulse, spec->flags)
598 * @param pulse Pulse width (in nanoseconds) set to the PWM.
605 uint32_t pulse) in pwm_set_pulse_dt() argument
607 return pwm_set(spec->dev, spec->channel, spec->period, pulse, in pwm_set_pulse_dt()
608 spec->flags); in pwm_set_pulse_dt()
620 * @retval -ERANGE If result is too large.
621 * @retval -errno Other negative errno code on failure.
636 return -ERANGE; in pwm_cycles_to_usec()
653 * @retval -ERANGE If result is too large.
654 * @retval -errno Other negative errno code on failure.
669 return -ERANGE; in pwm_cycles_to_nsec()
679 * @brief Configure PWM period/pulse width capture for a single PWM input.
700 * @retval -EINVAL if invalid function parameters were given
701 * @retval -ENOSYS if PWM capture is not supported or the given flags are not
703 * @retval -EIO if IO error occurred while configuring
704 * @retval -EBUSY if PWM capture is already in progress
712 (const struct pwm_driver_api *)dev->api; in pwm_configure_capture()
714 if (api->configure_capture == NULL) { in pwm_configure_capture()
715 return -ENOSYS; in pwm_configure_capture()
718 return api->configure_capture(dev, channel, flags, cb, in pwm_configure_capture()
724 * @brief Enable PWM period/pulse width capture for a single PWM input.
736 * @retval -EINVAL if invalid function parameters were given
737 * @retval -ENOSYS if PWM capture is not supported
738 * @retval -EIO if IO error occurred while enabling PWM capture
739 * @retval -EBUSY if PWM capture is already in progress
748 (const struct pwm_driver_api *)dev->api; in z_impl_pwm_enable_capture()
750 if (api->enable_capture == NULL) { in z_impl_pwm_enable_capture()
751 return -ENOSYS; in z_impl_pwm_enable_capture()
754 return api->enable_capture(dev, channel); in z_impl_pwm_enable_capture()
759 * @brief Disable PWM period/pulse width capture for a single PWM input.
768 * @retval -EINVAL if invalid function parameters were given
769 * @retval -ENOSYS if PWM capture is not supported
770 * @retval -EIO if IO error occurred while disabling PWM capture
779 (const struct pwm_driver_api *)dev->api; in z_impl_pwm_disable_capture()
781 if (api->disable_capture == NULL) { in z_impl_pwm_disable_capture()
782 return -ENOSYS; in z_impl_pwm_disable_capture()
785 return api->disable_capture(dev, channel); in z_impl_pwm_disable_capture()
790 * @brief Capture a single PWM period/pulse width in clock cycles for a single
805 * width (in clock cycles). HW specific.
806 * @param[out] pulse Pointer to the memory to store the captured PWM pulse width
811 * @retval -EBUSY PWM capture already in progress.
812 * @retval -EAGAIN Waiting period timed out.
813 * @retval -EIO IO error while capturing.
814 * @retval -ERANGE If result is too large.
818 uint32_t *pulse, k_timeout_t timeout);
821 * @brief Capture a single PWM period/pulse width in microseconds for a single
836 * width (in usec).
837 * @param[out] pulse Pointer to the memory to store the captured PWM pulse width
842 * @retval -EBUSY PWM capture already in progress.
843 * @retval -EAGAIN Waiting period timed out.
844 * @retval -EIO IO error while capturing.
845 * @retval -ERANGE If result is too large.
846 * @retval -errno Other negative errno code on failure.
850 uint64_t *pulse, k_timeout_t timeout) in pwm_capture_usec() argument
867 err = pwm_cycles_to_usec(dev, channel, pulse_cycles, pulse); in pwm_capture_usec()
876 * @brief Capture a single PWM period/pulse width in nanoseconds for a single
891 * width (in nsec).
892 * @param[out] pulse Pointer to the memory to store the captured PWM pulse width
897 * @retval -EBUSY PWM capture already in progress.
898 * @retval -EAGAIN Waiting period timed out.
899 * @retval -EIO IO error while capturing.
900 * @retval -ERANGE If result is too large.
901 * @retval -errno Other negative errno code on failure.
905 uint64_t *pulse, k_timeout_t timeout) in pwm_capture_nsec() argument
922 err = pwm_cycles_to_nsec(dev, channel, pulse_cycles, pulse); in pwm_capture_nsec()
940 return device_is_ready(spec->dev); in pwm_is_ready_dt()