@@ -107,7 +107,8 @@ static int wdt_nrf_install_timeout(const struct device *dev,
107107 * the timeout) from range 0xF-0xFFFFFFFF given in 32768 Hz
108108 * clock ticks. This makes the allowed range of 0x1-0x07CFFFFF
109109 * in milliseconds. Check if the provided value is within
110- * this range. */
110+ * this range.
111+ */
111112 if ((cfg -> window .max == 0U ) || (cfg -> window .max > 0x07CFFFFF )) {
112113 return - EINVAL ;
113114 }
@@ -155,6 +156,7 @@ static const struct wdt_driver_api wdt_nrfx_driver_api = {
155156 .feed = wdt_nrf_feed ,
156157};
157158
159+ #if !defined(CONFIG_WDT_NRFX_NO_IRQ )
158160static void wdt_event_handler (const struct device * dev , nrf_wdt_event_t event_type ,
159161 uint32_t requests , void * p_context )
160162{
@@ -172,45 +174,47 @@ static void wdt_event_handler(const struct device *dev, nrf_wdt_event_t event_ty
172174 requests &= ~BIT (i );
173175 }
174176}
177+ #endif
175178
176179#define WDT (idx ) DT_NODELABEL(wdt##idx)
177180
178- #define WDT_NRFX_WDT_DEVICE (idx ) \
179- static void wdt_##idx##_event_handler(nrf_wdt_event_t event_type, \
180- uint32_t requests, \
181- void *p_context) \
182- { \
183- wdt_event_handler(DEVICE_DT_GET(WDT(idx)), event_type, \
184- requests, p_context); \
185- } \
186- static int wdt_##idx##_init(const struct device *dev) \
187- { \
188- const struct wdt_nrfx_config *config = dev->config; \
189- nrfx_err_t err_code; \
190- IRQ_CONNECT(DT_IRQN(WDT(idx)), DT_IRQ(WDT(idx), priority), \
191- nrfx_isr, nrfx_wdt_##idx##_irq_handler, 0); \
192- err_code = nrfx_wdt_init(&config->wdt, \
193- NULL, \
194- wdt_##idx##_event_handler, \
195- NULL); \
196- if (err_code != NRFX_SUCCESS) { \
197- return -EBUSY; \
198- } \
199- return 0; \
200- } \
201- static struct wdt_nrfx_data wdt_##idx##_data = { \
202- .m_timeout = 0, \
203- .m_allocated_channels = 0, \
204- }; \
205- static const struct wdt_nrfx_config wdt_##idx##z_config = { \
206- .wdt = NRFX_WDT_INSTANCE(idx), \
207- }; \
208- DEVICE_DT_DEFINE(WDT(idx), \
209- wdt_##idx##_init, \
210- NULL, \
211- &wdt_##idx##_data, \
212- &wdt_##idx##z_config, \
213- PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
181+ #define WDT_NRFX_WDT_DEVICE (idx ) \
182+ COND_CODE_0(IS_ENABLED(CONFIG_WDT_NRFX_NO_IRQ), ( \
183+ static void wdt_##idx##_event_handler(nrf_wdt_event_t event_type, \
184+ uint32_t requests, \
185+ void *p_context) \
186+ { \
187+ wdt_event_handler(DEVICE_DT_GET(WDT(idx)), event_type, \
188+ requests, p_context); \
189+ } \
190+ ), ()) \
191+ static int wdt_##idx##_init(const struct device *dev) \
192+ { \
193+ const struct wdt_nrfx_config *config = dev->config; \
194+ nrfx_err_t err_code; \
195+ COND_CODE_0(IS_ENABLED(CONFIG_WDT_NRFX_NO_IRQ), ( \
196+ IRQ_CONNECT(DT_IRQN(WDT(idx)), DT_IRQ(WDT(idx), \
197+ priority), nrfx_isr, nrfx_wdt_##idx##_irq_handler, 0);), ()) \
198+ err_code = nrfx_wdt_init(&config->wdt, \
199+ NULL, \
200+ COND_CODE_0(IS_ENABLED(CONFIG_WDT_NRFX_NO_IRQ), \
201+ (wdt_##idx##_event_handler,), (NULL,)) \
202+ NULL); \
203+ if (err_code != NRFX_SUCCESS) { \
204+ return -EBUSY; \
205+ } \
206+ return 0; \
207+ } \
208+ static struct wdt_nrfx_data wdt_##idx##_data; \
209+ static const struct wdt_nrfx_config wdt_##idx##z_config = { \
210+ .wdt = NRFX_WDT_INSTANCE(idx), \
211+ }; \
212+ DEVICE_DT_DEFINE(WDT(idx), \
213+ wdt_##idx##_init, \
214+ NULL, \
215+ &wdt_##idx##_data, \
216+ &wdt_##idx##z_config, \
217+ PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
214218 &wdt_nrfx_driver_api)
215219
216220#ifdef CONFIG_HAS_HW_NRF_WDT0
0 commit comments