Lines Matching +full:divider +full:- +full:val
7 * SPDX-License-Identifier: Apache-2.0
44 const struct mcux_wdog32_config *config = dev->config; in mcux_wdog32_setup()
45 struct mcux_wdog32_data *data = dev->data; in mcux_wdog32_setup()
46 WDOG_Type *base = config->base; in mcux_wdog32_setup()
48 if (!data->timeout_valid) { in mcux_wdog32_setup()
50 return -EINVAL; in mcux_wdog32_setup()
53 data->wdog_config.workMode.enableStop = in mcux_wdog32_setup()
56 data->wdog_config.workMode.enableDebug = in mcux_wdog32_setup()
59 WDOG32_Init(base, &data->wdog_config); in mcux_wdog32_setup()
67 const struct mcux_wdog32_config *config = dev->config; in mcux_wdog32_disable()
68 struct mcux_wdog32_data *data = dev->data; in mcux_wdog32_disable()
69 WDOG_Type *base = config->base; in mcux_wdog32_disable()
72 data->timeout_valid = false; in mcux_wdog32_disable()
78 #define MSEC_TO_WDOG32_TICKS(clock_freq, divider, msec) \ argument
79 ((uint32_t)(clock_freq * msec / 1000U / divider))
84 const struct mcux_wdog32_config *config = dev->config; in mcux_wdog32_install_timeout()
85 struct mcux_wdog32_data *data = dev->data; in mcux_wdog32_install_timeout()
89 if (data->timeout_valid) { in mcux_wdog32_install_timeout()
91 return -ENOMEM; in mcux_wdog32_install_timeout()
95 clock_freq = config->clock_frequency; in mcux_wdog32_install_timeout()
97 if (!device_is_ready(config->clock_dev)) { in mcux_wdog32_install_timeout()
99 return -ENODEV; in mcux_wdog32_install_timeout()
102 if (clock_control_get_rate(config->clock_dev, config->clock_subsys, in mcux_wdog32_install_timeout()
104 return -EINVAL; in mcux_wdog32_install_timeout()
108 div = config->clk_divider == kWDOG32_ClockPrescalerDivide1 ? 1U : 256U; in mcux_wdog32_install_timeout()
110 WDOG32_GetDefaultConfig(&data->wdog_config); in mcux_wdog32_install_timeout()
112 data->wdog_config.timeoutValue = in mcux_wdog32_install_timeout()
113 MSEC_TO_WDOG32_TICKS(clock_freq, div, cfg->window.max); in mcux_wdog32_install_timeout()
115 if (cfg->window.min) { in mcux_wdog32_install_timeout()
116 data->wdog_config.enableWindowMode = true; in mcux_wdog32_install_timeout()
117 data->wdog_config.windowValue = in mcux_wdog32_install_timeout()
118 MSEC_TO_WDOG32_TICKS(clock_freq, div, cfg->window.min); in mcux_wdog32_install_timeout()
120 data->wdog_config.enableWindowMode = false; in mcux_wdog32_install_timeout()
121 data->wdog_config.windowValue = 0; in mcux_wdog32_install_timeout()
124 if ((data->wdog_config.timeoutValue < MIN_TIMEOUT) || in mcux_wdog32_install_timeout()
125 (data->wdog_config.timeoutValue < data->wdog_config.windowValue)) { in mcux_wdog32_install_timeout()
127 return -EINVAL; in mcux_wdog32_install_timeout()
130 data->wdog_config.prescaler = config->clk_divider; in mcux_wdog32_install_timeout()
131 data->wdog_config.clockSource = config->clk_source; in mcux_wdog32_install_timeout()
132 data->wdog_config.enableInterrupt = cfg->callback != NULL; in mcux_wdog32_install_timeout()
133 data->callback = cfg->callback; in mcux_wdog32_install_timeout()
134 data->timeout_valid = true; in mcux_wdog32_install_timeout()
136 data->wdog_config.timeoutValue); in mcux_wdog32_install_timeout()
143 const struct mcux_wdog32_config *config = dev->config; in mcux_wdog32_feed()
144 WDOG_Type *base = config->base; in mcux_wdog32_feed()
148 return -EINVAL; in mcux_wdog32_feed()
159 const struct mcux_wdog32_config *config = dev->config; in mcux_wdog32_isr()
160 struct mcux_wdog32_data *data = dev->data; in mcux_wdog32_isr()
161 WDOG_Type *base = config->base; in mcux_wdog32_isr()
167 if (data->callback) { in mcux_wdog32_isr()
168 data->callback(dev, 0); in mcux_wdog32_isr()
174 const struct mcux_wdog32_config *config = dev->config; in mcux_wdog32_init()
176 config->irq_config_func(dev); in mcux_wdog32_init()
188 #define TO_WDOG32_CLK_SRC(val) _DO_CONCAT(kWDOG32_ClockSource, val) argument
189 #define TO_WDOG32_CLK_DIV(val) _DO_CONCAT(kWDOG32_ClockPrescalerDivide, val) argument