12345678910111213141516171819202122232425262728 |
- /**
- * Copyright (c) 2022 Brian Starkey <stark3y@gmail.com>
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
- #include "RP2040.h"
- #include "hardware/structs/watchdog.h"
- #include "hardware/watchdog.h"
-
- #include "picowota/reboot.h"
-
- void picowota_reboot(bool to_bootloader)
- {
- hw_clear_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS);
- if (to_bootloader) {
- watchdog_hw->scratch[5] = PICOWOTA_BOOTLOADER_ENTRY_MAGIC;
- watchdog_hw->scratch[6] = ~PICOWOTA_BOOTLOADER_ENTRY_MAGIC;
- } else {
- watchdog_hw->scratch[5] = 0;
- watchdog_hw->scratch[6] = 0;
- }
- watchdog_reboot(0, 0, 0);
- while (1) {
- tight_loop_contents();
- asm("");
- }
- }
|