1 /* 2 * Copyright (c) 2020-2021 Vestas Wind Systems A/S 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __TEST_PWM_LOOPBACK_H__ 8 #define __TEST_PWM_LOOPBACK_H__ 9 10 #include <zephyr/kernel.h> 11 #include <zephyr/drivers/pwm.h> 12 #include <zephyr/ztest.h> 13 14 #define PWM_LOOPBACK_OUT_IDX 0 15 #define PWM_LOOPBACK_IN_IDX 1 16 17 #define PWM_LOOPBACK_NODE DT_INST(0, test_pwm_loopback) 18 19 #define PWM_LOOPBACK_OUT_CTLR \ 20 DT_PWMS_CTLR_BY_IDX(PWM_LOOPBACK_NODE, PWM_LOOPBACK_OUT_IDX) 21 #define PWM_LOOPBACK_OUT_CHANNEL \ 22 DT_PWMS_CHANNEL_BY_IDX(PWM_LOOPBACK_NODE, PWM_LOOPBACK_OUT_IDX) 23 #define PWM_LOOPBACK_OUT_FLAGS \ 24 DT_PWMS_FLAGS_BY_IDX(PWM_LOOPBACK_NODE, PWM_LOOPBACK_OUT_IDX) 25 26 #define PWM_LOOPBACK_IN_CTLR \ 27 DT_PWMS_CTLR_BY_IDX(PWM_LOOPBACK_NODE, PWM_LOOPBACK_IN_IDX) 28 #define PWM_LOOPBACK_IN_CHANNEL \ 29 DT_PWMS_CHANNEL_BY_IDX(PWM_LOOPBACK_NODE, PWM_LOOPBACK_IN_IDX) 30 #define PWM_LOOPBACK_IN_FLAGS \ 31 DT_PWMS_FLAGS_BY_IDX(PWM_LOOPBACK_NODE, PWM_LOOPBACK_IN_IDX) 32 33 struct test_pwm { 34 const struct device *dev; 35 uint32_t pwm; 36 pwm_flags_t flags; 37 }; 38 39 struct test_pwm_callback_data { 40 uint32_t *buffer; 41 size_t buffer_len; 42 size_t count; 43 int status; 44 struct k_sem sem; 45 bool pulse_capture; 46 }; 47 48 void get_test_pwms(struct test_pwm *out, struct test_pwm *in); 49 50 #endif /* __TEST_PWM_LOOPBACK_H__ */ 51