diff --git a/bootloaders/zero/main.c b/bootloaders/zero/main.c index 3b18872a8..50f8269ff 100644 --- a/bootloaders/zero/main.c +++ b/bootloaders/zero/main.c @@ -44,37 +44,6 @@ static void check_start_application(void) // LED_init(); // LED_off(); -#if defined(BOOT_DOUBLE_TAP_ADDRESS) - #define DOUBLE_TAP_MAGIC 0x07738135 - if (PM->RCAUSE.bit.POR) - { - /* On power-on initialize double-tap */ - BOOT_DOUBLE_TAP_DATA = 0; - } - else - { - if (BOOT_DOUBLE_TAP_DATA == DOUBLE_TAP_MAGIC) - { - /* Second tap, stay in bootloader */ - BOOT_DOUBLE_TAP_DATA = 0; - return; - } - - /* First tap */ - BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC; - - /* Wait 0.5sec to see if the user tap reset again. - * The loop value is based on SAMD21 default 1MHz clock @ reset. - */ - for (uint32_t i=0; i<125000; i++) /* 500ms */ - /* force compiler to not optimize this... */ - __asm__ __volatile__(""); - - /* Timeout happened, continue boot... */ - BOOT_DOUBLE_TAP_DATA = 0; - } -#endif - #if (!defined DEBUG) || ((defined DEBUG) && (DEBUG == 0)) uint32_t* pulSketch_Start_Address; #endif @@ -108,6 +77,37 @@ uint32_t* pulSketch_Start_Address; return; } +#if defined(BOOT_DOUBLE_TAP_ADDRESS) + #define DOUBLE_TAP_MAGIC 0x07738135 + if (PM->RCAUSE.bit.POR) + { + /* On power-on initialize double-tap */ + BOOT_DOUBLE_TAP_DATA = 0; + } + else + { + if (BOOT_DOUBLE_TAP_DATA == DOUBLE_TAP_MAGIC) + { + /* Second tap, stay in bootloader */ + BOOT_DOUBLE_TAP_DATA = 0; + return; + } + + /* First tap */ + BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC; + + /* Wait 0.5sec to see if the user tap reset again. + * The loop value is based on SAMD21 default 1MHz clock @ reset. + */ + for (uint32_t i=0; i<125000; i++) /* 500ms */ + /* force compiler to not optimize this... */ + __asm__ __volatile__(""); + + /* Timeout happened, continue boot... */ + BOOT_DOUBLE_TAP_DATA = 0; + } +#endif + /* #if defined(BOOT_LOAD_PIN) volatile PortGroup *boot_port = (volatile PortGroup *)(&(PORT->Group[BOOT_LOAD_PIN / 32]));