File tree 2 files changed +68
-2
lines changed
hardware/arduino/sam/variants/arduino_due_x
2 files changed +68
-2
lines changed Original file line number Diff line number Diff line change @@ -358,6 +358,52 @@ void serialEventRun(void)
358
358
if (Serial3.available ()) serialEvent3 ();
359
359
}
360
360
361
+ // ----------------------------------------------------------------------------
362
+ extern " C" {
363
+
364
+ /* *
365
+ * Watchdog enable
366
+ *
367
+ * Enable the watchdog timer with the specified settings.
368
+ * WDTO_xxx macros provide standard settings.
369
+ * Should only be called once.
370
+ */
371
+ void wdt_enable (uint32_t mode)
372
+ {
373
+ WDT_Enable (WDT, mode);
374
+ }
375
+
376
+ /* *
377
+ * Watchdog disable
378
+ *
379
+ * Disable the watchdog timer.
380
+ * Should only be called once.
381
+ */
382
+ void wdt_disable (void )
383
+ {
384
+ WDT_Disable (WDT);
385
+ }
386
+
387
+ /* *
388
+ * Watchdog reset
389
+ *
390
+ * Resets the watchdog counter
391
+ */
392
+ void wdt_reset (void )
393
+ {
394
+ WDT_Restart (WDT);
395
+ }
396
+
397
+ } // extern "C"
398
+
399
+ /* *
400
+ * Watchdog initialize hook
401
+ *
402
+ * This function is called from init().
403
+ * Default action is to disable watchdog.
404
+ */
405
+ void wdt_initialize (void ) __attribute__ ((weak, alias(" wdt_disable" )));
406
+
361
407
// ----------------------------------------------------------------------------
362
408
363
409
#ifdef __cplusplus
@@ -377,8 +423,8 @@ void init( void )
377
423
while (true );
378
424
}
379
425
380
- // Disable watchdog
381
- WDT_Disable (WDT );
426
+ // Initialize watchdog
427
+ wdt_initialize ( );
382
428
383
429
// Initialize C library
384
430
__libc_init_array ();
Original file line number Diff line number Diff line change @@ -232,6 +232,25 @@ static const uint8_t CAN1TX = 89;
232
232
#define TC_MIN_DUTY_CYCLE 0
233
233
#define TC_RESOLUTION 8
234
234
235
+ // Watchdog routines
236
+
237
+ #define WDTO_15MS WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(4) | WDT_MR_WDD(4)
238
+ #define WDTO_30MS WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(8) | WDT_MR_WDD(8)
239
+ #define WDTO_60MS WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(15) | WDT_MR_WDD(15)
240
+ #define WDTO_120MS WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(31) | WDT_MR_WDD(31)
241
+ #define WDTO_250MS WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(64) | WDT_MR_WDD(64)
242
+ #define WDTO_500MS WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(128) | WDT_MR_WDD(128)
243
+ #define WDTO_1S WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(256) | WDT_MR_WDD(256)
244
+ #define WDTO_2S WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(512) | WDT_MR_WDD(512)
245
+ #define WDTO_4S WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(1024) | WDT_MR_WDD(1024)
246
+ #define WDTO_8S WDT_MR_WDRSTEN | WDT_MR_WDRPROC | WDT_MR_WDV(2048) | WDT_MR_WDD(2048)
247
+
248
+ void wdt_enable (uint32_t mode );
249
+
250
+ void wdt_disable (void );
251
+
252
+ void wdt_reset (void );
253
+
235
254
#ifdef __cplusplus
236
255
}
237
256
#endif
@@ -274,5 +293,6 @@ extern USARTClass Serial3;
274
293
#define SERIAL_PORT_HARDWARE2 Serial2
275
294
#define SERIAL_PORT_HARDWARE3 Serial3
276
295
296
+
277
297
#endif /* _VARIANT_ARDUINO_DUE_X_ */
278
298
You can’t perform that action at this time.
0 commit comments