Reboot using Arduino standard 1200bps/DTR=0
Allow the IDE to cause the chip to reboot when the Serial port is active and the baud is set to 1200 followed by a DTR toggle. The user still needs to hold the BOOTSEL button to enable the UF2 boot, for now.
This commit is contained in:
parent
ded383ed42
commit
e0e0d9e115
2 changed files with 25 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ This is an under-development port of the RP2040 (Raspberry Pi Pico processor) to
|
|||
|
||||
It uses a custom toolset with GCC 10.2 and Newlib 4.0.0, not depending on system-installed prerequisites. https://github.com/earlephilhower/pico-quick-toolchain
|
||||
|
||||
Only delay, analogWrite, and digitalWrite are implemented now. The biggest hurdle was getting a working build system outside of the pick-sdk CMake environment.
|
||||
The biggest hurdle was getting a working build system outside of the pick-sdk CMake environment.
|
||||
Presently, a manually build `pico.a` file is generated using objects compiled by `cmake` in the pico-examples repo, but in the future this will be scripted and automated.
|
||||
|
||||
There is automated discovery of boards in bootloader mode, so they show up in the IDE, and the upload command works using the Microsoft UF2 tool (included).
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ extern "C" {
|
|||
#include "pico/binary_info.h"
|
||||
#include "hardware/irq.h"
|
||||
#include "pico/mutex.h"
|
||||
#include "hardware/watchdog.h"
|
||||
}
|
||||
#define PICO_STDIO_USB_TASK_INTERVAL_US 1000
|
||||
#define PICO_STDIO_USB_LOW_PRIORITY_IRQ 31
|
||||
|
|
@ -220,3 +221,26 @@ SerialUSB::operator bool() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static bool _dtr = false;
|
||||
static bool _rts = false;
|
||||
static int _bps = 115200;
|
||||
static void CheckSerialReset() {
|
||||
if ((_bps == 1200) && (!_dtr)) {
|
||||
watchdog_enable(100, 1);
|
||||
while (1); // WDT will fire here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern "C" void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
|
||||
_dtr = dtr ? true : false;
|
||||
_rts = rts ? true : false;
|
||||
CheckSerialReset();
|
||||
}
|
||||
|
||||
extern "C" void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding) {
|
||||
_bps = p_line_coding->bit_rate;
|
||||
CheckSerialReset();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue