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;
69
69
static unsigned int reload_cycles = CMSDK_APB_WDOG_RELOAD ;
70
70
static uint8_t assigned_channels ;
71
71
static uint8_t flags ;
72
+ static bool enabled ;
72
73
73
74
static void (* user_cb )(const struct device * dev , int channel_id );
74
75
@@ -88,13 +89,19 @@ static int wdog_cmsdk_apb_setup(const struct device *dev, uint8_t options)
88
89
ARG_UNUSED (dev );
89
90
ARG_UNUSED (options );
90
91
92
+ /* Check if watchdog is already running */
93
+ if (enabled ) {
94
+ return - EBUSY ;
95
+ }
96
+
91
97
/* Reset pending interrupts before starting */
92
98
wdog -> intclr = CMSDK_APB_WDOG_INTCLR ;
93
99
wdog -> load = reload_cycles ;
94
100
95
101
/* Start the watchdog counter with INTEN bit */
96
102
wdog -> ctrl = (CMSDK_APB_WDOG_CTRL_RESEN | CMSDK_APB_WDOG_CTRL_INTEN );
97
103
104
+ enabled = true;
98
105
return 0 ;
99
106
}
100
107
@@ -107,6 +114,7 @@ static int wdog_cmsdk_apb_disable(const struct device *dev)
107
114
/* Stop the watchdog counter with INTEN bit */
108
115
wdog -> ctrl = ~(CMSDK_APB_WDOG_CTRL_RESEN | CMSDK_APB_WDOG_CTRL_INTEN );
109
116
117
+ enabled = false;
110
118
assigned_channels = 0 ;
111
119
112
120
return 0 ;
@@ -123,6 +131,9 @@ static int wdog_cmsdk_apb_install_timeout(const struct device *dev,
123
131
if (config -> window .max == 0 ) {
124
132
return - EINVAL ;
125
133
}
134
+ if (enabled == true) {
135
+ return - EBUSY ;
136
+ }
126
137
if (assigned_channels == 1 ) {
127
138
return - ENOMEM ;
128
139
}
You can’t perform that action at this time.
0 commit comments