From aafa4ba18e162d4c0dd761645aeac186b8d5ffce Mon Sep 17 00:00:00 2001 From: Adam Wojasinski Date: Fri, 21 Apr 2023 12:12:14 +0200 Subject: [PATCH] drivers: watchdog: wdt_nrfx: Align behaviour parameter New nrfx release replaces `nrf_wdt_behaviour_t` type to `nrf_wdt_behaviour_mask_t` enumerator. As a result function setting behaviour accepts `uint32_t` bitmask of behaviour. This commit aligns symbols used in SHIM to the ones introduced with the nrfx release. Signed-off-by: Adam Wojasinski --- drivers/watchdog/wdt_nrfx.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/watchdog/wdt_nrfx.c b/drivers/watchdog/wdt_nrfx.c index a4bffa967dc..007ff133a17 100644 --- a/drivers/watchdog/wdt_nrfx.c +++ b/drivers/watchdog/wdt_nrfx.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include @@ -27,19 +28,19 @@ static int wdt_nrf_setup(const struct device *dev, uint8_t options) { const struct wdt_nrfx_config *config = dev->config; struct wdt_nrfx_data *data = dev->data; - nrf_wdt_behaviour_t behaviour; + uint32_t behaviour; /* Activate all available options. Run in all cases. */ - behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP_HALT; + behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP_MASK | NRF_WDT_BEHAVIOUR_RUN_HALT_MASK; /* Deactivate running in sleep mode. */ if (options & WDT_OPT_PAUSE_IN_SLEEP) { - behaviour &= ~NRF_WDT_BEHAVIOUR_RUN_SLEEP; + behaviour &= ~NRF_WDT_BEHAVIOUR_RUN_SLEEP_MASK; } /* Deactivate running when debugger is attached. */ if (options & WDT_OPT_PAUSE_HALTED_BY_DBG) { - behaviour &= ~NRF_WDT_BEHAVIOUR_RUN_HALT; + behaviour &= ~NRF_WDT_BEHAVIOUR_RUN_HALT_MASK; } nrf_wdt_behaviour_set(config->wdt.p_reg, behaviour); @@ -133,28 +134,26 @@ static const struct wdt_driver_api wdt_nrfx_driver_api = { .feed = wdt_nrf_feed, }; -static void wdt_event_handler(const struct device *dev) +static void wdt_event_handler(const struct device *dev, uint32_t requests) { - const struct wdt_nrfx_config *config = dev->config; struct wdt_nrfx_data *data = dev->data; - int i; - for (i = 0; i < data->m_allocated_channels; ++i) { - if (nrf_wdt_request_status(config->wdt.p_reg, - (nrf_wdt_rr_register_t)i)) { - if (data->m_callbacks[i]) { - data->m_callbacks[i](dev, i); - } + while (requests) { + uint8_t i = u32_count_trailing_zeros(requests); + + if (data->m_callbacks[i]) { + data->m_callbacks[i](dev, i); } + requests &= ~BIT(i); } } #define WDT(idx) DT_NODELABEL(wdt##idx) #define WDT_NRFX_WDT_DEVICE(idx) \ - static void wdt_##idx##_event_handler(void) \ + static void wdt_##idx##_event_handler(uint32_t requests) \ { \ - wdt_event_handler(DEVICE_DT_GET(WDT(idx))); \ + wdt_event_handler(DEVICE_DT_GET(WDT(idx)), requests); \ } \ static int wdt_##idx##_init(const struct device *dev) \ { \ @@ -177,8 +176,9 @@ static void wdt_event_handler(const struct device *dev) static const struct wdt_nrfx_config wdt_##idx##z_config = { \ .wdt = NRFX_WDT_INSTANCE(idx), \ .config = { \ - .behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP_HALT, \ - .reload_value = 2000, \ + .behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP_MASK | \ + NRF_WDT_BEHAVIOUR_RUN_HALT_MASK, \ + .reload_value = 2000, \ } \ }; \ DEVICE_DT_DEFINE(WDT(idx), \