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.

12345678910111213141516171819202122232425262728
  1. /**
  2. * Copyright (c) 2022 Brian Starkey <stark3y@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include "RP2040.h"
  7. #include "hardware/structs/watchdog.h"
  8. #include "hardware/watchdog.h"
  9. #include "picowota/reboot.h"
  10. void picowota_reboot(bool to_bootloader)
  11. {
  12. hw_clear_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS);
  13. if (to_bootloader) {
  14. watchdog_hw->scratch[5] = PICOWOTA_BOOTLOADER_ENTRY_MAGIC;
  15. watchdog_hw->scratch[6] = ~PICOWOTA_BOOTLOADER_ENTRY_MAGIC;
  16. } else {
  17. watchdog_hw->scratch[5] = 0;
  18. watchdog_hw->scratch[6] = 0;
  19. }
  20. watchdog_reboot(0, 0, 0);
  21. while (1) {
  22. tight_loop_contents();
  23. asm("");
  24. }
  25. }