Subversion Repositories HomeAutomation

Rev

Rev 283 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 283 Rev 299
Line 86... Line 86...
86
    for (i = 0; i < len; i+=2) {
86
    for (i = 0; i < len; i+=2) {
87
        flash_write_word(dst + i, pgm_read_word(src + i));
87
        flash_write_word(dst + i, pgm_read_word(src + i));
88
        wdt_reset();
88
        wdt_reset();
89
    }
89
    }
90
    flash_flush_buffer();
90
    flash_flush_buffer();
-
 
91
    while (1); // Nothing more we can do, hopefully there is a watchdog active
-
 
92
}
-
 
93
#endif
-
 
94
 
-
 
95
#ifdef FLASH_COPY_DATA_NEW
-
 
96
extern uint16_t __flash_code_start;
-
 
97
 
-
 
98
void flash_copy_data(uint16_t src, uint16_t dst, uint16_t len) {
-
 
99
    uint16_t offset;
-
 
100
    uint16_t data;
-
 
101
 
-
 
102
    cli(); // From this point we're on our own
-
 
103
   
-
 
104
    for (offset = 0; offset < len; offset += 2) {
-
 
105
        if (dst + offset >= (uint16_t)&__flash_code_start) break;
-
 
106
        data = pgm_read_word(src + offset);
-
 
107
        boot_page_fill(dst + offset, data);
-
 
108
        if ((dst + offset + 2) % SPM_PAGESIZE == 0) {
-
 
109
            boot_page_erase(dst + offset);
-
 
110
            //boot_spm_busy_wait();      // Wait until the memory is erased.
-
 
111
           
-
 
112
            boot_page_write(dst + offset);     // Store buffer in flash page.
-
 
113
            //boot_spm_busy_wait();       // Wait until the memory is written.
-
 
114
        }
-
 
115
           
-
 
116
        wdt_reset();
-
 
117
    }
91
    while (1); // Nothing more we can do, hopefully there is a watchdog active
118
    while (1); // Nothing more we can do, hopefully there is a watchdog active
92
}
119
}
93
#endif
120
#endif