My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifdef TARGET_LPC1768
  23. #include "../../inc/MarlinConfig.h"
  24. #if ENABLED(USE_WATCHDOG)
  25. #include <lpc17xx_wdt.h>
  26. #include "watchdog.h"
  27. void watchdog_init() {
  28. #if ENABLED(WATCHDOG_RESET_MANUAL)
  29. // We enable the watchdog timer, but only for the interrupt.
  30. // Configure WDT to only trigger an interrupt
  31. // Disable WDT interrupt (just in case, to avoid triggering it!)
  32. NVIC_DisableIRQ(WDT_IRQn);
  33. // We NEED memory barriers to ensure Interrupts are actually disabled!
  34. // ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
  35. __DSB();
  36. __ISB();
  37. // Configure WDT to only trigger an interrupt
  38. // Initialize WDT with the given parameters
  39. WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_INT_ONLY);
  40. // Configure and enable WDT interrupt.
  41. NVIC_ClearPendingIRQ(WDT_IRQn);
  42. NVIC_SetPriority(WDT_IRQn, 0); // Use highest priority, so we detect all kinds of lockups
  43. NVIC_EnableIRQ(WDT_IRQn);
  44. #else
  45. WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_RESET);
  46. #endif
  47. WDT_Start(WDT_TIMEOUT);
  48. }
  49. void HAL_watchdog_refresh() {
  50. WDT_Feed();
  51. #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
  52. TOGGLE(LED_PIN); // heartbeat indicator
  53. #endif
  54. }
  55. // Timeout state
  56. bool watchdog_timed_out() { return TEST(WDT_ReadTimeOutFlag(), 0); }
  57. void watchdog_clear_timeout_flag() { WDT_ClrTimeOutFlag(); }
  58. #endif // USE_WATCHDOG
  59. #endif // TARGET_LPC1768