This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 3be1fc8cf4aa42a72c991a1f740109a2ea0c8155
Author: Daniel P. Carvalho <[email protected]>
AuthorDate: Sat Oct 10 18:34:49 2026 -0300

    boards/ev49n51a: register the watchdog as /dev/watchdog0.
    
    Register the PIC32MZ watchdog from the board bring-up when PIC32MZ_WDT is
    enabled and program a time-out of 8192 base periods.
    
    Assisted-by: Claude Code:claude-sonnet-5-5
    Signed-off-by: Daniel P. Carvalho <[email protected]>
---
 boards/mips/pic32mz/ev49n51a/include/board.h       |  9 ++++++---
 boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c | 14 ++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/boards/mips/pic32mz/ev49n51a/include/board.h 
b/boards/mips/pic32mz/ev49n51a/include/board.h
index 6c382045545..91d26bd40a9 100644
--- a/boards/mips/pic32mz/ev49n51a/include/board.h
+++ b/boards/mips/pic32mz/ev49n51a/include/board.h
@@ -109,11 +109,14 @@
 #undef BOARD_PBCLK7_ENABLE
 #undef BOARD_PBCLK8_ENABLE
 
-/* Watchdog pre-scaler (not yet used - WDT is left disabled by the
- * reference config; revisit if/when WDT support is added for this chip).
+/* Watchdog pre-scaler: the time-out is this value times the base period of
+ * the LPRC-clocked watchdog (CONFIG_PIC32MZ_WDT_BASE_US).  It is programmed
+ * in the device configuration and cannot be changed at run time.  The
+ * watchdog itself is started by software (PIC32MZ_WDT) unless
+ * CONFIG_PIC32MZ_WDTENABLE hardware-enables it from reset.
  */
 
-#define BOARD_WD_PRESCALER     1048576
+#define BOARD_WD_PRESCALER     8192
 
 /* Ethernet MII management clock (MDC).
  *
diff --git a/boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c 
b/boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c
index 07ebc5ebb4c..1987ff66670 100644
--- a/boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c
+++ b/boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c
@@ -40,6 +40,10 @@
 #  include "pic32mz_w1_wlan.h"
 #endif
 
+#ifdef CONFIG_PIC32MZ_WDT
+#  include "pic32mz_wdt.h"
+#endif
+
 #include "ev49n51a.h"
 
 /****************************************************************************
@@ -69,6 +73,16 @@ int pic32mz_bringup(void)
     }
 #endif
 
+#ifdef CONFIG_PIC32MZ_WDT
+  /* Watchdog timer */
+
+  ret = pic32mz_wdt_initialize(CONFIG_WATCHDOG_DEVPATH);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: Failed to register the watchdog: %d\n", ret);
+    }
+#endif
+
 #if defined(CONFIG_MTD_SST26) && defined(CONFIG_PIC32MZ_SPI1)
   struct spi_dev_s *spi;
   struct mtd_dev_s *mtd;

Reply via email to