Merge pull request #495 from tannewt/fix_baud_reset
Fix 1200 baud reset.
This commit is contained in:
commit
e671fa2f7a
@ -55,7 +55,6 @@ void common_hal_mcu_enable_interrupts(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern uint32_t _ezero;
|
extern uint32_t _ezero;
|
||||||
extern uint32_t _srelocate;
|
|
||||||
|
|
||||||
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
||||||
// Set up the defaults.
|
// Set up the defaults.
|
||||||
@ -63,7 +62,7 @@ void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
|||||||
_ezero = CIRCUITPY_CANARY_WORD;
|
_ezero = CIRCUITPY_CANARY_WORD;
|
||||||
|
|
||||||
if (runmode == RUNMODE_BOOTLOADER) {
|
if (runmode == RUNMODE_BOOTLOADER) {
|
||||||
if (&_bootloader_dbl_tap < &_srelocate) {
|
if (!bootloader_available()) {
|
||||||
mp_raise_ValueError("Cannot reset into bootloader because no bootloader is present.");
|
mp_raise_ValueError("Cannot reset into bootloader because no bootloader is present.");
|
||||||
}
|
}
|
||||||
// Pretend to be the first of the two reset presses needed to enter the
|
// Pretend to be the first of the two reset presses needed to enter the
|
||||||
|
@ -62,7 +62,7 @@ volatile bool reset_on_disconnect = false;
|
|||||||
|
|
||||||
void usb_dtr_notify(uint8_t port, bool set) {
|
void usb_dtr_notify(uint8_t port, bool set) {
|
||||||
mp_cdc_enabled = set;
|
mp_cdc_enabled = set;
|
||||||
if (!set && reset_on_disconnect && _bootloader_dbl_tap != 0) {
|
if (!set && reset_on_disconnect && bootloader_available()) {
|
||||||
reset_to_bootloader();
|
reset_to_bootloader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,3 +38,8 @@ void reset_to_bootloader(void) {
|
|||||||
_bootloader_dbl_tap = DBL_TAP_MAGIC;
|
_bootloader_dbl_tap = DBL_TAP_MAGIC;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern uint32_t _srelocate;
|
||||||
|
bool bootloader_available(void) {
|
||||||
|
return &_bootloader_dbl_tap >= &_srelocate;
|
||||||
|
}
|
||||||
|
@ -33,5 +33,6 @@ extern uint32_t _bootloader_dbl_tap;
|
|||||||
|
|
||||||
void reset_to_bootloader(void);
|
void reset_to_bootloader(void);
|
||||||
void reset(void);
|
void reset(void);
|
||||||
|
bool bootloader_available(void);
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_RESET_H
|
#endif // MICROPY_INCLUDED_ATMEL_SAMD_RESET_H
|
||||||
|
Loading…
Reference in New Issue
Block a user