File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ const struct device *wdog_r;
6969static unsigned int reload_cycles = CMSDK_APB_WDOG_RELOAD ;
7070static uint8_t assigned_channels ;
7171static uint8_t flags ;
72+ static bool enabled ;
7273
7374static void (* user_cb )(const struct device * dev , int channel_id );
7475
@@ -88,13 +89,19 @@ static int wdog_cmsdk_apb_setup(const struct device *dev, uint8_t options)
8889 ARG_UNUSED (dev );
8990 ARG_UNUSED (options );
9091
92+ /* Check if watchdog is already running */
93+ if (enabled ) {
94+ return - EBUSY ;
95+ }
96+
9197 /* Reset pending interrupts before starting */
9298 wdog -> intclr = CMSDK_APB_WDOG_INTCLR ;
9399 wdog -> load = reload_cycles ;
94100
95101 /* Start the watchdog counter with INTEN bit */
96102 wdog -> ctrl = (CMSDK_APB_WDOG_CTRL_RESEN | CMSDK_APB_WDOG_CTRL_INTEN );
97103
104+ enabled = true;
98105 return 0 ;
99106}
100107
@@ -107,6 +114,7 @@ static int wdog_cmsdk_apb_disable(const struct device *dev)
107114 /* Stop the watchdog counter with INTEN bit */
108115 wdog -> ctrl = ~(CMSDK_APB_WDOG_CTRL_RESEN | CMSDK_APB_WDOG_CTRL_INTEN );
109116
117+ enabled = false;
110118 assigned_channels = 0 ;
111119
112120 return 0 ;
@@ -123,6 +131,9 @@ static int wdog_cmsdk_apb_install_timeout(const struct device *dev,
123131 if (config -> window .max == 0 ) {
124132 return - EINVAL ;
125133 }
134+ if (enabled == true) {
135+ return - EBUSY ;
136+ }
126137 if (assigned_channels == 1 ) {
127138 return - ENOMEM ;
128139 }
You can’t perform that action at this time.
0 commit comments