Merge pull request #495 from tannewt/fix_baud_reset

Fix 1200 baud reset.
This commit is contained in:
Dan Halbert 2017-12-20 18:32:55 -05:00 committed by GitHub
commit e671fa2f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions

View File

@ -55,7 +55,6 @@ void common_hal_mcu_enable_interrupts(void) {
}
extern uint32_t _ezero;
extern uint32_t _srelocate;
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
// Set up the defaults.
@ -63,7 +62,7 @@ void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
_ezero = CIRCUITPY_CANARY_WORD;
if (runmode == RUNMODE_BOOTLOADER) {
if (&_bootloader_dbl_tap < &_srelocate) {
if (!bootloader_available()) {
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

View File

@ -62,7 +62,7 @@ volatile bool reset_on_disconnect = false;
void usb_dtr_notify(uint8_t port, bool set) {
mp_cdc_enabled = set;
if (!set && reset_on_disconnect && _bootloader_dbl_tap != 0) {
if (!set && reset_on_disconnect && bootloader_available()) {
reset_to_bootloader();
}
}

View File

@ -38,3 +38,8 @@ void reset_to_bootloader(void) {
_bootloader_dbl_tap = DBL_TAP_MAGIC;
reset();
}
extern uint32_t _srelocate;
bool bootloader_available(void) {
return &_bootloader_dbl_tap >= &_srelocate;
}

View File

@ -33,5 +33,6 @@ extern uint32_t _bootloader_dbl_tap;
void reset_to_bootloader(void);
void reset(void);
bool bootloader_available(void);
#endif // MICROPY_INCLUDED_ATMEL_SAMD_RESET_H