| Line 13... | 
        Line 13... | 
      
      
        | 13 | 
          | 
        13 | 
          | 
      
      
        | 14 | 
          | 
        14 | 
          | 
      
      
        | 15 | 
        #INT_RDA | 
        15 | 
        #INT_RDA | 
      
      
        | 16 | 
        rs232_handler() | 
        16 | 
        rs232_handler() | 
      
      
        | 17 | 
        { | 
        17 | 
        { | 
      
      
        | 18 | 
           putchar(getc());    | 
        18 | 
           putchar(getc()); | 
      
      
        | 19 | 
        } | 
        19 | 
        } | 
      
      
        | 20 | 
          | 
        20 | 
          | 
      
      
        | 21 | 
          | 
        21 | 
          | 
      
      
        | 22 | 
        /*-------------------------------- MAIN --------------------------------------*/ | 
        22 | 
        /*-------------------------------- MAIN --------------------------------------*/ | 
      
      
        | 23 | 
        #SEPARATE | 
        23 | 
        #SEPARATE | 
      
      
        | Line 41... | 
        Line 41... | 
      
      
        | 41 | 
        #define LOADER_RESERVED    getenv("PROGRAM_MEMORY")-26*FLASH_BLOCK_SIZE | 
        41 | 
        #define LOADER_RESERVED    getenv("PROGRAM_MEMORY")-26*FLASH_BLOCK_SIZE | 
      
      
        | 42 | 
        #define BUFFER_LEN_LOD     46 | 
        42 | 
        #define BUFFER_LEN_LOD     46 | 
      
      
        | 43 | 
        #if FLASH_BLOCK_SIZE != getenv("FLASH_ERASE_SIZE")/2 | 
        43 | 
        #if FLASH_BLOCK_SIZE != getenv("FLASH_ERASE_SIZE")/2 | 
      
      
        | 44 | 
          #error Wrong length of the Flash Block Size. getenv("FLASH_ERASE_SIZE")/getenv("FLASH_WRITE_SIZE") | 
        44 | 
          #error Wrong length of the Flash Block Size. getenv("FLASH_ERASE_SIZE")/getenv("FLASH_WRITE_SIZE") | 
      
      
        | 45 | 
        #endif | 
        45 | 
        #endif | 
      
      
        | 46 | 
            | 
        46 | 
          | 
      
      
        | 47 | 
          | 
        47 | 
          | 
      
      
        | 48 | 
        #BUILD(INTERRUPT=FLASH_BLOCK_SIZE)   // Redirect Interrupt routine above first flash block | 
        48 | 
        #BUILD(INTERRUPT=FLASH_BLOCK_SIZE)   // Redirect Interrupt routine above first flash block | 
      
      
        | 49 | 
        #ORG 4,5 | 
        49 | 
        #ORG 4,5 | 
      
      
        | 50 | 
        void JumpToTheInterrupt()     // Jump to the Interrupt Handler | 
        50 | 
        void JumpToTheInterrupt()     // Jump to the Interrupt Handler | 
      
      
        | 51 | 
        { #asm GOTO FLASH_BLOCK_SIZE #endasm } | 
        51 | 
        { #asm GOTO FLASH_BLOCK_SIZE #endasm } | 
      
      
        | 52 | 
        #ORG 6,FLASH_BLOCK_SIZE-1 {} // First Flash block is reserved | 
        52 | 
        #ORG 6,FLASH_BLOCK_SIZE-1 {} // First Flash block is reserved | 
      
      
        | 53 | 
          | 
        53 | 
          | 
      
      
        | 54 | 
          | 
        54 | 
          | 
      
      
        | 55 | 
        #ORG LOADER_RESERVED,LOADER_RESERVED+FLASH_BLOCK_SIZE-1 auto=0 | 
        55 | 
        #ORG LOADER_RESERVED,LOADER_RESERVED+FLASH_BLOCK_SIZE-1 auto=0 | 
      
      
        | 56 | 
        #SEPARATE | 
        56 | 
        #SEPARATE | 
      
      
        | 57 | 
        void dumy_main() // Main on the fix position | 
        57 | 
        void dummy_main() // Main on the fix position | 
      
      
        | 58 | 
        { | 
        58 | 
        { | 
      
      
        | 59 | 
           real_main(); | 
        59 | 
           real_main(); | 
      
      
        | 60 | 
        } | 
        60 | 
        } | 
      
      
        | 61 | 
          | 
        61 | 
          | 
      
      
        | 62 | 
        #ORG LOADER_RESERVED+FLASH_BLOCK_SIZE,getenv("PROGRAM_MEMORY")-125 auto=0 default | 
        62 | 
        #ORG LOADER_RESERVED+FLASH_BLOCK_SIZE,getenv("PROGRAM_MEMORY")-125 auto=0 default | 
      
      
        | Line 167... | 
        Line 167... | 
      
      
        | 167 | 
              { | 
        167 | 
              { | 
      
      
        | 168 | 
          | 
        168 | 
          | 
      
      
        | 169 | 
                 if (line_type == 0) | 
        169 | 
                 if (line_type == 0) | 
      
      
        | 170 | 
                 { | 
        170 | 
                 { | 
      
      
        | 171 | 
                    // Read old program memory content | 
        171 | 
                    // Read old program memory content | 
      
      
        | 172 | 
                    for (i=0,next_addr=addr;i<8;i++)   | 
        172 | 
                    for (i=0,next_addr=addr;i<8;i++) | 
      
      
        | 173 | 
                       data.i16[i]=read_program_eeprom(next_addr++); | 
        173 | 
                       data.i16[i]=read_program_eeprom(next_addr++); | 
      
      
        | 174 | 
                    // Loops through all of the data and stores it in data | 
        174 | 
                    // Loops through all of the data and stores it in data | 
      
      
        | 175 | 
                    // The last 2 bytes are the check sum, hence buffidx-3 | 
        175 | 
                    // The last 2 bytes are the check sum, hence buffidx-3 | 
      
      
        | 176 | 
                    for (i=8,dataidx=0; i < buffidx-3; i += 2) | 
        176 | 
                    for (i=8,dataidx=0; i < buffidx-3; i += 2) | 
      
      
        | 177 | 
                       data.i8[dataidx++]=atoi_b16(&buffer[i]); | 
        177 | 
                       data.i8[dataidx++]=atoi_b16(&buffer[i]); | 
      
      
        | 178 | 
          | 
        178 | 
          | 
      
      
        | 179 | 
                    if (addr == 0)  | 
        179 | 
                    if (addr == 0) | 
      
      
        | 180 | 
                    { | 
        180 | 
                    { | 
      
      
        | 181 | 
                        | 
        181 | 
          | 
      
      
        | 182 | 
                       // Write 8 words to the Loader location | 
        182 | 
                       // Write 8 words to the Loader location | 
      
      
        | 183 | 
                       addr=LOADER_RESERVED; | 
        183 | 
                       addr=LOADER_RESERVED; | 
      
      
        | 184 | 
                       for (i=0;i<8;i++)  | 
        184 | 
                       for (i=0;i<8;i++) | 
      
      
        | 185 | 
                         write_program_eeprom(addr++, data.i16[i]); | 
        185 | 
                         write_program_eeprom(addr++, data.i16[i]); | 
      
      
        | 186 | 
                       putchar('%'); | 
        186 | 
                       putchar('%'); | 
      
      
        | 187 | 
                    } | 
        187 | 
                    } | 
      
      
        | 188 | 
                    else | 
        188 | 
                    else | 
      
      
        | 189 | 
                    if (addr > 7 && addr < LOADER_RESERVED) | 
        189 | 
                    if (addr > 7 && addr < LOADER_RESERVED) | 
      
      
        | Line 238... | 
        Line 238... | 
      
      
        | 238 | 
              restart_wdt(); | 
        238 | 
              restart_wdt(); | 
      
      
        | 239 | 
           }; | 
        239 | 
           }; | 
      
      
        | 240 | 
          | 
        240 | 
          | 
      
      
        | 241 | 
           CREN=0; CREN=1;   // Reinitialise USART | 
        241 | 
           CREN=0; CREN=1;   // Reinitialise USART | 
      
      
        | 242 | 
           restart_wdt(); | 
        242 | 
           restart_wdt(); | 
      
      
        | 243 | 
           goto_address(LOADER_RESERVED); // Jump to the location where is the jump to the main  | 
        243 | 
           goto_address(LOADER_RESERVED); // Jump to the location where is the jump to the main | 
      
      
        | 244 | 
        } | 
        244 | 
        } | 
      
      
        | 245 | 
            | 
        245 | 
          |