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.

watchdog_SAMD51.cpp 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  5. * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. #ifdef __SAMD51__
  22. #include "../../inc/MarlinConfig.h"
  23. #if ENABLED(USE_WATCHDOG)
  24. #include "watchdog_SAMD51.h"
  25. void watchdog_init(void) {
  26. // The low-power oscillator used by the WDT runs at 32,768 Hz with
  27. // a 1:32 prescale, thus 1024 Hz, though probably not super precise.
  28. // Setup WDT clocks
  29. MCLK->APBAMASK.bit.OSC32KCTRL_ = true;
  30. MCLK->APBAMASK.bit.WDT_ = true;
  31. OSC32KCTRL->OSCULP32K.bit.EN1K = true; // Enable out 1K (this is what WDT uses)
  32. WDT->CTRLA.bit.ENABLE = false; // Disable watchdog for config
  33. SYNC(WDT->SYNCBUSY.bit.ENABLE);
  34. WDT->INTENCLR.reg = WDT_INTENCLR_EW; // Disable early warning interrupt
  35. WDT->CONFIG.reg = WDT_CONFIG_PER_CYC4096; // Set at least 4s period for chip reset
  36. watchdog_reset();
  37. WDT->CTRLA.reg = WDT_CTRLA_ENABLE; // Start watchdog now in normal mode
  38. SYNC(WDT->SYNCBUSY.bit.ENABLE);
  39. }
  40. #endif // USE_WATCHDOG
  41. #endif // __SAMD51__