xiaoxiang781216 commented on code in PR #20782:
URL: https://github.com/apache/nuttx/pull/20782#discussion_r4356626410


##########
drivers/timers/taskwdt.c:
##########
@@ -0,0 +1,436 @@
+/****************************************************************************
+ * drivers/timers/taskwdt.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <errno.h>
+#include <nuttx/debug.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/fs/fs.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/list.h>
+#include <nuttx/mutex.h>
+#include <nuttx/sched.h>
+#include <nuttx/wqueue.h>
+#include <nuttx/timers/taskwdt.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define TASKWDT_INTERVAL_TICK MSEC2TICK(CONFIG_TASKWDT_INTERVAL)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* A channel is the state behind one open() of the device */
+
+struct taskwdt_chan_s
+{
+  struct list_node node;                            /* Entry in 
taskwdt_s.chans */
+  pid_t            pid;                             /* Task that opened it */
+  char             name[CONFIG_TASK_NAME_SIZE + 1]; /* Its name */
+  clock_t          timeout;                         /* Timeout in ticks */
+  clock_t          deadline;                        /* Tick the channel 
expires */
+  bool             armed;                           /* Is the channel 
supervised */
+};
+
+struct taskwdt_s
+{
+  struct file      wdt;     /* The hardware watchdog */
+  struct work_s    work;    /* Checks the channels, feeds the hardware */
+  struct list_node chans;   /* All the channels (struct taskwdt_chan_s) */
+  mutex_t          lock;    /* Protects everything above and below */
+  bool             started; /* The hardware watchdog is armed */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int     taskwdt_open(FAR struct file *filep);

Review Comment:
   the plan is great!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to